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

Regression in environment var inheritance in tox 4 #2831

Open
ostackbrian opened this issue Jan 6, 2023 · 1 comment
Open

Regression in environment var inheritance in tox 4 #2831

ostackbrian opened this issue Jan 6, 2023 · 1 comment
Labels
bug:minor does not affect many people or has no big impact help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.

Comments

@ostackbrian
Copy link

Issue

I'm not sure if this is a regression, or if I am using a bad pattern that worked by chance in tox3.

I use the base [testenv] to set_env some vars and run unit tests. Then I have a [testenv:functional] that inherits these env vars (most of which are still relevant) but changes the var governing where the tests are located. I use that as an "abstract" testenv to hold the setenv, commands, etc., for python-version-specific testenvs like [testenv:functional-py39], [testenv:functional-py310], etc. In tox3 this worked great, but in tox 4, the changes to set_env in the "abstract" testenv aren't picked up when I call 'tox -e functional-py39'.

Here's a tox.ini for this that works in both tox3 and tox4.

[tox]
envlist = py39,functional-py39
skipsdist=true

[testenv]
setenv =
    OS_TEST_PATH=./cinderclient/tests/unit
allowlist_externals = bash
commands = bash ts.sh testenv

# abstract env
[testenv:functional]
setenv =
  {[testenv]setenv}
  OS_TEST_PATH=./cinderclient/tests/functional
commands = bash ts.sh functional

# python-version-specific env
[testenv:functional-py39]
setenv = {[testenv:functional]setenv}
commands = {[testenv:functional]commands}

All ts.sh does is echo the value of the env var of interest to a file:

#!/bin/bash

echo "$1: $OS_TEST_PATH" >> tmpfile

Using the tox.ini with both tox3 and tox4:

./tox4 --version >> tmpfile./tox4
py39: commands[0]> bash ts.sh testenv
py39: OK ✔ in 0.06 seconds
functional-py39: commands[0]> bash ts.sh functional
  py39: OK (0.06=setup[0.06]+cmd[0.00] seconds)
  functional-py39: OK (0.05=setup[0.05]+cmd[0.00] seconds)
  congratulations :) (0.14 seconds)tox --version >> tmpfiletox
py39 create: /home/brosmait/scratch/lang/python/tox/.tox/py39
py39 run-test-pre: PYTHONHASHSEED='2285170242'
py39 run-test: commands[0] | bash ts.sh testenv
functional-py39 create: /home/brosmait/scratch/lang/python/tox/.tox/functional-py39
functional-py39 run-test-pre: PYTHONHASHSEED='2285170242'
functional-py39 run-test: commands[0] | bash ts.sh functional
____________________________________________________________ summary _____________________________________________________________
  py39: commands succeeded
  functional-py39: commands succeeded
  congratulations :)

Looking at the created file:

cat tmpfile
4.2.5 from /home/brosmait/repos/openstack/python-cinderclient/.tox/.tox/lib/python3.10/site-packages/tox/__init__.py
testenv: ./cinderclient/tests/unit
functional: ./cinderclient/tests/unit
3.28.0 imported from /usr/lib/python3.10/site-packages/tox/__init__.py
testenv: ./cinderclient/tests/unit
functional: ./cinderclient/tests/functional

You can see that tox3 uses the correct value for the env var for the functional tests, but tox4 is using the original value.

Environment

Provide at least:

  • OS: Fedora release 36
  • pip list of the host Python where tox is installed:
pip list
Package       Version
------------- -------
cachetools    5.2.0
chardet       5.1.0
colorama      0.4.6
distlib       0.3.6
filelock      3.9.0
packaging     22.0
pip           22.3.1
platformdirs  2.6.2
pluggy        1.0.0
pyproject_api 1.4.0
setuptools    65.6.3
tomli         2.0.1
tox           4.2.5
virtualenv    20.17.1
wheel         0.38.4

Output of running tox

Provide the output of tox -rvv:

