cmaize.package_managers/pip/pip

class cmaize.package_managers/pip/pip.PipPackageManager

Bases: PackageManager

Class exposing Python’s PipPackageManager package manager to CMaize.

This class holds a Python interpreter and leverages the pip installation associated with the interpreter to locate and install pip packages.

Additional Constructors

CTOR(_py_exe)

Constructs a pip package manager based on the provided Python interpreter

The PipPackageManager class works by system calling a Python interpreter. When creating a PipPackageManager object the user is responsible for ensuring that the Python interpreter used at creation is indeed the Python interpreter that should be used for installing packages.

Parameters:
  • self (PipPackageManager*) – The variable to assign the new object to.

  • _py_exe (path) – The path to the Python interpreter.

Methods

find_installed(_fi_result, _fi_package_specs[, ...])

Determines if self has already installed a package.

This method will call pip list and case-insensitively grep the result for the requested package. If the package is found an imported interface target will be created with the provided name. Otherwise, the function returns an empty string.

Parameters:
  • self (PipPackageManager) – The pip package manager to check for the package.

  • result (desc) – A variable to hold the result of the invocation.

  • package_specs (PackageSpecification) – The details pertaining to what package pip should try to find.

  • _fi_result (desc)

  • _fi_package_specs (PackageSpecification)

Returns:

An empty string if package_specs is not already installed, otherwise a target representing the package.

Return type:

string or InstalledTarget

get_package(_gp_result, _gp_package_specs[, ...])

Retrieves an already installed package.

This method is a convenience function for calling find_installed and asserting that the result is not an empty string.

Parameters:
  • self (PipPackageManager) – The pip package manager to check for the pacakge.

  • result (InstalledTarget*) – A variable to hold the resulting target

  • package_specs (PackageSpecification.) – The details of the package we are looking for.

  • _gp_result (str)

  • _gp_package_specs (PackageSpecification)

Returns:

A target detailing the found package.

Return type:

InstalledTarget

Raises:

PACKAGE_NOT_FOUND – When package_specs is not already installed.

install_package(_ip_package_specs[, ...])

Installs the specified package.

This method is used to have the package manager install a package. At the moment, the installation happens at configuration time.

Parameters:

Attributes

python_executable
Type:

path

The Python executable to use for running pip commands. pip invocations will look like self.python_executable -m pip <command>

cmaize.package_managers/pip/pip.enable_pip_package_manager()

Enables and registers a pip package manager with the global environment.

The pip package manager is only registered if “pip” has not already been added to the CMAIZE_SUPPORTED_PACKAGE_MANAGERS global variable.

Note

Enabling the pip package manager adds Python as a dependency of CMaize.