Packaging provides a set of tools to deal with downloads and installation of distributions. Their role is to download the distribution from indexes, resolve the dependencies, and provide a safe way to install distributions. An operation that fails will cleanly roll back, not leave half-installed distributions on the system. Here’s the basic process followed:
This is a higher-level module built on packaging.database and packaging.pypi.
Return information about what’s going to be installed and upgraded. requirements is a string containing the requirements for this project, for example 'FooBar 1.1' or 'BarBaz (<1.2)'.
If you want to use another index than the main PyPI, give its URI as index argument.
installed is a list of already installed distributions used to find satisfied dependencies, obsoleted distributions and eventual conflicts.
By default, alpha, beta and candidate versions are not picked up. Set prefer_final to false to accept them too.
The results are returned in a dictionary containing all the information needed to perform installation of the requirements with the install_from_infos() function:
>>> get_install_info("FooBar (<=1.2)")
{'install': [<FooBar 1.1>], 'remove': [], 'conflict': []}
Safely install all distributions provided in dists into path. paths is a list of paths where already-installed distributions will be looked for to find satisfied dependencies and conflicts (default: sys.path). Returns a list of installed dists.
Safely install and remove given distributions. This function is designed to work with the return value of get_infos(): install, remove and conflicts should be list of distributions returned by get_infos(). If install is not empty, install_path must be given to specify the path where the distributions should be installed. paths is a list of paths where already-installed distributions will be looked for (default: sys.path).
This function is a very basic installer; if conflicts is not empty, the system will be in a conflicting state after the function completes. It is a building block for more sophisticated installers with conflict resolution systems.
Install a distribution from a source directory, which must contain either a Packaging-compliant setup.cfg file or a legacy Distutils setup.py script (in which case Distutils will be used under the hood to perform the installation).
Remove one distribution from the system.