xylem.installers package

Submodules

xylem.installers.impl module

class xylem.installers.impl.Installer

Bases: builtins.object

Installer class that custom installer plugins derive from.

The Installer API is designed around opaque resolved parameters. These parameters can be any type of sequence object, but they must obey set arithmetic. They should also implement __str__() methods so they can be pretty printed.

get_depends(rule_args)

Get list list of dependencies on other xylem keys.

Parameters:rule_args (dict) – argument dictionary to the xylem rule for this package manager
Returns:List of dependencies on other xylem keys. Only necessary if the package manager doesn’t handle dependencies.
Return type:list of str
get_install_command(resolved, interactive=True, reinstall=False)

Get command line invocations to install list of items.

Parameters:
  • resolved – [resolution]. List of opaque resolved installation items
  • interactive – If False, disable interactive prompts, e.g. pass through -y or equivalent to package manager.
  • reinstall – If True, install everything even if already installed
Returns:

List of commands, each command being a list of strings.

Return type:

[[str]]

static get_name()

Get the name of the installer this class implements.

This is the name that is referenced in the rules files, user configuration or OS plugins. There may only be one installer for a any given name at runtime, i.e. plugins defining installers with existing names might be ignored.

Return str:installer name
get_priority_for_os(os_name, os_version)

Get the priority of this installer according to installer plugin.

Given an OS name/version tuple, the installer can declare that it should be used on that OS with the returned priority. If the installer does not want to declare itself for this OS, None is returned.

Return type:number or None
is_installed(resolved_item)

Check if single opaque installation item is installed.

Parameters:resolved_item – single opaque resolved installation item
Returns:True if all of the resolved items are installed on the local system
resolve(rule_args)

Return list of resolutions from rules dictionary entry.

Parameters:rule_args (dict) – argument dictionary to the xylem rule for this package manager
Returns:[resolution]. Resolved objects should be printable to a user, but are otherwise opaque.
class xylem.installers.impl.InstallerContext(setup_installers=True, os_override=None)

Bases: builtins.object

InstallerContext manages the context of execution for xylem.

It combines OS plugins, installer plugins and user settings to manage the current OS, installers to be used including their priorities.

get_default_installer_name()

Get name of default installer for current os.

setup_installers() needs to be called beforehand.

get_installer(name)

Get installer object by name.

get_installer_names()

Get all configured installers for current os.

setup_installers() needs to be called beforehand.

get_installer_priority(name)

Get configured priority for specific installer and current os.

setup_installers() needs to be called beforehand.

get_os_string()

Get the OS name and version as ‘name:version’ string.

See get_os_tuple()

Return type:str
Raises UnsupportedOsError:
 if OS was not detected correctly
get_os_tuple()

Get the OS (name,version) tuple.

Return the OS name/version tuple to use for resolution and installation. This will be the detected OS name/version unless InstallerContext.set_os_override() has been called.

Returns:(os_name, os_version)
Return type:(str,str)
Raises UnsupportedOsError:
 if OS was not detected correctly
set_os_override(os_tuple)

Override the OS detector with os_name and os_version.

See InstallerContext.detect_os().

Parameters:os_name ((str,str)) – OS (name,version) tuple to use
Raises UnsupportedOsError:
 if os override was invalid
setup_installers()

For current os, setup configured installers.

Installers are set up with their priorities for the current os and based on user config, os plugins and installer plugins.

xylem.installers.impl.get_installer_plugin_list()

Return list of Installer plugin objects unique by name.

Load the Installer plugin descriptions from entry points, instantiating objects and ignoring duplicates (by Installer.get_name(), not entry point name).

Returns:list of the loaded plugin objects
Raises InvalidPluginError:
 if one of the loaded plugins is invalid
xylem.installers.impl.load_installer_plugin(entry_point)

Load Installer plugin from entry point.

Parameters:entry_point – entry point object from pkg_resources

xylem.installers.package_manager_installer module

class xylem.installers.package_manager_installer.PackageManagerInstaller(detect_fn, supports_depends=False)

Bases: xylem.installers.impl.Installer

Base class from a variety of package manager installers.

