Managing Packages¶
Any configuration related to packages is done through the Packages object. Here is an example showing some common operations:
def main(build):
# it's possible to set the index urls that packages will be installed from:
build.packages.index_urls = ["http://www.mycompany.com/python_index"]
# this method installs the package "py.test" with version 2.7.0. It's
# available in the sandbox as soon as the package is installed.
build.packages.install("py.test", version="==2.7.0")
# if you want to a development / editable egg, you can use this function.
build.packages.install(".", develop=True)
# if you want to set a specific version of a package to download, you can do so with versions
build.packages.versions.update({
"requests": "==2.6.0"
})
# this takes effect on all subsequent installations. For example, it will be considered here:
build.packages.install("requests")
Full API Reference¶
-
class
uranium.packages.
Packages
(virtualenv_dir=None)[source]¶ this is the public API for downloading packages into an environment.
unless otherwise specified, all properties in this class are mutable: updating them will take immediate effect.
-
index_urls
¶ index urls is a list of the urls that Packages queries when looking for packages.
-
install
(name, version=None, develop=False, upgrade=False, install_options=None)[source]¶ install is used when installing a python package into the environment.
if version is set, the specified version of the package will be installed. The specified version should be a full PEP 440 version specifier (i.e. “==1.2.0”)
if develop is set to True, the package will be installed as editable: the source in the directory passed will be used when using that package.
if install_options is provided, it should be a list of options, like [“–prefix=/opt/srv”, “–install-lib=/opt/srv/lib”]
-
uninstall
(package_name)[source]¶ uninstall is used when uninstalling a python package from a environment.
-
versions
¶ versions is a dictionary object of <package_name, version_spec> pairs.
when a request is made to install a package, it will use the version specified in this dictionary.
- if the package installation specifies a version, it will override
the version specified here.
# this sets the version to be used in this dictionary to 0.2.3. packages.install("uranium", version="==0.2.3")
TODO: this will also contain entries to packages installed without a specified version. the version installed will be updated here.
-