pimlico.core.dependencies.base module

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

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

Bases: object

Base class for all Pimlico module software dependencies.

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.

dependencies()[source]

Returns a list of instances of :class:SoftwareDependency subcalsses 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 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: exceptions.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.