diff --git a/fix-tests.patch b/fix-tests.patch index 179cf7e..0845016 100644 --- a/fix-tests.patch +++ b/fix-tests.patch @@ -1,4 +1,4 @@ -From 42a461b71597e85e7902571348786aa4ab848cf8 Mon Sep 17 00:00:00 2001 +From 49a830fa59f9cbc58920b5052f47089cff2685e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= Date: Fri, 28 Mar 2025 09:44:24 +0100 Subject: [PATCH] Fix tests @@ -9,28 +9,28 @@ Content-Transfer-Encoding: 8bit Co-Authored-By: Lumir Balhar Co-Authored-By: Miro HronĨok --- - pyproject.toml | 4 +--- + pyproject.toml | 3 --- src/tox/pytest.py | 14 ++------------ tests/test_provision.py | 11 ++++------- .../package/test_python_package_util.py | 10 ++++++++-- - 4 files changed, 15 insertions(+), 30 deletions(-) + 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/pyproject.toml b/pyproject.toml -index 6920d19..53326bc 100644 +index c9ca99c..3a74d6f 100644 --- a/pyproject.toml +++ b/pyproject.toml -@@ -222,9 +217,6 @@ report.omit = [ - "tests/type_check/*", - ] +@@ -239,9 +239,6 @@ ini_options.timeout = 30 + + [tool.coverage] run.parallel = true -run.plugins = [ - "covdefaults", -] - - [tool.towncrier] - name = "tox" + paths.source = [ + "src", + ".tox*/*/lib/python*/site-packages", diff --git a/src/tox/pytest.py b/src/tox/pytest.py -index 31b3e6f..c358313 100644 +index 36aa2f6..7693523 100644 --- a/src/tox/pytest.py +++ b/src/tox/pytest.py @@ -17,7 +17,6 @@ from typing import TYPE_CHECKING, Any, Protocol, cast @@ -52,7 +52,7 @@ index 31b3e6f..c358313 100644 try: tox_run(args) except SystemExit as exception: -@@ -479,15 +478,6 @@ def enable_pypi_server(monkeypatch: pytest.MonkeyPatch, url: str | None) -> None +@@ -480,15 +479,6 @@ def enable_pypi_server(monkeypatch: pytest.MonkeyPatch, url: str | None) -> None monkeypatch.setenv("PIP_TIMEOUT", str(2)) @@ -69,10 +69,10 @@ index 31b3e6f..c358313 100644 def _invalid_index_fake_port() -> int: with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as socket_handler: diff --git a/tests/test_provision.py b/tests/test_provision.py -index d1b6b2d..022e340 100644 +index 74c27b9..12c99be 100644 --- a/tests/test_provision.py +++ b/tests/test_provision.py -@@ -126,15 +126,13 @@ def _use_pypi_index(pypi_index: Index, monkeypatch: MonkeyPatch) -> None: +@@ -127,15 +127,13 @@ def _use_pypi_index(pypi_index: Index, monkeypatch: MonkeyPatch) -> None: @pytest.fixture @@ -92,7 +92,7 @@ index d1b6b2d..022e340 100644 def test_provision_requires_nok(tox_project: ToxProjectCreator) -> None: -@@ -183,7 +181,6 @@ def test_provision_requires_ok(tox_project: ToxProjectCreator, tmp_path: Path) - +@@ -213,7 +211,6 @@ def test_provision_requires_ok(tox_project: ToxProjectCreator, tmp_path: Path) - @pytest.mark.integration @@ -101,10 +101,10 @@ index d1b6b2d..022e340 100644 ini = "[tox]\nrequires=demo-pkg-inline\n[testenv]\npackage=skip\n[testenv:.tox]\nplatform=wrong_platform" proj = tox_project({"tox.ini": ini}) diff --git a/tests/tox_env/python/virtual_env/package/test_python_package_util.py b/tests/tox_env/python/virtual_env/package/test_python_package_util.py -index 3802147..7f64d90 100644 +index 4c834ce..74b04f5 100644 --- a/tests/tox_env/python/virtual_env/package/test_python_package_util.py +++ b/tests/tox_env/python/virtual_env/package/test_python_package_util.py -@@ -15,6 +15,12 @@ if TYPE_CHECKING: +@@ -16,6 +16,12 @@ if TYPE_CHECKING: from importlib.metadata import Distribution, PathDistribution @@ -117,7 +117,7 @@ index 3802147..7f64d90 100644 @pytest.fixture(scope="session") def pkg_with_extras(pkg_with_extras_project: Path) -> PathDistribution: -@@ -43,10 +49,10 @@ def test_load_dependency_many_extra(pkg_with_extras: PathDistribution) -> None: +@@ -44,10 +50,10 @@ def test_load_dependency_many_extra(pkg_with_extras: PathDistribution) -> None: exp = [ Requirement("platformdirs>=4.3.8"), Requirement("colorama>=0.4.6"), @@ -131,5 +131,5 @@ index 3802147..7f64d90 100644 for left, right in zip_longest(result, exp): assert isinstance(right, Requirement) -- -2.51.1 +2.54.0 diff --git a/python-tox.spec b/python-tox.spec index 815d3b8..e498fa0 100644 --- a/python-tox.spec +++ b/python-tox.spec @@ -20,7 +20,7 @@ %undefine _py3_shebang_s Name: python-tox -Version: 4.35.0 +Version: 4.53.1 Release: %autorelease Summary: Virtualenv-based automation of test activities @@ -28,10 +28,6 @@ License: MIT URL: https://tox.readthedocs.io/ Source: %{pypi_source tox} -# Adjust for virtualenv 21 API changes, from upsteam, rebased. -# https://github.com/tox-dev/tox/commit/a9533f575f -Patch: virtualenv-21.patch - # Remove usage of devpi-process. # Remove coverage options. # Adjust virtualenv environment variables to make it work with our patched virtualenv. @@ -47,6 +43,7 @@ BuildRequires: pyproject-rpm-macros >= 1.16 %if %{with tests} BuildRequires: /usr/bin/gcc BuildRequires: /usr/bin/git +BuildRequires: /usr/bin/man BuildRequires: /usr/bin/pip BuildRequires: /usr/bin/pytest BuildRequires: /usr/bin/python @@ -91,6 +88,9 @@ Recommends: python3.9 # Instead of adding new Pythons here, add `Supplements: tox` to them, see: # https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/NVVUXSVSPFQOWIGBE2JNI67HEO7R63ZQ/ +# Enable completions by default +Recommends: (tox+completion if (bash-completion or fish or zsh)) + %py_provides python3-tox %description -n tox %_description @@ -104,8 +104,7 @@ Recommends: python3.9 # First, carefully adjust the pins of build and runtime dependencies, # then remove all the >= specifiers from tests deps, whatever they are, # finally, remove undesired test dependencies. -sed -ri -e 's/"(packaging|filelock|platformdirs|pyproject-api|cachetools|hatch-vcs)>=.*/"\1",/g' \ - -e 's/"(virtualenv)>=.*/"\1>=20.29",/g' \ +sed -ri -e 's/"(filelock|platformdirs|pyproject-api|cachetools|hatch-vcs)>=.*/"\1",/g' \ -e 's/"(hatchling)>=.*/"\1>=1.13",/g' \ -e 's/"(pluggy)>=.*/"\1>=1.5",/g' \ -e '/^test = \[/,/^\]/ { s/>=[^;"]+// }' \ @@ -114,7 +113,7 @@ sed -ri -e 's/"(packaging|filelock|platformdirs|pyproject-api|cachetools|hatch-v %generate_buildrequires export SETUPTOOLS_SCM_PRETEND_VERSION="%{version}" -%pyproject_buildrequires -r %{?with_tests:-g test} +%pyproject_buildrequires -r %{?with_tests:-g test} -x completion %build @@ -126,18 +125,21 @@ export SETUPTOOLS_SCM_PRETEND_VERSION="%{version}" %pyproject_install %pyproject_save_files tox +for shell in bash fish zsh; do + register-python-argcomplete --shell $shell tox > tox.$shell +done +# The bash-completion package has tox already, we use the .bash suffix, +# see https://github.com/scop/bash-completion/issues/1628#issuecomment-4380971779 +install -Dpm 0644 tox.bash %{buildroot}%{bash_completions_dir}/tox.bash +install -Dpm 0644 tox.fish %{buildroot}%{fish_completions_dir}/tox.fish +install -Dpm 0644 tox.zsh %{buildroot}%{zsh_completions_dir}/_tox + %if %{with tests} %check # A macro that returns a version of the installed Python package, as an RPM v-string, defaults to v"0" %define pyversion() v"%(%{python3} -c 'import importlib.metadata as im; print(im.version("%{1}"))' 2>/dev/null || echo 0)" -# Upstream requires virtualenv >= 20.31 for tests, and no longer sets VIRTUALENV_WHEEL. -# To support environments with older virtualenv, we set it manually: -%if %{pyversion virtualenv} < v"20.31" -export VIRTUALENV_WHEEL=bundle -%endif - # Skipped tests use internal virtualenv functionality to # download wheels which does not work with "bundled" version of wheel in # the Fedora's virtualenv patch. @@ -145,11 +147,6 @@ k="${k-}${k+ and }not test_virtualenv_flipped_settings" k="${k-}${k+ and }not test_virtualenv_env_ignored_if_set" k="${k-}${k+ and }not test_virtualenv_env_used_if_not_set" -# https://github.com/tox-dev/tox/issues/3290 -%if v"0%{?python3_version}" >= v"3.13" -k="${k-}${k+ and }not test_str_convert_ok_py39" -%endif - # https://github.com/tox-dev/tox/commit/698f1dd663 # The tests fail with setuptools < 70.1 %if %{pyversion setuptools} < v"70.1" @@ -157,17 +154,6 @@ k="${k-}${k+ and }not test_result_json_sequential" k="${k-}${k+ and }not test_setuptools_package" k="${k-}${k+ and }not test_skip_develop_mode" k="${k-}${k+ and }not test_tox_install_pkg_sdist" -%else -# this test fails with virtualenv < 20.31 with bundled wheel -test -z $VIRTUALENV_WHEEL || k="${k-}${k+ and }not test_result_json_sequential" -%endif - -# Skip tests only working with packaging 26+ -# Adjusted upstream in https://github.com/tox-dev/tox/pull/3673 -%if %{pyversion packaging} < v"26" -k="${k-}${k+ and }not (test_req_file and name-extra-protocol)" -k="${k-}${k+ and }not (test_req_file and whitespace and around)" -k="${k-}${k+ and }not test_dependency_groups_bad_requirement" %endif # The following tests either need internet connection or installed tox @@ -179,7 +165,9 @@ k="${k-}${k+ and }not test_call_as_module" k="${k-}${k+ and }not test_call_as_exe" k="${k-}${k+ and }not test_run_installpkg_targz" k="${k-}${k+ and }not test_pyproject_installpkg_pep517_envs" -test -z $VIRTUALENV_WHEEL && k="${k-}${k+ and }not test_result_json_sequential" +k="${k-}${k+ and }not test_pylock_install_integration" +k="${k-}${k+ and }not test_interrupt_post_commands" +k="${k-}${k+ and }not test_second_interrupt_stops_post_commands" %endif %pytest -v -n auto -k "${k-}" --run-integration @@ -188,6 +176,12 @@ test -z $VIRTUALENV_WHEEL && k="${k-}${k+ and }not test_result_json_sequential" %files -n tox -f %{pyproject_files} %{_bindir}/tox +%{_mandir}/man1/tox.1* + +%pyproject_extras_subpkg -n tox completion +%{bash_completions_dir}/tox.bash +%{fish_completions_dir}/tox.fish +%{zsh_completions_dir}/_tox %changelog diff --git a/sources b/sources index 16136e2..2fd9c1d 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (tox-4.35.0.tar.gz) = 13134511a53b1ba794f6821886655e2421ef0d668238d65779dc10a13bab23e5711f11aefdb99c7723c78f3558032df5cb78c5fe2c90e66b067f9ce325a60225 +SHA512 (tox-4.53.1.tar.gz) = b11df73e47c5c63124b9e7e11c44a8c3c39b40d177b411bcbd4218a9875fd658a32712083102ef2a1cae6e75939cd32f7caa00551de753f30f58f7f52ab4e5dd diff --git a/virtualenv-21.patch b/virtualenv-21.patch deleted file mode 100644 index d06b542..0000000 --- a/virtualenv-21.patch +++ /dev/null @@ -1,136 +0,0 @@ -From 200b647be443613ecff552e34a76c335ac990780 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= -Date: Fri, 27 Feb 2026 16:07:38 +0000 -Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(ci):=20resolve=20ty=20type-c?= - =?UTF-8?q?heck=20failures=20(#3837)?= -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - ---- - docs/changelog/3837.bugfix.rst | 3 +++ - src/tox/tox_env/python/virtual_env/api.py | 16 +++++++++--- - tests/session/cmd/test_sequential.py | 1 + - .../python/virtual_env/test_virtualenv_api.py | 26 +++++++++++++++++++ - 4 files changed, 42 insertions(+), 4 deletions(-) - create mode 100644 docs/changelog/3837.bugfix.rst - -diff --git a/docs/changelog/3837.bugfix.rst b/docs/changelog/3837.bugfix.rst -new file mode 100644 -index 0000000..5dc14d5 ---- /dev/null -+++ b/docs/changelog/3837.bugfix.rst -@@ -0,0 +1,3 @@ -+Fix type errors flagged by ``ty`` for ``virtualenv`` API changes (``system_executable`` nullability and -+``cached_py_info.PythonInfo`` removal), and correct the CI workflow matrix exclude for ``windows-2025`` - by -+:user:`gaborbernat`. -diff --git a/src/tox/tox_env/python/virtual_env/api.py b/src/tox/tox_env/python/virtual_env/api.py -index 7c56c14..b2a26e7 100644 ---- a/src/tox/tox_env/python/virtual_env/api.py -+++ b/src/tox/tox_env/python/virtual_env/api.py -@@ -10,7 +10,6 @@ from typing import TYPE_CHECKING, Any, cast - - from virtualenv import __version__ as virtualenv_version - from virtualenv import app_data, session_via_cli --from virtualenv.discovery import cached_py_info - from virtualenv.discovery.py_spec import PythonSpec - - from tox.config.loader.str_convert import StrConvert -@@ -139,13 +138,15 @@ class VirtualEnv(Python, ABC): - interpreter = self.creator.interpreter - except (FileNotFoundError, RuntimeError): # Unable to find the interpreter - return None -+ if (sys_exe := interpreter.system_executable) is None: -+ return None - return PythonInfo( - implementation=interpreter.implementation, - version_info=interpreter.version_info, - version=interpreter.version, - is_64=(interpreter.architecture == 64), # noqa: PLR2004 - platform=interpreter.platform, -- extra={"executable": Path(interpreter.system_executable).resolve()}, -+ extra={"executable": Path(sys_exe).resolve()}, - free_threaded=interpreter.free_threaded, - ) - -@@ -194,8 +195,15 @@ class VirtualEnv(Python, ABC): - :param path: the path investigated - :return: the found information (cached) - """ -- return cached_py_info.from_exe( -- cached_py_info.PythonInfo, -+ from virtualenv.discovery import cached_py_info # noqa: PLC0415 -+ from virtualenv.discovery.py_info import PythonInfo as VirtualenvPythonInfo # noqa: PLC0415 -+ -+ result = cached_py_info.from_exe( -+ VirtualenvPythonInfo, - app_data.make_app_data(None, read_only=False, env=os.environ), - str(path), - ) -+ if result is None: -+ msg = f"could not query python information for {path}" -+ raise RuntimeError(msg) -+ return result -diff --git a/tests/session/cmd/test_sequential.py b/tests/session/cmd/test_sequential.py -index 16e177b..677ddcc 100644 ---- a/tests/session/cmd/test_sequential.py -+++ b/tests/session/cmd/test_sequential.py -@@ -81,6 +81,7 @@ def test_result_json_sequential( - log_report = json.load(file_handler) - - py_info = PythonInfo.current_system() -+ assert py_info.system_executable is not None - host_python = { - "executable": str(Path(py_info.system_executable).resolve()), - "extra_version_info": None, -diff --git a/tests/tox_env/python/virtual_env/test_virtualenv_api.py b/tests/tox_env/python/virtual_env/test_virtualenv_api.py -index 215f7ed..8960fa2 100644 ---- a/tests/tox_env/python/virtual_env/test_virtualenv_api.py -+++ b/tests/tox_env/python/virtual_env/test_virtualenv_api.py -@@ -2,13 +2,17 @@ from __future__ import annotations - - import os - import sys -+from pathlib import Path - from typing import TYPE_CHECKING -+from unittest.mock import MagicMock, PropertyMock - - import pytest - from virtualenv import __version__ as virtualenv_version - from virtualenv import session_via_cli - from virtualenv.config.cli.parser import VirtualEnvOptions - -+from tox.tox_env.python.virtual_env.api import VirtualEnv -+ - if TYPE_CHECKING: - from pytest_mock import MockerFixture - -@@ -171,3 +175,25 @@ def test_list_dependencies_command(tox_project: ToxProjectCreator) -> None: - result.assert_success() - request: ExecuteRequest = execute_calls.call_args[0][3] - assert request.cmd == ["python", "-m", "pip", "freeze"] -+ -+ -+def test_get_python_returns_none_when_system_executable_missing( -+ tox_project: ToxProjectCreator, -+ mocker: MockerFixture, -+) -> None: -+ mocker.patch.object( -+ VirtualEnv, -+ "creator", -+ new_callable=PropertyMock, -+ return_value=MagicMock(interpreter=MagicMock(system_executable=None)), -+ ) -+ proj = tox_project({"tox.ini": "[testenv]\npackage=skip\nbase_python=missing-interp"}) -+ result = proj.run("r") -+ result.assert_failed() -+ assert "could not find python interpreter" in result.out -+ -+ -+def test_get_virtualenv_py_info_raises_on_none(mocker: MockerFixture) -> None: -+ mocker.patch("virtualenv.discovery.cached_py_info.from_exe", return_value=None) -+ with pytest.raises(RuntimeError, match="could not query python information for"): -+ VirtualEnv.get_virtualenv_py_info(Path("/no/such/python")) --- -2.53.0 -