base

Base classes for defining software dependencies for module types and routines for fetching them.

class SoftwareDependency(name, homepage_url=None, dependencies=None, license=None)[source]

Bases: object

Base class for all Pimlico module software dependencies.

Every dependency has a name and list of sub-dependencies.

A URL may be provided by the kwarg homepage_url. This will be used in documentation to link to the software’s homepage.

A license may also be specified, for inclusion in the documentation. It should be an instance of SoftwareLicense. See the literals in pimlico.core.dependences.licenses for many commonly used licenses.

available(local_config)[source]

Return True if the dependency is satisfied, meaning that the software/library is installed and ready to use.

problems(local_config)[source]

Returns a list of problems standing in the way of the dependency being available. If the list is empty, the dependency is taken to be installed and ready to use.

Overriding methods should call super method.

installable()[source]

Return True if it’s possible to install this library automatically. If False, the user will have to install it themselves. Instructions for doing this may be provided by installation_instructions(), which will only generally be called if installable() returns False.

This might be the case, for example, if the software is not available to download freely, or if it requires a system-wide installation.

installation_instructions()[source]

Where a dependency can’t be installed programmatically, we typically want to be able to output instructions for the user to tell them how to go about doing it themselves. Any subclass that doesn’t provide an automatic installation routine should override this to provide instructions.

You may also provide this even if the class does provide automatic installation. For example, you might want to provide instructions for other ways to install the software, like a system-wide install. This instructions will be shown together with missing dependency information.

installation_notes()[source]

If this returns a non-empty string, the message will be output together with the information that the dependency is not available, before the user is given the option of installing it automatically (or told that it can’t be). This is useful where information about a dependency should always be displayed, not just in cases where automatic installation isn’t possible.

For example, you might need to include warnings about potential installation difficulties, license information, sources of additional information about the software, and so on.

dependencies()[source]

Returns a list of instances of SoftwareDependency subclasses representing this library’s own dependencies. If the library is already available, these will never be consulted, but if it is to be installed, we will check first that all of these are available (and try to install them if not).

install(local_config, trust_downloaded_archives=False)[source]

Should be overridden by any subclasses whose library is automatically installable. Carries out the actual installation.

You may assume that all dependencies returned by :method:dependencies have been satisfied prior to calling this.

all_dependencies()[source]

Recursively fetch all dependencies of this dependency (not including itself).

get_installed_version(local_config)[source]

If available() returns True, this method should return a SoftwareVersion object (or subclass) representing the software’s version.

The base implementation returns an object representing an unknown version number.

If available() returns False, the behaviour is undefined and may raise an error.

class Any(name, dependency_options, *args, **kwargs)[source]

Bases: pimlico.core.dependencies.base.SoftwareDependency

A collection of dependency requirements of which at least one must be available. The first in the list that is installable is treated as the default and used for automatic installation.

available(local_config)[source]

Return True if the dependency is satisfied, meaning that the software/library is installed and ready to use.

problems(local_config)[source]

Returns a list of problems standing in the way of the dependency being available. If the list is empty, the dependency is taken to be installed and ready to use.

Overriding methods should call super method.

installable()[source]

Return True if it’s possible to install this library automatically. If False, the user will have to install it themselves. Instructions for doing this may be provided by installation_instructions(), which will only generally be called if installable() returns False.

This might be the case, for example, if the software is not available to download freely, or if it requires a system-wide installation.

get_installation_candidate()[source]

Returns the first dependency of the multiple possibilities that is automatically installable, or None if none of them are.

get_available_option(local_config)[source]

If one of the options is available, return that one. Otherwise return None.

dependencies()[source]

Returns a list of instances of SoftwareDependency subclasses representing this library’s own dependencies. If the library is already available, these will never be consulted, but if it is to be installed, we will check first that all of these are available (and try to install them if not).

install(local_config, trust_downloaded_archives=False)[source]

Installs the dependency given by get_installation_candidate(), if any. Ideally, we should provide a way to select which of the options should be installed. However, until we’ve worked out the best way to do this, the default option is always installed. The user may install another option manually and that will be used.

installation_notes()[source]

If this returns a non-empty string, the message will be output together with the information that the dependency is not available, before the user is given the option of installing it automatically (or told that it can’t be). This is useful where information about a dependency should always be displayed, not just in cases where automatic installation isn’t possible.

For example, you might need to include warnings about potential installation difficulties, license information, sources of additional information about the software, and so on.

class SystemCommandDependency(name, test_command, **kwargs)[source]

Bases: pimlico.core.dependencies.base.SoftwareDependency

Dependency that tests whether a command is available on the command line. Generally requires system-wide installation.

installable()[source]

Usually not automatically installable

problems(local_config)[source]

Returns a list of problems standing in the way of the dependency being available. If the list is empty, the dependency is taken to be installed and ready to use.

Overriding methods should call super method.

exception InstallationError[source]

Bases: Exception

check_and_install(deps, local_config, trust_downloaded_archives=False)[source]

Check whether dependencies are available and try to install those that aren’t. Returns a list of dependencies that can’t be installed.

install(dep, local_config, trust_downloaded_archives=False)[source]
install_dependencies(pipeline, modules=None, trust_downloaded_archives=True)[source]

Install depedencies for pipeline modules

Parameters:
  • pipeline
  • modules – list of module names, or None to install for all
Returns:

recursive_deps(dep)[source]

Collect all recursive dependencies of this dependency. Does a depth-first search so that everything comes later in the list than things it depends on.