qip.package¶
-
qip.package.GIT_PATTERN= <_sre.SRE_Pattern object>¶ Compiled regular expression to detect git input.
-
qip.package.EXTRA_REQUEST_PATTERN= <_sre.SRE_Pattern object>¶ Compiled regular expression to detect request with extra option.
-
qip.package.PACKAGE_INFO_SCRIPT= '/home/docs/checkouts/readthedocs.org/user_builds/qip/envs/latest/lib/python2.7/site-packages/qip/package_data/package_info.py'¶ Path to the Python package info script.
-
qip.package.install(request, path, context_mapping, cache_path, editable_mode=False)[source]¶ Install package in path from request.
Parameters: - request –
package to be installed. A request can be one of:
"/path/to/foo/" "." "foo" "foo==0.1.0" "foo >= 7, < 8" "git@gitlab:rnd/foo.git" "git@gitlab:rnd/foo.git@0.1.0" "git@gitlab:rnd/foo.git@dev"
- path – path to install Python packages to.
- context_mapping – contain environment mapping and python mapping, as
returned from
qip.fetch_context_mapping(). - cache_path – Temporary directory for the pip cache.
- editable_mode – install in editable mode. Default is False.
Raises: - RuntimeError – if Pip fails to install Python package.
- ValueError – if the Python package name can not be extracted from request.
Returns: mapping with information about the package gathered from the environment. It should be in the form of:
{ "identifier": "Foo-0.1.0", "request": "foo >= 0.1.0, < 1", "extra": [], "name": "Foo", "key": "foo", "version": "0.1.0", "description": "This is a Python package", "location": "/path/to/source", "target": "Foo/Foo-0.1.0-py27-centos7", "python": { "identifier": "2.7", "request": "python >= 2.7, < 2.8", "library-path": "lib/python2.8/site-packages" }, "system": { "platform": "linux", "arch": "x86_64", "os": { "name": "centos", "major_version": 7 } }, "requirements": [ "bim<3,>=2" ] }
- request –
-
qip.package.fetch_mapping_from_environ(name, context_mapping, extra_keywords=None)[source]¶ Return a mapping with information about the Python package name.
Parameters: - name – Python package name.
- context_mapping – contain environment mapping and python mapping, as
returned from
qip.fetch_context_mapping(). - extra_keywords – List of extra requirement keywords if required. Default is None.
Returns: mapping with information about the package gathered from the environment. It should be in the form of:
{ "identifier": "Foo-0.1.0", "name": "Foo", "key": "foo", "version": "0.1.0", "description": "This is a Python package", "location": "/path/to/source", "target": "Foo/Foo-0.1.0-py27-centos7", "python": { "identifier": "2.7", "request": "python >= 2.7, < 2.8", "library-path": "lib/python2.8/site-packages" }, "system": { "platform": "linux", "arch": "x86_64", "os": { "name": "centos", "major_version": 7 } }, "requirements": [ "bim<3,>=2" ] }
-
qip.package.extract_dependency_mapping(name, environ_mapping, extra_keywords=None)[source]¶ Return mapping for Python package with all dependency requirements.
Parameters: - name – Python package name.
- environ_mapping – mapping of environment variables.
- extra_keywords – List of extra requirement keywords if required. Default is None.
Returns: None if the package name cannot be found in dependency mapping, otherwise return dependency mapping. A valid mapping should be in the form of:
{ "package": { "key": "foo", "package_name": "Foo", "module_name": "foo" "installed_version": "0.1.0", }, "requirements": [ "bim<3,>=2" ] }
-
qip.package.extract_identifier(mapping, extra_keywords=None)[source]¶ Return corresponding identifier from package mapping.
Parameters: - mapping –
package mapping. The package mapping must be in the form of:
{ "key": "foo", "package_name": "Foo", "installed_version": "1.11", }
- extra_keywords – List of extra requirement keywords if required. Default is None.
Returns: Corresponding identifier (e.g. “Foo-1.11”, “Bar”).
- mapping –
-
qip.package.extract_key(mapping, extra_keywords=None)[source]¶ Compute key for package mapping.
Parameters: - mapping –
package mapping. The package mapping must be in the form of:
{ "key": "foo", "package_name": "Foo", "installed_version": "1.11", }
- extra_keywords – List of extra requirement keywords if required. Default is None.
Returns: Corresponding key (e.g. “foo”, “foo-test”).
- mapping –
-
qip.package.is_system_required(metadata)[source]¶ Indicate whether package is platform-specific from metadata.
Package classifiers are retrieved from metadata to indicate if a specific operating system is required.
Parameters: metadata – string resulting from the pip show -v command. Returns: Boolean value.
-
qip.package.extract_command_mapping(metadata, extra_keywords=None)[source]¶ Extract command mapping from entry points within metadata.
Package Entry-Points are retrieved from metadata to extract the corresponding commands. Each function defined as
console_scriptswill be used to create associated command.Provided extra_keywords are used when commands depend on optional dependencies.
Parameters: - metadata –
string resulting from the pip show -v command.
- extra_keywords – List of extra requirement keywords if required. Default is None.
Returns: command mapping
It should be in the form of:
{ "foo": "python -m foo", "bar": "python -m bar.test" }
- metadata –
-
qip.package.extract_target_path(name, identifier, python_version, os_mapping=None)[source]¶ Return the corresponding target path from package mapping.
Parameters: - name – Python package name.
- identifier – Python package identifier.
- python_version – Python version identifier (e.g. “2.7”).
- os_mapping –
None or a mapping describing the operating system. Default is None.
It should be in the form of:
{ "name": "centos", "major_version": 7 }
Returns: Corresponding path (e.g. “Foo/Foo-1.11-py27-centos7”).