Skip to content

Commit

Permalink
Fix fallback to python env with isolated_build
Browse files Browse the repository at this point in the history
Skip the section generated by ``isolated_build = true`` when collection all environments instead of removing the ``isolated_build_env`` afterwards.
  • Loading branch information
Unrud committed Aug 7, 2022
1 parent 82c26ed commit 1b304ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/changelog/2474.bugfix.rst
@@ -0,0 +1 @@
Fix fallback to ``python`` environment when ``isolated_build = true`` is set -- by :user:`Unrud`
14 changes: 7 additions & 7 deletions src/tox/config/__init__.py
Expand Up @@ -1484,7 +1484,7 @@ def make_envconfig(self, name, section, subs, config, replace=True):
reader.addsubstitutions(**{env_attr.name: res})
return tc

def _getallenvs(self, reader, extra_env_list=None):
def _getallenvs(self, reader, config, extra_env_list=None):
extra_env_list = extra_env_list or []
env_str = reader.getstring("envlist", replace=False)
env_list = _split_env(env_str)
Expand All @@ -1493,9 +1493,12 @@ def _getallenvs(self, reader, extra_env_list=None):
env_list.append(env)

all_envs = OrderedDict((i, None) for i in env_list)
package_env = config.isolated_build_env if config.isolated_build is True else None
for section in self._cfg:
if section.name.startswith(testenvprefix):
all_envs[section.name[len(testenvprefix) :]] = None
section_env = section.name[len(testenvprefix) :]
if section_env != package_env:
all_envs[section_env] = None
if not all_envs:
all_envs["python"] = None
return list(all_envs.keys())
Expand All @@ -1511,7 +1514,7 @@ def _getenvdata(self, reader, config):
(from_option and "ALL" in from_option)
or (not from_option and from_environ and "ALL" in from_environ.split(","))
) and PARALLEL_ENV_VAR_KEY_PRIVATE not in os.environ:
all_envs = self._getallenvs(reader)
all_envs = self._getallenvs(reader, config)
else:
candidates = (
(os.environ.get(PARALLEL_ENV_VAR_KEY_PRIVATE), True),
Expand All @@ -1522,7 +1525,7 @@ def _getenvdata(self, reader, config):
)
env_str, envlist_explicit = next(((i, e) for i, e in candidates if i), ([], False))
env_list = _split_env(env_str)
all_envs = self._getallenvs(reader, env_list)
all_envs = self._getallenvs(reader, config, env_list)

if not env_list:
env_list = all_envs
Expand All @@ -1533,9 +1536,6 @@ def _getenvdata(self, reader, config):
raise tox.exception.ConfigError(msg)

package_env = config.isolated_build_env
if config.isolated_build is True and package_env in all_envs:
all_envs.remove(package_env)

if config.isolated_build is True and package_env in env_list:
msg = "isolated_build_env {} cannot be part of envlist".format(package_env)
raise tox.exception.ConfigError(msg)
Expand Down

0 comments on commit 1b304ce

Please sign in to comment.