./tox4 -rvv
py39: 83 W remove tox env folder /home/brosmait/scratch/lang/python/tox/.tox/py39 [tox/tox_env/api.py:321]
py39: 103 I find interpreter for spec PythonSpec(major=3, minor=9) [virtualenv/discovery/builtin.py:56]
py39: 103 D discover exe for PythonInfo(spec=CPython3.10.9.final.0-64, exe=/home/brosmait/repos/openstack/python-cinderclient/.tox/.tox/bin/python, platform=linux, version='3.10.9 (main, Dec  7 2022, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]', encoding_fs_io=utf-8-utf-8) in /usr [virtualenv/discovery/py_info.py:437]
py39: 103 D filesystem is case-sensitive [virtualenv/info.py:24]
py39: 103 D got python info of /usr/bin/python3.10 from /home/brosmait/.local/share/virtualenv/py_info/1/8a94588eda9d64d9e9a351ab8144e55b1fabf5113b54e67dd26a8c27df0381b3.json [virtualenv/app_data/via_disk_folder.py:129]
py39: 104 I proposed PythonInfo(spec=CPython3.10.9.final.0-64, system=/usr/bin/python3.10, exe=/home/brosmait/repos/openstack/python-cinderclient/.tox/.tox/bin/python, platform=linux, version='3.10.9 (main, Dec  7 2022, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:63]
py39: 104 D discover PATH[0]=/home/brosmait/.pyenv/plugins/pyenv-virtualenv/shims [virtualenv/discovery/builtin.py:108]
py39: 104 D discover PATH[1]=/home/brosmait/.pyenv/shims [virtualenv/discovery/builtin.py:108]
py39: 104 D got python info of /home/brosmait/.pyenv/shims/python3.9 from /home/brosmait/.local/share/virtualenv/py_info/1/df5750520713fe69cbf62cb311668a6a03aa778e2b7543129d2ab17ce2716c13.json [virtualenv/app_data/via_disk_folder.py:129]
py39: 105 D got python info of /home/brosmait/.pyenv/versions/3.9.14/bin/python3.9 from /home/brosmait/.local/share/virtualenv/py_info/1/e9b605bd999ef794c335c758558757307e733b618c62dd3ca2fa6d9c79695fff.json [virtualenv/app_data/via_disk_folder.py:129]
py39: 105 I proposed PathPythonInfo(spec=CPython3.9.14.final.0-64, system=/home/brosmait/.pyenv/versions/3.9.14/bin/python3.9, exe=/home/brosmait/.pyenv/shims/python3.9, platform=linux, version='3.9.14 (main, Oct  4 2022, 17:06:42) \n[GCC 12.2.1 20220819 (Red Hat 12.2.1-2)]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:63]
py39: 105 D accepted PathPythonInfo(spec=CPython3.9.14.final.0-64, system=/home/brosmait/.pyenv/versions/3.9.14/bin/python3.9, exe=/home/brosmait/.pyenv/shims/python3.9, platform=linux, version='3.9.14 (main, Oct  4 2022, 17:06:42) \n[GCC 12.2.1 20220819 (Red Hat 12.2.1-2)]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:65]
py39: 120 I create virtual environment via CPython3Posix(dest=/home/brosmait/scratch/lang/python/tox/.tox/py39, clear=False, no_vcs_ignore=False, global=False) [virtualenv/run/session.py:48]
py39: 120 D create folder /home/brosmait/scratch/lang/python/tox/.tox/py39/bin [virtualenv/util/path/_sync.py:9]
py39: 120 D create folder /home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages [virtualenv/util/path/_sync.py:9]
py39: 120 D write /home/brosmait/scratch/lang/python/tox/.tox/py39/pyvenv.cfg [virtualenv/create/pyenv_cfg.py:30]
py39: 120 D 	home = /home/brosmait/.pyenv/versions/3.9.14/bin [virtualenv/create/pyenv_cfg.py:34]
py39: 120 D 	implementation = CPython [virtualenv/create/pyenv_cfg.py:34]
py39: 120 D 	version_info = 3.9.14.final.0 [virtualenv/create/pyenv_cfg.py:34]
py39: 120 D 	virtualenv = 20.17.1 [virtualenv/create/pyenv_cfg.py:34]
py39: 120 D 	include-system-site-packages = false [virtualenv/create/pyenv_cfg.py:34]
py39: 120 D 	base-prefix = /home/brosmait/.pyenv/versions/3.9.14 [virtualenv/create/pyenv_cfg.py:34]
py39: 120 D 	base-exec-prefix = /home/brosmait/.pyenv/versions/3.9.14 [virtualenv/create/pyenv_cfg.py:34]
py39: 120 D 	base-executable = /home/brosmait/.pyenv/versions/3.9.14/bin/python3.9 [virtualenv/create/pyenv_cfg.py:34]
py39: 120 D symlink /home/brosmait/.pyenv/versions/3.9.14/bin/python3.9 to /home/brosmait/scratch/lang/python/tox/.tox/py39/bin/python [virtualenv/util/path/_sync.py:28]
py39: 121 D create virtualenv import hook file /home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages/_virtualenv.pth [virtualenv/create/via_global_ref/api.py:89]
py39: 121 D create /home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages/_virtualenv.py [virtualenv/create/via_global_ref/api.py:92]
py39: 121 D ============================== target debug ============================== [virtualenv/run/session.py:50]
py39: 121 D debug via /home/brosmait/scratch/lang/python/tox/.tox/py39/bin/python /home/brosmait/repos/openstack/python-cinderclient/.tox/.tox/lib/python3.10/site-packages/virtualenv/create/debug.py [virtualenv/create/creator.py:197]
py39: 121 D {
  "sys": {
    "executable": "/home/brosmait/scratch/lang/python/tox/.tox/py39/bin/python",
    "_base_executable": "/home/brosmait/scratch/lang/python/tox/.tox/py39/bin/python",
    "prefix": "/home/brosmait/scratch/lang/python/tox/.tox/py39",
    "base_prefix": "/home/brosmait/.pyenv/versions/3.9.14",
    "real_prefix": null,
    "exec_prefix": "/home/brosmait/scratch/lang/python/tox/.tox/py39",
    "base_exec_prefix": "/home/brosmait/.pyenv/versions/3.9.14",
    "path": [
      "/home/brosmait/.pyenv/versions/3.9.14/lib/python39.zip",
      "/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9",
      "/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9/lib-dynload",
      "/home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages"
    ],
    "meta_path": [
      "<class '_virtualenv._Finder'>",
      "<class '_frozen_importlib.BuiltinImporter'>",
      "<class '_frozen_importlib.FrozenImporter'>",
      "<class '_frozen_importlib_external.PathFinder'>"
    ],
    "fs_encoding": "utf-8",
    "io_encoding": "utf-8"
  },
  "version": "3.9.14 (main, Oct  4 2022, 17:06:42) \n[GCC 12.2.1 20220819 (Red Hat 12.2.1-2)]",
  "makefile_filename": "/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9/config-3.9-x86_64-linux-gnu/Makefile",
  "os": "<module 'os' from '/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9/os.py'>",
  "site": "<module 'site' from '/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9/site.py'>",
  "datetime": "<module 'datetime' from '/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9/datetime.py'>",
  "math": "<module 'math' from '/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9/lib-dynload/math.cpython-39-x86_64-linux-gnu.so'>",
  "json": "<module 'json' from '/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9/json/__init__.py'>"
} [virtualenv/run/session.py:51]
py39: 136 I add seed packages via FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/brosmait/.local/share/virtualenv) [virtualenv/run/session.py:55]
py39: 137 D install setuptools from wheel /home/brosmait/repos/openstack/python-cinderclient/.tox/.tox/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/setuptools-65.6.3-py3-none-any.whl via CopyPipInstall [virtualenv/seed/embed/via_app_data/via_app_data.py:47]
py39: 137 D install pip from wheel /home/brosmait/repos/openstack/python-cinderclient/.tox/.tox/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/pip-22.3.1-py3-none-any.whl via CopyPipInstall [virtualenv/seed/embed/via_app_data/via_app_data.py:47]
py39: 137 D install wheel from wheel /home/brosmait/repos/openstack/python-cinderclient/.tox/.tox/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/wheel-0.38.4-py3-none-any.whl via CopyPipInstall [virtualenv/seed/embed/via_app_data/via_app_data.py:47]
py39: 138 D copy /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-65.6.3-py3-none-any/distutils-precedence.pth to /home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages/distutils-precedence.pth [virtualenv/util/path/_sync.py:36]
py39: 138 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/wheel-0.38.4-py3-none-any/wheel to /home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages/wheel [virtualenv/util/path/_sync.py:36]
py39: 138 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/pip-22.3.1-py3-none-any/pip to /home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages/pip [virtualenv/util/path/_sync.py:36]
py39: 138 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-65.6.3-py3-none-any/_distutils_hack to /home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages/_distutils_hack [virtualenv/util/path/_sync.py:36]
py39: 139 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-65.6.3-py3-none-any/pkg_resources to /home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages/pkg_resources [virtualenv/util/path/_sync.py:36]
py39: 142 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/wheel-0.38.4-py3-none-any/wheel-0.38.4.dist-info to /home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages/wheel-0.38.4.dist-info [virtualenv/util/path/_sync.py:36]
py39: 143 D copy /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/wheel-0.38.4-py3-none-any/wheel-0.38.4.virtualenv to /home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages/wheel-0.38.4.virtualenv [virtualenv/util/path/_sync.py:36]
py39: 144 D generated console scripts wheel-3.9 wheel wheel3 wheel3.9 [virtualenv/seed/embed/via_app_data/pip_install/base.py:41]
py39: 147 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-65.6.3-py3-none-any/setuptools to /home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages/setuptools [virtualenv/util/path/_sync.py:36]
py39: 165 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-65.6.3-py3-none-any/setuptools-65.6.3.dist-info to /home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages/setuptools-65.6.3.dist-info [virtualenv/util/path/_sync.py:36]
py39: 166 D copy /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-65.6.3-py3-none-any/setuptools-65.6.3.virtualenv to /home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages/setuptools-65.6.3.virtualenv [virtualenv/util/path/_sync.py:36]
py39: 166 D generated console scripts  [virtualenv/seed/embed/via_app_data/pip_install/base.py:41]
py39: 178 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/pip-22.3.1-py3-none-any/pip-22.3.1.dist-info to /home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages/pip-22.3.1.dist-info [virtualenv/util/path/_sync.py:36]
py39: 178 D copy /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/pip-22.3.1-py3-none-any/pip-22.3.1.virtualenv to /home/brosmait/scratch/lang/python/tox/.tox/py39/lib/python3.9/site-packages/pip-22.3.1.virtualenv [virtualenv/util/path/_sync.py:36]
py39: 179 D generated console scripts pip3.9 pip pip-3.9 pip3 [virtualenv/seed/embed/via_app_data/pip_install/base.py:41]
py39: 179 I add activators for Bash, CShell, Fish, Nushell, PowerShell, Python [virtualenv/run/session.py:61]
py39: 180 D write /home/brosmait/scratch/lang/python/tox/.tox/py39/pyvenv.cfg [virtualenv/create/pyenv_cfg.py:30]
py39: 180 D 	home = /home/brosmait/.pyenv/versions/3.9.14/bin [virtualenv/create/pyenv_cfg.py:34]
py39: 180 D 	implementation = CPython [virtualenv/create/pyenv_cfg.py:34]
py39: 180 D 	version_info = 3.9.14.final.0 [virtualenv/create/pyenv_cfg.py:34]
py39: 180 D 	virtualenv = 20.17.1 [virtualenv/create/pyenv_cfg.py:34]
py39: 180 D 	include-system-site-packages = false [virtualenv/create/pyenv_cfg.py:34]
py39: 180 D 	base-prefix = /home/brosmait/.pyenv/versions/3.9.14 [virtualenv/create/pyenv_cfg.py:34]
py39: 180 D 	base-exec-prefix = /home/brosmait/.pyenv/versions/3.9.14 [virtualenv/create/pyenv_cfg.py:34]
py39: 180 D 	base-executable = /home/brosmait/.pyenv/versions/3.9.14/bin/python3.9 [virtualenv/create/pyenv_cfg.py:34]
py39: 181 W commands[0]> bash ts.sh testenv [tox/tox_env/api.py:427]
py39: 183 I exit 0 (0.00 seconds) /home/brosmait/scratch/lang/python/tox> bash ts.sh testenv pid=315709 [tox/execute/api.py:275]
py39: OK ✔ in 0.1 seconds
functional-py39: 183 W remove tox env folder /home/brosmait/scratch/lang/python/tox/.tox/functional-py39 [tox/tox_env/api.py:321]
functional-py39: 201 I find interpreter for spec PythonSpec(major=3, minor=9) [virtualenv/discovery/builtin.py:56]
functional-py39: 201 I proposed PythonInfo(spec=CPython3.10.9.final.0-64, system=/usr/bin/python3.10, exe=/home/brosmait/repos/openstack/python-cinderclient/.tox/.tox/bin/python, platform=linux, version='3.10.9 (main, Dec  7 2022, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:63]
functional-py39: 201 D discover PATH[0]=/home/brosmait/.pyenv/plugins/pyenv-virtualenv/shims [virtualenv/discovery/builtin.py:108]
functional-py39: 202 D discover PATH[1]=/home/brosmait/.pyenv/shims [virtualenv/discovery/builtin.py:108]
functional-py39: 202 I proposed PathPythonInfo(spec=CPython3.9.14.final.0-64, system=/home/brosmait/.pyenv/versions/3.9.14/bin/python3.9, exe=/home/brosmait/.pyenv/shims/python3.9, platform=linux, version='3.9.14 (main, Oct  4 2022, 17:06:42) \n[GCC 12.2.1 20220819 (Red Hat 12.2.1-2)]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:63]
functional-py39: 202 D accepted PathPythonInfo(spec=CPython3.9.14.final.0-64, system=/home/brosmait/.pyenv/versions/3.9.14/bin/python3.9, exe=/home/brosmait/.pyenv/shims/python3.9, platform=linux, version='3.9.14 (main, Oct  4 2022, 17:06:42) \n[GCC 12.2.1 20220819 (Red Hat 12.2.1-2)]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:65]
functional-py39: 202 I create virtual environment via CPython3Posix(dest=/home/brosmait/scratch/lang/python/tox/.tox/functional-py39, clear=False, no_vcs_ignore=False, global=False) [virtualenv/run/session.py:48]
functional-py39: 203 D create folder /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/bin [virtualenv/util/path/_sync.py:9]
functional-py39: 203 D create folder /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages [virtualenv/util/path/_sync.py:9]
functional-py39: 203 D write /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/pyvenv.cfg [virtualenv/create/pyenv_cfg.py:30]
functional-py39: 203 D 	home = /home/brosmait/.pyenv/versions/3.9.14/bin [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 203 D 	implementation = CPython [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 203 D 	version_info = 3.9.14.final.0 [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 203 D 	virtualenv = 20.17.1 [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 203 D 	include-system-site-packages = false [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 203 D 	base-prefix = /home/brosmait/.pyenv/versions/3.9.14 [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 203 D 	base-exec-prefix = /home/brosmait/.pyenv/versions/3.9.14 [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 203 D 	base-executable = /home/brosmait/.pyenv/versions/3.9.14/bin/python3.9 [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 203 D symlink /home/brosmait/.pyenv/versions/3.9.14/bin/python3.9 to /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/bin/python [virtualenv/util/path/_sync.py:28]
functional-py39: 203 D create virtualenv import hook file /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages/_virtualenv.pth [virtualenv/create/via_global_ref/api.py:89]
functional-py39: 203 D create /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages/_virtualenv.py [virtualenv/create/via_global_ref/api.py:92]
functional-py39: 203 D ============================== target debug ============================== [virtualenv/run/session.py:50]
functional-py39: 203 D debug via /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/bin/python /home/brosmait/repos/openstack/python-cinderclient/.tox/.tox/lib/python3.10/site-packages/virtualenv/create/debug.py [virtualenv/create/creator.py:197]
functional-py39: 203 D {
  "sys": {
    "executable": "/home/brosmait/scratch/lang/python/tox/.tox/functional-py39/bin/python",
    "_base_executable": "/home/brosmait/scratch/lang/python/tox/.tox/functional-py39/bin/python",
    "prefix": "/home/brosmait/scratch/lang/python/tox/.tox/functional-py39",
    "base_prefix": "/home/brosmait/.pyenv/versions/3.9.14",
    "real_prefix": null,
    "exec_prefix": "/home/brosmait/scratch/lang/python/tox/.tox/functional-py39",
    "base_exec_prefix": "/home/brosmait/.pyenv/versions/3.9.14",
    "path": [
      "/home/brosmait/.pyenv/versions/3.9.14/lib/python39.zip",
      "/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9",
      "/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9/lib-dynload",
      "/home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages"
    ],
    "meta_path": [
      "<class '_virtualenv._Finder'>",
      "<class '_frozen_importlib.BuiltinImporter'>",
      "<class '_frozen_importlib.FrozenImporter'>",
      "<class '_frozen_importlib_external.PathFinder'>"
    ],
    "fs_encoding": "utf-8",
    "io_encoding": "utf-8"
  },
  "version": "3.9.14 (main, Oct  4 2022, 17:06:42) \n[GCC 12.2.1 20220819 (Red Hat 12.2.1-2)]",
  "makefile_filename": "/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9/config-3.9-x86_64-linux-gnu/Makefile",
  "os": "<module 'os' from '/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9/os.py'>",
  "site": "<module 'site' from '/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9/site.py'>",
  "datetime": "<module 'datetime' from '/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9/datetime.py'>",
  "math": "<module 'math' from '/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9/lib-dynload/math.cpython-39-x86_64-linux-gnu.so'>",
  "json": "<module 'json' from '/home/brosmait/.pyenv/versions/3.9.14/lib/python3.9/json/__init__.py'>"
} [virtualenv/run/session.py:51]
functional-py39: 219 I add seed packages via FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/brosmait/.local/share/virtualenv) [virtualenv/run/session.py:55]
functional-py39: 220 D install pip from wheel /home/brosmait/repos/openstack/python-cinderclient/.tox/.tox/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/pip-22.3.1-py3-none-any.whl via CopyPipInstall [virtualenv/seed/embed/via_app_data/via_app_data.py:47]
functional-py39: 220 D install setuptools from wheel /home/brosmait/repos/openstack/python-cinderclient/.tox/.tox/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/setuptools-65.6.3-py3-none-any.whl via CopyPipInstall [virtualenv/seed/embed/via_app_data/via_app_data.py:47]
functional-py39: 220 D install wheel from wheel /home/brosmait/repos/openstack/python-cinderclient/.tox/.tox/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/wheel-0.38.4-py3-none-any.whl via CopyPipInstall [virtualenv/seed/embed/via_app_data/via_app_data.py:47]
functional-py39: 221 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/wheel-0.38.4-py3-none-any/wheel to /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages/wheel [virtualenv/util/path/_sync.py:36]
functional-py39: 221 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/pip-22.3.1-py3-none-any/pip to /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages/pip [virtualenv/util/path/_sync.py:36]
functional-py39: 221 D copy /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-65.6.3-py3-none-any/distutils-precedence.pth to /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages/distutils-precedence.pth [virtualenv/util/path/_sync.py:36]
functional-py39: 222 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-65.6.3-py3-none-any/_distutils_hack to /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages/_distutils_hack [virtualenv/util/path/_sync.py:36]
functional-py39: 222 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-65.6.3-py3-none-any/pkg_resources to /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages/pkg_resources [virtualenv/util/path/_sync.py:36]
functional-py39: 224 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/wheel-0.38.4-py3-none-any/wheel-0.38.4.dist-info to /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages/wheel-0.38.4.dist-info [virtualenv/util/path/_sync.py:36]
functional-py39: 226 D copy /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/wheel-0.38.4-py3-none-any/wheel-0.38.4.virtualenv to /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages/wheel-0.38.4.virtualenv [virtualenv/util/path/_sync.py:36]
functional-py39: 227 D generated console scripts wheel-3.9 wheel wheel3 wheel3.9 [virtualenv/seed/embed/via_app_data/pip_install/base.py:41]
functional-py39: 229 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-65.6.3-py3-none-any/setuptools to /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages/setuptools [virtualenv/util/path/_sync.py:36]
functional-py39: 249 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-65.6.3-py3-none-any/setuptools-65.6.3.dist-info to /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages/setuptools-65.6.3.dist-info [virtualenv/util/path/_sync.py:36]
functional-py39: 250 D copy /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-65.6.3-py3-none-any/setuptools-65.6.3.virtualenv to /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages/setuptools-65.6.3.virtualenv [virtualenv/util/path/_sync.py:36]
functional-py39: 250 D generated console scripts  [virtualenv/seed/embed/via_app_data/pip_install/base.py:41]
functional-py39: 261 D copy directory /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/pip-22.3.1-py3-none-any/pip-22.3.1.dist-info to /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages/pip-22.3.1.dist-info [virtualenv/util/path/_sync.py:36]
functional-py39: 262 D copy /home/brosmait/.local/share/virtualenv/wheel/3.9/image/1/CopyPipInstall/pip-22.3.1-py3-none-any/pip-22.3.1.virtualenv to /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/lib/python3.9/site-packages/pip-22.3.1.virtualenv [virtualenv/util/path/_sync.py:36]
functional-py39: 262 D generated console scripts pip3 pip3.9 pip pip-3.9 [virtualenv/seed/embed/via_app_data/pip_install/base.py:41]
functional-py39: 262 I add activators for Bash, CShell, Fish, Nushell, PowerShell, Python [virtualenv/run/session.py:61]
functional-py39: 263 D write /home/brosmait/scratch/lang/python/tox/.tox/functional-py39/pyvenv.cfg [virtualenv/create/pyenv_cfg.py:30]
functional-py39: 263 D 	home = /home/brosmait/.pyenv/versions/3.9.14/bin [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 263 D 	implementation = CPython [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 263 D 	version_info = 3.9.14.final.0 [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 263 D 	virtualenv = 20.17.1 [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 263 D 	include-system-site-packages = false [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 263 D 	base-prefix = /home/brosmait/.pyenv/versions/3.9.14 [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 263 D 	base-exec-prefix = /home/brosmait/.pyenv/versions/3.9.14 [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 263 D 	base-executable = /home/brosmait/.pyenv/versions/3.9.14/bin/python3.9 [virtualenv/create/pyenv_cfg.py:34]
functional-py39: 264 W commands[0]> bash ts.sh functional [tox/tox_env/api.py:427]
functional-py39: 266 I exit 0 (0.00 seconds) /home/brosmait/scratch/lang/python/tox> bash ts.sh functional pid=315721 [tox/execute/api.py:275]
  py39: OK (0.10=setup[0.10]+cmd[0.00] seconds)
  functional-py39: OK (0.08=setup[0.08]+cmd[0.00] seconds)
  congratulations :) (0.21 seconds)cat tmpfile
testenv: ./cinderclient/tests/unit
functional: ./cinderclient/tests/unit

Minimal example

If possible, provide a minimal reproducer for the issue:

(see file above)

Observations

  1. The "abstract" testenv is necessary, that is, the bug isn't reproducible if you just have 2 testenvs.

  2. I think this may have something to do with lazy loading of environments in tox4, because the bug doesn't occur if we use that intermediate "abstract" environment:

./tox4 -e py39,functional,functional-py39
py39: commands[0]> bash ts.sh testenv
py39: OK ✔ in 0.02 seconds
functional: commands[0]> bash ts.sh functional
functional: OK ✔ in 0 seconds
functional-py39: commands[0]> bash ts.sh functional
  py39: OK (0.02=setup[0.02]+cmd[0.00] seconds)
  functional: OK (0.00=setup[0.00]+cmd[0.00] seconds)
  functional-py39: OK (0.00=setup[0.00]+cmd[0.00] seconds)
  congratulations :) (0.05 seconds)cat tmpfile
testenv: ./cinderclient/tests/unit
functional: ./cinderclient/tests/functional
functional: ./cinderclient/tests/functional

... though, of course, the whole point of the "abstract" testenv is that you normally don't use it directly.

  1. The output for 'tox c' doesn't include the change to the env var:
./tox4 c -k set_env -e py39,functional,functional-py39
[testenv:py39]
set_env =
  OS_TEST_PATH=./cinderclient/tests/unit
  PIP_DISABLE_PIP_VERSION_CHECK=1
  PYTHONHASHSEED=4137894661
  PYTHONIOENCODING=utf-8

[testenv:functional]
set_env =
  OS_TEST_PATH=./cinderclient/tests/unit
  PIP_DISABLE_PIP_VERSION_CHECK=1
  PYTHONHASHSEED=4137894661
  PYTHONIOENCODING=utf-8

[testenv:functional-py39]
set_env =
  OS_TEST_PATH=./cinderclient/tests/unit
  PIP_DISABLE_PIP_VERSION_CHECK=1
  PYTHONHASHSEED=4137894661
  PYTHONIOENCODING=utf-8

This seems kind of bad to me, because people not using the "abstract" testenv will still see misleading results from the 'tox c' output. In other words, if you only had [testenv] and [testenv:functional] defined (forget about the "abstract" business), 'tox c' does not show the value that tox is actually using for OS_TEST_PATH when you call 'tox -e functional', which makes debugging the config file difficult.

  1. If the pattern I'm using to have an "abstract" job is stupid, please let me know what a better way to do this is and I'll be happy to use it. But if it's a reasonable thing to do, I imagine I'm not the only one doing it, and it's going to cause difficulties upgrading from tox3 to tox4. (I mean, the workaround is easy enough, just violate the DRY principle and explicitly set all the env vars, but you have to know to do it.)
@gaborbernat
Copy link
Member

gaborbernat commented Jan 6, 2023

There's no such thing as abstract env (in either tox 3 or 4) 🤔 is this some concept you've come up with on your own? PR to fix it is welcome. Perhaps factor filters express better what you want:

[tox]
envlist = py39,functional-py39
skipsdist=true

[testenv]
setenv =
    OS_TEST_PATH=./cinderclient/tests/unit
   functional:  OS_TEST_PATH=./cinderclient/tests/functional
allowlist_externals = bash
commands = bash ts.sh testenv

@gaborbernat gaborbernat added bug:minor does not affect many people or has no big impact help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted. labels Jan 6, 2023
@gaborbernat gaborbernat modified the milestones: P-0, P-1 Jan 6, 2023
@gaborbernat gaborbernat removed this from the P-1 milestone Jun 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:minor does not affect many people or has no big impact help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.
Projects
None yet
Development

No branches or pull requests

2 participants