Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken/incompatible --skip-missing-interpreters false behavior since 4.1.2 #2811

Closed
scop opened this issue Jan 3, 2023 · 6 comments · Fixed by #2828
Closed

Broken/incompatible --skip-missing-interpreters false behavior since 4.1.2 #2811

scop opened this issue Jan 3, 2023 · 6 comments · Fixed by #2828
Labels
bug:normal affects many people or has quite an impact help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.

Comments

@scop
Copy link
Contributor

scop commented Jan 3, 2023

Issue

Since tox 4.1.2, tox --skip-missing-interpreters false -e someenv seems to want interpreters present also for envs that are not invoked.

Up to 4.1.1, since from I don't remember when (3.x a long time ago), this used to work the way I'd assume: fail on missing interpreters only for environments that are actually going to be used. 4.1.2..4.1.3 have the problem.

Environment

Provide at least:

  • OS: Linux
  • pip list of the host Python where tox is installed:
Package                Version
---------------------- -------
astroid                2.12.12
attrs                  22.1.0
bandit                 1.7.4
black                  22.6.0
cachetools             5.2.0
cfgv                   3.3.1
chardet                5.1.0
click                  8.1.3
colorama               0.4.6
coverage               6.5.0
dill                   0.3.6
distlib                0.3.6
exceptiongroup         1.0.1
filelock               3.9.0
flake8                 6.0.0
flake8-bandit          4.1.1
flake8-bugbear         22.8.23
flake8-docstrings      1.6.0
flake8-noqa            1.3.0
gitdb                  4.0.9
GitPython              3.1.29
identify               2.5.8
iniconfig              1.1.1
isort                  5.9.3
jedi                   0.17.2
lazy-object-proxy      1.8.0
mccabe                 0.7.0
mypy                   0.990
mypy-extensions        0.4.3
nodeenv                1.7.0
packaging              22.0
parso                  0.7.1
pathspec               0.10.1
pbr                    5.11.0
pip                    22.2.2
platformdirs           2.6.2
pluggy                 1.0.0
pre-commit             2.21.0
py                     1.11.0
pycodestyle            2.10.0
pydocstyle             6.1.1
pyflakes               3.0.1
pylint                 2.15.5
pyparsing              3.0.9
pyproject_api          1.3.0
pytest                 7.2.0
pytest-cov             4.0.0
python-jsonrpc-server  0.4.0
python-language-server 0.36.2
pyupgrade              3.2.2
PyYAML                 6.0
setuptools             65.6.3
six                    1.16.0
smmap                  5.0.0
snowballstemmer        2.2.0
stevedore              4.1.1
tokenize-rt            5.0.0
toml                   0.10.2
tomli                  2.0.1
tomlkit                0.11.6
tox                    4.1.2
typing_extensions      4.4.0
ujson                  5.5.0
virtualenv             20.17.1
wrapt                  1.14.1

Output of running tox

Provide the output of tox -rvv:

(please note the actual invoked command has additionally --skip-missing-interpreters false -e py310)

$ tox -rvv --skip-missing-interpreters false -e py310
[...]
Traceback (most recent call last):
  File ".../bin/tox", line 8, in <module>
    sys.exit(run())
  File ".../lib/python3.10/site-packages/tox/run.py", line 19, in run
    result = main(sys.argv[1:] if args is None else args)
  File ".../lib/python3.10/site-packages/tox/run.py", line 45, in main
    result = handler(state)
  File ".../lib/python3.10/site-packages/tox/session/cmd/legacy.py", line 111, in legacy
    return run_sequential(state)
  File ".../lib/python3.10/site-packages/tox/session/cmd/run/sequential.py", line 22, in run_sequential
    return execute(state, max_workers=1, has_spinner=False, live=True)
  File ".../lib/python3.10/site-packages/tox/session/cmd/run/common.py", line 213, in execute
    state.envs.ensure_only_run_env_is_active()
  File ".../lib/python3.10/site-packages/tox/session/env_select.py", line 365, in ensure_only_run_env_is_active
    envs, active = self._defined_envs, self._env_name_to_active()
  File ".../lib/python3.10/site-packages/tox/session/env_select.py", line 225, in _defined_envs
    raise failed[next(iter(failed_to_create))]
  File ".../lib/python3.10/site-packages/tox/session/env_select.py", line 202, in _defined_envs
    run_env.package_env = self._build_pkg_env(pkg_name_type, name, env_name_to_active)
  File ".../lib/python3.10/site-packages/tox/session/env_select.py", line 270, in _build_pkg_env
    name_type = next(child_package_envs)
  File ".../lib/python3.10/site-packages/tox/tox_env/python/virtual_env/package/pyproject.py", line 141, in register_run_env
    yield from super().register_run_env(run_env)
  File ".../lib/python3.10/site-packages/tox/tox_env/python/package.py", line 101, in register_run_env
    pkg_env = run_env.conf["wheel_build_env"]
  File ".../lib/python3.10/site-packages/tox/config/sets.py", line 114, in __getitem__
    return self.load(item)
  File ".../lib/python3.10/site-packages/tox/config/sets.py", line 125, in load
    return config_definition.__call__(self._conf, self.loaders, ConfigLoadArgs(chain, self.name, self.env_name))
  File ".../lib/python3.10/site-packages/tox/config/of_type.py", line 110, in __call__
    value = self.default(conf, args.env_name) if callable(self.default) else self.default
  File ".../lib/python3.10/site-packages/tox/tox_env/python/package.py", line 81, in default_wheel_tag
    run_py = cast(Python, run_env).base_python
  File ".../lib/python3.10/site-packages/tox/tox_env/python/api.py", line 240, in base_python
    raise NoInterpreter(base_pythons)