General form of a package manager Installer implementation that assumes:

  • installer rule-args spec is a list of package names stored with the key “packages”
  • a detect function exists that given a list of packages, returns a list of the installed packages

Also, if supports_depends is set to True:

  • installer rule-args spec can also include dependency specification with the key “depends”

Subclasses need to provide implementation of get_install_command.

In addition, if subclass provide their own resolve method, the resolved items need not be package names (i.e. strings). Methods other than get_isntall_command, resolve and the detect_fn treat the resolved items as opaque objects.

get_depends(rule_args)

Get list list of dependencies on other xylem keys.

Parameters:rule_args (dict) – argument dictionary to the xylem rule for this package manager
Returns:List of dependencies on other xylem keys read from the ‘depends’ key in rule_args if self.supports_depends is True.
get_packages_to_install(resolved, reinstall=False)
is_installed(resolved_item)
resolve(rules_args)

See Installer.resolve().

Module contents

class xylem.installers.InstallerContext(setup_installers=True, os_override=None)

Bases: builtins.object

InstallerContext manages the context of execution for xylem.

It combines OS plugins, installer plugins and user settings to manage the current OS, installers to be used including their priorities.

get_default_installer_name()

Get name of default installer for current os.

setup_installers() needs to be called beforehand.

get_installer(name)

Get installer object by name.

get_installer_names()

Get all configured installers for current os.

setup_installers() needs to be called beforehand.

get_installer_priority(name)

Get configured priority for specific installer and current os.

setup_installers() needs to be called beforehand.

get_os_string()

Get the OS name and version as ‘name:version’ string.

See get_os_tuple()

Return type:str
Raises UnsupportedOsError:
 if OS was not detected correctly
get_os_tuple()

Get the OS (name,version) tuple.

Return the OS name/version tuple to use for resolution and installation. This will be the detected OS name/version unless InstallerContext.set_os_override() has been called.

Returns:(os_name, os_version)
Return type:(str,str)
Raises UnsupportedOsError:
 if OS was not detected correctly
set_os_override(os_tuple)

Override the OS detector with os_name and os_version.

See InstallerContext.detect_os().

Parameters:os_name ((str,str)) – OS (name,version) tuple to use
Raises UnsupportedOsError:
 if os override was invalid
setup_installers()

For current os, setup configured installers.

Installers are set up with their priorities for the current os and based on user config, os plugins and installer plugins.

class xylem.installers.Installer

Bases: builtins.object

Installer class that custom installer plugins derive from.

The Installer API is designed around opaque resolved parameters. These parameters can be any type of sequence object, but they must obey set arithmetic. They should also implement __str__() methods so they can be pretty printed.

get_depends(rule_args)

Get list list of dependencies on other xylem keys.

Parameters:rule_args (dict) – argument dictionary to the xylem rule for this package manager
Returns:List of dependencies on other xylem keys. Only necessary if the package manager doesn’t handle dependencies.
Return type:list of str
get_install_command(resolved, interactive=True, reinstall=False)

Get command line invocations to install list of items.

Parameters:
  • resolved – [resolution]. List of opaque resolved installation items
  • interactive – If False, disable interactive prompts, e.g. pass through -y or equivalent to package manager.
  • reinstall – If True, install everything even if already installed
Returns:

List of commands, each command being a list of strings.

Return type:

[[str]]

static get_name()

Get the name of the installer this class implements.

This is the name that is referenced in the rules files, user configuration or OS plugins. There may only be one installer for a any given name at runtime, i.e. plugins defining installers with existing names might be ignored.

Return str:installer name
get_priority_for_os(os_name, os_version)

Get the priority of this installer according to installer plugin.

Given an OS name/version tuple, the installer can declare that it should be used on that OS with the returned priority. If the installer does not want to declare itself for this OS, None is returned.

Return type:number or None
is_installed(resolved_item)

Check if single opaque installation item is installed.

Parameters:resolved_item – single opaque resolved installation item
Returns:True if all of the resolved items are installed on the local system
resolve(rule_args)

Return list of resolutions from rules dictionary entry.

Parameters:rule_args (dict) – argument dictionary to the xylem rule for this package manager
Returns:[resolution]. Resolved objects should be printable to a user, but are otherwise opaque.