diff options
Diffstat (limited to 'tox/config.py')
-rw-r--r-- | tox/config.py | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/tox/config.py b/tox/config.py index 640e21d..40c6e0a 100644 --- a/tox/config.py +++ b/tox/config.py @@ -141,7 +141,11 @@ class DepOption: same package, even if versions differ. """ dep1_name = pkg_resources.Requirement.parse(dep1).project_name - dep2_name = pkg_resources.Requirement.parse(dep2).project_name + try: + dep2_name = pkg_resources.Requirement.parse(dep2).project_name + except pkg_resources.RequirementParseError: + # we couldn't parse a version, probably a URL + return False return dep1_name == dep2_name @@ -320,6 +324,18 @@ def tox_addoption(parser): help="additional arguments available to command positional substitution") # add various core venv interpreter attributes + def basepython_default(testenv_config, value): + if value is None: + for f in testenv_config.factors: + if f in default_factors: + return default_factors[f] + return sys.executable + return str(value) + + parser.add_testenv_attribute( + name="basepython", type="string", default=None, postprocess=basepython_default, + help="executable name or path of interpreter used to create a " + "virtual test environment.") parser.add_testenv_attribute( name="envdir", type="path", default="{toxworkdir}/{envname}", @@ -453,19 +469,6 @@ def tox_addoption(parser): name="usedevelop", type="bool", postprocess=develop, default=False, help="install package in develop/editable mode") - def basepython_default(testenv_config, value): - if value is None: - for f in testenv_config.factors: - if f in default_factors: - return default_factors[f] - return sys.executable - return str(value) - - parser.add_testenv_attribute( - name="basepython", type="string", default=None, postprocess=basepython_default, - help="executable name or path of interpreter used to create a " - "virtual test environment.") - parser.add_testenv_attribute_obj(InstallcmdOption()) parser.add_testenv_attribute_obj(DepOption()) @@ -714,7 +717,7 @@ class parseini: if atype == "path": reader.addsubstitutions(**{env_attr.name: res}) - if env_attr.name == "install_command": + if env_attr.name == "envdir": reader.addsubstitutions(envbindir=vc.envbindir, envpython=vc.envpython, envsitepackagesdir=vc.envsitepackagesdir) return vc @@ -908,6 +911,7 @@ class SectionReader: return '\n'.join(filter(None, map(factor_line, lines))) def _replace_env(self, match): + env_list = self.getdict('setenv') match_value = match.group('substitution_value') if not match_value: raise tox.exception.ConfigError( @@ -922,11 +926,14 @@ class SectionReader: envkey = match_value if envkey not in os.environ and default is None: - raise tox.exception.ConfigError( - "substitution env:%r: unknown environment variable %r" % - (envkey, envkey)) - - return os.environ.get(envkey, default) + if envkey not in env_list and default is None: + raise tox.exception.ConfigError( + "substitution env:%r: unknown environment variable %r" % + (envkey, envkey)) + if envkey in os.environ: + return os.environ.get(envkey, default) + else: + return env_list.get(envkey, default) def _substitute_from_other_section(self, key): if key.startswith("[") and "]" in key: |