rez.package_py_utils
This sourcefile is intended to be imported in package.py files, in functions including:
the special ‘preprocess’ function;
early bound functions that use the @early decorator.
- rez.package_py_utils.exec_command(attr, cmd)[source]
Runs a subproc to calculate a package attribute.
- rez.package_py_utils.exec_python(attr, src, executable='python')[source]
Runs a python subproc to calculate a package attribute.
- rez.package_py_utils.expand_requirement(request, paths=None)[source]
Expands a requirement string like ‘python-2.*’, ‘foo-2.*+<*’, etc.
Wildcards are expanded to the latest version that matches. There is also a special wildcard ‘**’ that will expand to the full version, but it cannot be used in combination with ‘*’.
Wildcards MUST placehold a whole version token, not partial - while ‘foo-2.*’ is valid, ‘foo-2.v*’ is not.
Wildcards MUST appear at the end of version numbers - while ‘foo-1.*.*’ is valid, ‘foo-1.*.0’ is not.
It is possible that an expansion will result in an invalid request string (such as ‘foo-2+<2’). The appropriate exception will be raised if this happens.
Examples
>>> print(expand_requirement('python-2.*')) python-2.7 >>> print(expand_requirement('python==2.**')) python==2.7.12 >>> print(expand_requirement('python<**')) python<3.0.5
- rez.package_py_utils.expand_requires(*requests)[source]
Create an expanded requirements list.
Example
>>> print(expand_requires(["boost-1.*.*"])) ["boost-1.55.0"] >>> print(expand_requires(["boost-1.*"])) ["boost-1.55"]
- Parameters
requests (list of str) – Requirements to expand. Each value may have trailing wildcards.
- Returns
Expanded requirements.
- Return type
List of str
- rez.package_py_utils.find_site_python(module_name, paths=None)[source]
Find the rez native python package that contains the given module.
This function is used by python ‘native’ rez installers to find the native rez python package that represents the python installation that this module is installed into.
Note
This function is dependent on the behavior found in the python ‘_native’ package found in the ‘rez-recipes’ repository. Specifically, it expects to find a python package with a ‘_site_paths’ list attribute listing the site directories associated with the python installation.
- Parameters
module_name (str) – Target python module.
paths (list of str, optional) – paths to search for packages, defaults to config.packages_path.
- Returns
Native python package containing the named module.
- Return type
Package