asv.environment¶
Manages an environment – a combination of a version of Python and set of dependencies.
Attributes¶
Exceptions¶
Common base class for all exceptions |
Classes¶
Manage a single environment -- a combination of a particular |
|
Manage a single environment -- a combination of a particular |
Functions¶
|
Iterate through all combinations of the given requirement |
|
Parse 'matrix' and include/exclude rule configuration entries. |
|
Parse exclude/include rule by adding key types. |
|
Match rule to a target. |
|
Get a name to uniquely identify an environment. |
|
|
|
Iterator returning Environment objects for all of the |
|
Parse mixed requirement / environment variable matrix entries |
|
Get a matching environment type class. |
|
Find the environment class with the given name. |
|
Check if the list of environments only contains ExistingEnvironment |
Module Contents¶
- asv.environment.iter_matrix(environment_type, pythons, conf, explicit_selection=False)[source]¶
Iterate through all combinations of the given requirement matrix and python versions.
Yields¶
- combinationdict of {(key_type, key_name): value, …}
Combination of environment settings. Possible key types are (‘req’, ‘env’, ‘env_nobuild’, ‘python’).
- asv.environment._parse_matrix(matrix, bare_keys=())[source]¶
Parse ‘matrix’ and include/exclude rule configuration entries.
It is in format:
{"key_type1": {"key1": value1, "key2, value2, ...}, ..., "nondict_key1": nondict_value1, ...}
or in legacy format:
{"key1": value1, ..., "nondict_key1": nondict_value1, ...}
in which the key type is assumed to be “req”.
Parameters¶
- matrix
Configuration matrix or rule entry
- bare_keysiterable
Non-dictionary key values to store as is
Returns¶
- parsed_matrix
Dictionary {(key_type, key): value, …}
- asv.environment._parse_exclude_include_rule(rule, is_include=False)[source]¶
Parse exclude/include rule by adding key types.
Parameters¶
- ruledict
Keys must be str, values must be str or None. The keys ‘python’, ‘environment_type’, ‘sys_platform’, are parsed specially and result to the corresponding key types.
Returns¶
- ruledict
Dictionary of {(key_type, key): value, …}
- asv.environment.match_rule(target, rule)[source]¶
Match rule to a target.
Parameters¶
- targetdict
Dictionary containing [((key_type, key), value), …].
- ruledict
Dictionary containing [((key_type, key), match), …], to be matched to target. Match can be str specifying a regexp that must match target[key], or None. None matches either None or a missing key in target. If match is not None, and the key is missing in target, the rule does not match. The key_type must match exactly.
Returns¶
- matchedbool
Whether the rule matched. The rule matches if all keys match.
- asv.environment.get_env_name(tool_name, python, requirements, tagged_env_vars, build=False)[source]¶
Get a name to uniquely identify an environment.
Parameters¶
- buildbool
Whether to omit non-build environment variables. The canonical name of the environment is the name with build=False.
- asv.environment.get_environments(conf, env_specifiers, verbose=True)[source]¶
Iterator returning Environment objects for all of the permutations of the given versions of Python and a matrix of requirements.
Parameters¶
- confdict
asv configuration object
- env_specifierslist of str
List of environment specifiers, in the format ‘env_name:python_spec’. If env_name is empty, autodetect it. If python_spec is missing, use those listed in the configuration file. Alternatively, can be the name given by Environment.name if the environment is in the matrix.
- verbosebool, optional
Whether to display warnings about unknown environment types etc.
- asv.environment._parse_matrix_entries(entries)[source]¶
Parse mixed requirement / environment variable matrix entries to requirements and tagged environment variables.
- asv.environment.get_environment_class(conf, python)[source]¶
Get a matching environment type class.
Parameters¶
- confdict
asv configuration object
- pythonstr
Python version specifier. Acceptable values depend on the Environment plugins installed but generally are:
‘X.Y’: A Python version, in which case conda or virtualenv will be used to create a new environment.
‘python’ or ‘/usr/bin/python’: Search for the given executable on the search PATH, and use that. It is assumed that all dependencies and the benchmarked project itself are already installed.
- asv.environment.get_environment_class_by_name(environment_type)[source]¶
Find the environment class with the given name.
- asv.environment.is_existing_only(environments)[source]¶
Check if the list of environments only contains ExistingEnvironment
Common base class for all exceptions
- class asv.environment.Environment(conf, python, requirements, tagged_env_vars)[source]¶
Manage a single environment – a combination of a particular version of Python and a set of dependencies for the benchmarked project.
- classmethod matches(python)[source]¶
Returns True if this environment subclass can handle the given Python specifier.
- property dir_name[source]¶
Get the name of the directory where the environment resides. This is not necessarily unique, and may be shared across different environments.
- create()[source]¶
Create the environment on disk. If it doesn’t exist, it is created. Then, all of the requirements are installed into it.
- abstract run(args, **kwargs)[source]¶
Start up the environment’s python executable with the given args.
- _interpolate_commands(commands)[source]¶
Parse a command list with interpolated variables to a sequence of commands.
Parameters¶
- commands{list of str}
Commands to execute
Returns¶
- run_commandslist of (cmd, env, return_codes, cwd)
Parsed commands to run.
- checkout_project(repo, commit_hash)[source]¶
Check out the working tree of the project at given commit hash
- install_project(conf, repo, commit_hash)[source]¶
Build and install the benchmarked project into the environment. Uninstalls any installed copy of the project first.
- can_install_project()[source]¶
Return True if specific revisions of the benchmarked project can be installed into this environment.
- find_executable(executable)[source]¶
Find an executable (eg. python, pip) in the environment.
If not found, raises OSError
- class asv.environment.ExistingEnvironment(conf, executable, requirements, tagged_env_vars)[source]¶
Manage a single environment – a combination of a particular version of Python and a set of dependencies for the benchmarked project.
- classmethod matches(python)[source]¶
Returns True if this environment subclass can handle the given Python specifier.
- create()[source]¶
Create the environment on disk. If it doesn’t exist, it is created. Then, all of the requirements are installed into it.
- install_project(conf, repo, commit_hash=None)[source]¶
Build and install the benchmarked project into the environment. Uninstalls any installed copy of the project first.