tox.tox_env.python.api.NoInterpreter: could not find python interpreter matching any of the specs py33

Minimal example

If possible, provide a minimal reproducer for the issue:

tox.ini producing the above:

[tox]
envlist = py33, py310

[testenv]
usedevelop = true
@gaborbernat
Copy link
Member

@q0w this could be a bug with #2793

@q0w
Copy link
Contributor

q0w commented Jan 3, 2023

I'll try to fix

@gaborbernat gaborbernat added bug:normal affects many people or has quite an impact help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted. labels Jan 3, 2023
@q0w
Copy link
Contributor

q0w commented Jan 3, 2023

why with use_develop tox ignores raise Skip exceptions and continues the execution?
upd: because it's handled in _build_pkg_env

@q0w
Copy link
Contributor

q0w commented Jan 4, 2023

I tested with tox<4.1.2 and with use_develop it continues the execution and then fails with:

...
AttributeError: 'NoneType' object has no attribute 'version_info'
  py33: FAIL code 2 (0.00 seconds)
  evaluation failed :( (0.24 seconds)

Something is wrong with an editable installation

@scop
Copy link
Contributor Author

scop commented Jan 4, 2023

Yes, that seems to be another bug, it apparently throws that for interpreters that are not present. But I thought I'd try to keep the report in scope and have just one thing in it.

openstack-mirroring pushed a commit to openstack/openstack that referenced this issue Jan 4, 2023
* Update swift from branch 'master'
  to f77172e2ad6fef4b226637b8ae099a6faf810978
  - CI: pin tox at the project level
    
    No sooner do we fix the gate than tox has a new release that breaks
    it again. Let's give them a bit to settle down; in the mean time, stick
    with 3.x.
    
    See tox-dev/tox#2811
    
    Also simplify our warning suppressions. The message filter is a regex,
    so any prefix of the message will suffice. This allows us to also drop a
    new message seen on CentOS 8:
    
       CryptographyDeprecationWarning: Python 3.6 is no longer
       supported by the Python core team. Therefore, support for
       it is deprecated in cryptography. The next release of
       cryptography (40.0) will be the last to support Python 3.6.
    
    As we've previously seen with cryptography warnings, this can slow down
    our probe tests to the point that they time out.
    
    Change-Id: I316170442c67c1b4a5b87f9a1168cc04ca2417b8
openstack-mirroring pushed a commit to openstack/swift that referenced this issue Jan 4, 2023
No sooner do we fix the gate than tox has a new release that breaks
it again. Let's give them a bit to settle down; in the mean time, stick
with 3.x.

See tox-dev/tox#2811

Also simplify our warning suppressions. The message filter is a regex,
so any prefix of the message will suffice. This allows us to also drop a
new message seen on CentOS 8:

   CryptographyDeprecationWarning: Python 3.6 is no longer
   supported by the Python core team. Therefore, support for
   it is deprecated in cryptography. The next release of
   cryptography (40.0) will be the last to support Python 3.6.

As we've previously seen with cryptography warnings, this can slow down
our probe tests to the point that they time out.

Change-Id: I316170442c67c1b4a5b87f9a1168cc04ca2417b8
@q0w
Copy link
Contributor

q0w commented Jan 5, 2023

Patching like this would fix the problem with use_develop

     def child_pkg_envs(self, run_conf: EnvConfigSet) -> Iterator[PackageToxEnv]:
-        if run_conf["package"] == "wheel":
+        if run_conf["package"] in {"wheel", "editable"}:
             env = self._wheel_build_envs.get(run_conf["wheel_build_env"])
             if env is not None and env.name != self.name:
                 yield env

but tox would fail with default wheel_build_env cause NoInterpreterFound/Skip are not handled here

stephenfin added a commit to stephenfin/tox that referenced this issue Jan 6, 2023
We now separate environments into either run or packaging environments
[1]. As noted in 'tox.session.env_select.EnvSelector._defined_envs' [2],
the name of the environment is not enough to determine what type of
environment it is and we must actually build the environment and inspect
it. This allows us to prevent users *running* these packaging
environments (e.g. 'tox -e .pkg'). Part of this process of building an
environment is validating the base python. If this validation fails
(i.e. the Python version does not exist), we will raise
'tox.tox_env.python.api.NoInterpreter'. We were not handling this
exception, and thus the process of determining the types of each
environment would cause a failure if any environment requested a Python
version we did not support, even if we weren't actually trying to run
this environment.

The fix for this is simple: handle the exception and simply ignore these
unsupported environments.

While we're here, fix some issues with an existing test that were
noticed while adding new tests.

[1] https://tox.wiki/en/latest/upgrading.html#packaging-configuration-and-inheritance
[2] https://github.com/tox-dev/tox/blob/af35384bb2ee/src/tox/session/env_select.py#L173

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: tox-dev#2811
stephenfin added a commit to stephenfin/tox that referenced this issue Jan 6, 2023
We now separate environments into either run or packaging environments
[1]. As noted in 'tox.session.env_select.EnvSelector._defined_envs' [2],
the name of the environment is not enough to determine what type of
environment it is and we must actually build the environment and inspect
it. This allows us to prevent users *running* these packaging
environments (e.g. 'tox -e .pkg'). Part of this process of building an
environment is validating the base python. If this validation fails
(i.e. the Python version does not exist), we will raise
'tox.tox_env.python.api.NoInterpreter'. We were not handling this
exception, and thus the process of determining the types of each
environment would cause a failure if any environment requested a Python
version we did not support, even if we weren't actually trying to run
this environment.

The fix for this is simple: handle the exception and simply ignore these
unsupported environments.

While we're here, fix some issues with an existing test that were
noticed while adding new tests.

[1] https://tox.wiki/en/latest/upgrading.html#packaging-configuration-and-inheritance
[2] https://github.com/tox-dev/tox/blob/af35384bb2ee/src/tox/session/env_select.py#L173

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: tox-dev#2811
openstack-mirroring pushed a commit to openstack/openstack that referenced this issue Jan 6, 2023
* Update neutron from branch 'master'
  to d59bf5ff6c75c9f32129cd4ee49c2acb23e8bb9c
  - Temporary update envlist for tox4
    
    tox4 even when running specific env with -e option tries
    to find python version for all envs defined in envlist[1]
    when running with --skip-missing-interpreters=false and
    fails if interpreter missing for any of the env.
    
    With py38 in envlist it tries to find python3.8
    which is not available in ubuntu-jammy by default
    and fails, hence use generic version instead i.e py3
    to handle it.
    
    Once [1] is fixed we can update the list as per
    default supported py3 version for a release.
    
    [1] tox-dev/tox#2811
    
    Change-Id: I3afc539c59f223338920d7fd59f0df76e842ece1
openstack-mirroring pushed a commit to openstack/neutron that referenced this issue Jan 6, 2023
tox4 even when running specific env with -e option tries
to find python version for all envs defined in envlist[1]
when running with --skip-missing-interpreters=false and
fails if interpreter missing for any of the env.

With py38 in envlist it tries to find python3.8
which is not available in ubuntu-jammy by default
and fails, hence use generic version instead i.e py3
to handle it.

Once [1] is fixed we can update the list as per
default supported py3 version for a release.

[1] tox-dev/tox#2811

Change-Id: I3afc539c59f223338920d7fd59f0df76e842ece1
openstack-mirroring pushed a commit to openstack/pbr that referenced this issue Jan 6, 2023
Resolve the following warnings:

  tox.tox_env.errors.Fail: pass_env values cannot contain whitespace,
  use comma to have multiple values in a single line, invalid values
  found 'PBR_INTEGRATION PIPFLAGS PIPVERSION PBRVERSION REPODIR
  WHEELHOUSE PROJECTS'

Also, reduce down the envlist as tox 4 when run in OpenStack CI is
also attempting to validate interpreters utilizing the
--skip-missing-interpreters=false setting [1].

Finally, fix up the integration job so that it passes on Ubuntu 22.04.
This necessitates removing any Python 2-based dependencies used in the
these jobs (since these are no longer available on Ubuntu 22.04) and
removing tests for pip versions that are not compatible with Python 3.10
(the Python version found on Ubuntu 22.04).

[1] tox-dev/tox#2811

Change-Id: Ib4dbe4e09e269219c08a87f6fb64ad9628b5864a
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
openstack-mirroring pushed a commit to openstack/openstack that referenced this issue Jan 6, 2023
* Update pbr from branch 'master'
  to 491ce1ab095b122b442de1ce662ebc2e29d27de3
  - Update tox.ini to work with tox 4
    
    Resolve the following warnings:
    
      tox.tox_env.errors.Fail: pass_env values cannot contain whitespace,
      use comma to have multiple values in a single line, invalid values
      found 'PBR_INTEGRATION PIPFLAGS PIPVERSION PBRVERSION REPODIR
      WHEELHOUSE PROJECTS'
    
    Also, reduce down the envlist as tox 4 when run in OpenStack CI is
    also attempting to validate interpreters utilizing the
    --skip-missing-interpreters=false setting [1].
    
    Finally, fix up the integration job so that it passes on Ubuntu 22.04.
    This necessitates removing any Python 2-based dependencies used in the
    these jobs (since these are no longer available on Ubuntu 22.04) and
    removing tests for pip versions that are not compatible with Python 3.10
    (the Python version found on Ubuntu 22.04).
    
    [1] tox-dev/tox#2811
    
    Change-Id: Ib4dbe4e09e269219c08a87f6fb64ad9628b5864a
    Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
openstack-mirroring pushed a commit to openstack/openstack that referenced this issue Jan 16, 2023
* Update neutron-lib from branch 'master'
  to 2ce390093be7bb722feddc81a770d878ede15dfd
  - Merge "Update envlist for tox4"
  - Update envlist for tox4
    
    tox4 even when running specific env with -e option tries
    to find python version for all envs defined in envlist[1]
    when running with --skip-missing-interpreters=false and
    fails if interpreter missing for any of the env.
    
    With py38 in envlist it tries to find python3.8
    which is not available in ubuntu-jammy by default
    and fails, hence use generic version instead i.e py3
    to handle it.
    
    Even though [1] is fixed we are still seeing this failure.
    
    [1] tox-dev/tox#2811
    
    Also updated basepython to use TOX_PYTHON if set.
    
    Change-Id: I18765db9682fced05e8441a1e2122f9f814cd31b
openstack-mirroring pushed a commit to openstack/neutron-lib that referenced this issue Jan 16, 2023
tox4 even when running specific env with -e option tries
to find python version for all envs defined in envlist[1]
when running with --skip-missing-interpreters=false and
fails if interpreter missing for any of the env.

With py38 in envlist it tries to find python3.8
which is not available in ubuntu-jammy by default
and fails, hence use generic version instead i.e py3
to handle it.

Even though [1] is fixed we are still seeing this failure.

[1] tox-dev/tox#2811

Also updated basepython to use TOX_PYTHON if set.

Change-Id: I18765db9682fced05e8441a1e2122f9f814cd31b
openstack-mirroring pushed a commit to openstack/neutron-specs that referenced this issue Jan 17, 2023
tox4 even when running specific env with -e option tries
to find python version for all envs defined in envlist[1]
when running with --skip-missing-interpreters=false and
fails if interpreter missing for any of the env.

With py38 in envlist it tries to find python3.8
which is not available in ubuntu-jammy by default
and fails, hence use generic version instead i.e py3
to handle it.

Even though [1] is fixed we are still seeing this failure.

[1] tox-dev/tox#2811

Also had to add "ignore_basepython_conflict = True".

Change-Id: I351870695b1c6706888d8a51fa33ea0fcbc63cd7
openstack-mirroring pushed a commit to openstack/openstack that referenced this issue Jan 17, 2023
* Update neutron-specs from branch 'master'
  to e5e141f134e88703d2a25909ea22c7627f9a6fb7
  - Update envlist for tox4
    
    tox4 even when running specific env with -e option tries
    to find python version for all envs defined in envlist[1]
    when running with --skip-missing-interpreters=false and
    fails if interpreter missing for any of the env.
    
    With py38 in envlist it tries to find python3.8
    which is not available in ubuntu-jammy by default
    and fails, hence use generic version instead i.e py3
    to handle it.
    
    Even though [1] is fixed we are still seeing this failure.
    
    [1] tox-dev/tox#2811
    
    Also had to add "ignore_basepython_conflict = True".
    
    Change-Id: I351870695b1c6706888d8a51fa33ea0fcbc63cd7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:normal affects many people or has quite an impact help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants