tox
tox copied to clipboard
Testing tox with `tox py` requires system-installed venv package
Issue
It looks as if when using a Debian-supplied python3
interpreter, you must have additional OS packages installed as well, these being at least python3-venv
. Cannot tox simply use virtualenv
for this since, being a tox dependency, that is always available in the environment?
Environment
Debian 12, system python3
package supplying Python 3.11.2.
Output of host python pip list
(Debian python3-pip
is not installed):
$ pip list
bash: pip: command not found
$ pip3 list
bash: pip3: command not found
Output of top-level tox environment pip list
:
$ pae tox pip list
Package Version
------------- -------
cachetools 5.3.2
chardet 5.2.0
colorama 0.4.6
distlib 0.3.8
filelock 3.13.1
packaging 23.2
pip 23.3.2
platformdirs 4.1.0
pluggy 1.3.0
pyproject-api 1.6.1
setuptools 69.0.3
tox 4.12.1
virtualenv 20.25.0
wheel 0.42.0
I'm running the "top-level" tox in a virtual environment using pae
from pactivate. This is essentially the same thing as using pipx, and python3 ~/Downloads/pipx.pyz run tox -e py -- -k test_build_wheel_external
produces the same error.
Output of running tox
$ pae tox -e py -- -k test_build_wheel_external
.pkg: _optional_hooks> python /home/cjs/.pyvirtenv/tox/.build/virtualenv/lib/python3.11/site-packages/pyproject_api/_backend.py True hatchling.build
.pkg: get_requires_for_build_wheel> python /home/cjs/.pyvirtenv/tox/.build/virtualenv/lib/python3.11/site-packages/pyproject_api/_backend.py True hatchling.build
.pkg: get_requires_for_build_editable> python /home/cjs/.pyvirtenv/tox/.build/virtualenv/lib/python3.11/site-packages/pyproject_api/_backend.py True hatchling.build
.pkg: build_wheel> python /home/cjs/.pyvirtenv/tox/.build/virtualenv/lib/python3.11/site-packages/pyproject_api/_backend.py True hatchling.build
py: install_package> python -I -m pip install --force-reinstall --no-deps /home/cjs/co/public/gh/tox-dev/tox/.tox/.tmp/package/12/tox-4.12.2.dev1+g5054a86f-py3-none-any.whl
py: commands[0]> pytest -k test_build_wheel_external
============================================================================ test session starts =============================================================================
platform linux -- Python 3.11.2, pytest-7.4.4, pluggy-1.3.0
cachedir: .tox/py/.pytest_cache
rootdir: /home/cjs/co/public/gh/tox-dev/tox
configfile: pyproject.toml
testpaths: tests
plugins: cov-4.1.0, xdist-3.5.0, time-machine-2.13.0, devpi-server-6.10.0, anyio-4.2.0, flaky-3.7.0, mock-3.12.0
collected 1690 items / 1686 deselected / 4 selected
tests/tox_env/python/virtual_env/package/test_package_cmd_builder.py F... [100%]
================================================================================== FAILURES ==================================================================================
_________________________________________________________________________ test_build_wheel_external __________________________________________________________________________
tests/tox_env/python/virtual_env/package/test_package_cmd_builder.py:108: in test_build_wheel_external
result.assert_success()
demo_pkg_inline = PosixPath('/home/cjs/co/public/gh/tox-dev/tox/tests/demo_pkg_inline')
ini = "\n [testenv]\n package = external\n package_env = .ext\n commands =\n python -c 'from demo_pkg_inl... package_glob = {envtmpdir}{/}dist{/}*.whl\n commands =\n pyproject-build -w . -o {envtmpdir}{/}dist\n "
project = ToxProject(path=/tmp/pytest-of-cjs/pytest-10/test_build_wheel_external0/p) at 140152652576272
result = code: 1
cmd: /home/cjs/co/public/gh/tox-dev/tox/.tox/py/bin/python -m tox r --root /home/cjs/co/public/gh/tox-dev/tox/...failed with stopping as failed to build package
py: FAIL code 1 (2.63 seconds)
evaluation failed :( (2.66 seconds)
tox_project = <function init_fixture.<locals>._init at 0x7f77d52fa480>
.tox/py/lib/python3.11/site-packages/tox/pytest.py:354: in assert_success
assert self.success, repr(self) # noqa: S101
E AssertionError: code: 1
E cmd: /home/cjs/co/public/gh/tox-dev/tox/.tox/py/bin/python -m tox r --root /home/cjs/co/public/gh/tox-dev/tox/tests/demo_pkg_inline --workdir /tmp/pytest-of-cjs/pytest-10/test_build_wheel_external0/p
E cwd: /tmp/pytest-of-cjs/pytest-10/test_build_wheel_external0/p
E standard output
E .ext: install_requires /home/cjs/co/public/gh/tox-dev/tox/tests/demo_pkg_inline> python -I -m pip install build
E .ext: install_deps /home/cjs/co/public/gh/tox-dev/tox/tests/demo_pkg_inline> python -I -m pip install build
E .ext: commands[0] /home/cjs/co/public/gh/tox-dev/tox/tests/demo_pkg_inline> pyproject-build -w . -o /tmp/pytest-of-cjs/pytest-10/test_build_wheel_external0/p/.ext/tmp/dist
E * Creating venv isolated environment...
E The virtual environment was not created successfully because ensurepip is not
E available. On Debian/Ubuntu systems, you need to install the python3-venv
E package using the following command.
E
E apt install python3.11-venv
E
E You may need to use sudo with that command. After installing the python3-venv
E package, recreate your virtual environment.
E
E Failing command: /tmp/build-env-l8i3vowx/bin/python3.11
E
E .ext: exit 1 (0.16 seconds) /home/cjs/co/public/gh/tox-dev/tox/tests/demo_pkg_inline> pyproject-build -w . -o /tmp/pytest-of-cjs/pytest-10/test_build_wheel_external0/p/.ext/tmp/dist pid=3477409
E py: failed with stopping as failed to build package
E py: FAIL code 1 (2.63 seconds)
E evaluation failed :( (2.66 seconds)
E
E assert False
E + where False = code: 1\ncmd: /home/cjs/co/public/gh/tox-dev/tox/.tox/py/bin/python -m tox r --root /home/cjs/co/public/gh/tox-dev/tox/...failed with stopping as failed to build package\n py: FAIL code 1 (2.63 seconds)\n evaluation failed :( (2.66 seconds)\n.success
self = code: 1
cmd: /home/cjs/co/public/gh/tox-dev/tox/.tox/py/bin/python -m tox r --root /home/cjs/co/public/gh/tox-dev/tox/...failed with stopping as failed to build package
py: FAIL code 1 (2.63 seconds)
evaluation failed :( (2.66 seconds)
========================================================================== short test summary info ===========================================================================
FAILED tests/tox_env/python/virtual_env/package/test_package_cmd_builder.py::test_build_wheel_external - AssertionError: code: 1
================================================================ 1 failed, 3 passed, 1686 deselected in 3.74s ================================================================
py: exit 1 (4.61 seconds) /home/cjs/co/public/gh/tox-dev/tox> pytest -k test_build_wheel_external pid=3477284
.pkg: _exit> python /home/cjs/.pyvirtenv/tox/.build/virtualenv/lib/python3.11/site-packages/pyproject_api/_backend.py True hatchling.build
py: FAIL code 1 (6.20=setup[1.60]+cmd[4.61] seconds)
evaluation failed :( (6.28 seconds)
Minimal example
On your Debian system, ensure python3
is installed but python3-venv
and python3-pip
are not installed. In the tox source tree, use pae
or pipx as described above to run
tox -e py -- -k test_build_wheel_external`.
This sounds like a bug for pyproject-build, not tox.
Can you give me a rough idea of how pyproject-build is being used here so that I can try to build a test case for that? It's not clear to me what test_build_wheel_external
is doing, or the location of the virtual environment that its ini = ...
is creating. (I cannot find a .ext
directory anywhere under the tree after running that test.)
E .ext: commands[0] /home/cjs/co/public/gh/tox-dev/tox/tests/demo_pkg_inline> pyproject-build -w . -o /tmp/pytest-of-cjs/pytest-10/test_build_wheel_external0/p/.ext/tmp/dist
The test seems to be using it to build a wheel.