1
0
mirror of https://github.com/fedora-python/tox-current-env.git synced 2025-11-24 03:08:58 +01:00

Avoid exception with tox.ini containing allowlist_externals

Fixes: https://github.com/fedora-python/tox-current-env/issues/45

Co-Authored-By: Miro Hrončok <miro@hroncok.cz>
This commit is contained in:
Sorin Sbarnea
2021-12-14 08:39:46 +00:00
committed by Miro Hrončok
parent 931f41066b
commit 6e7459afce
2 changed files with 30 additions and 1 deletions

View File

@@ -54,6 +54,21 @@ def _plugin_active(option):
return option.current_env or option.print_deps_to or option.print_extras_to
def _allow_all_externals(envconfig):
for option in ["allowlist_externals", "whitelist_externals"]:
# If either is set, we change it, as we cannot have both set at the same time:
if getattr(envconfig, option, None):
setattr(envconfig, option, "*")
break
else:
# If none was set, we set one of them, preferably the new one:
if hasattr(envconfig, "allowlist_externals"):
envconfig.allowlist_externals = "*"
else:
# unless we need to fallback to the old and deprecated
# TODO, drop this when we drop support for tox < 3.18
envconfig.whitelist_externals = "*"
@tox.hookimpl
def tox_configure(config):
"""Stores options in the config. Makes all commands external and skips sdist"""
@@ -72,8 +87,8 @@ def tox_configure(config):
if _plugin_active(config.option):
config.skipsdist = True
for testenv in config.envconfigs:
config.envconfigs[testenv].whitelist_externals = "*"
config.envconfigs[testenv].usedevelop = False
_allow_all_externals(config.envconfigs[testenv])
if (getattr(config.option.print_deps_to, "name", object()) ==
getattr(config.option.print_extras_to, "name", object())):