From 65cb96383bd4ee9a8621702be2b888a77cdaa208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 12 Aug 2020 17:04:58 +0200 Subject: [PATCH] Drop support for tox < 3.13 (< 3.15 with Python 3.8+) We have tox 3.13 in Fedora 31 running on Python 3.7 We have tox 3.15 in Fedora 32 running on Python 3.8 --- .github/workflows/main.yaml | 8 ++++---- setup.py | 8 +++++++- src/tox_current_env/hooks.py | 18 ++++++++---------- tests/test_integration.py | 12 ++++++------ tox.ini | 5 +++-- 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 782acd0..a9f6a74 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -19,10 +19,10 @@ jobs: tox_env: # This information is repeated in tox.ini # (see https://github.com/fedora-python/tox-github-action/issues/8) - - py36-tox35 - - py37-tox35 - - py38-tox35 - - py39-tox35 + - py36-tox313 + - py37-tox313 + - py38-tox315 + - py39-tox315 - py36-toxrelease - py37-toxrelease diff --git a/setup.py b/setup.py index 933132b..63ddc01 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,13 @@ setup( package_dir={"": "src"}, packages=find_packages("src"), entry_points={"tox": ["current-env = tox_current_env.hooks"]}, - install_requires=["tox>=3.5"], + install_requires=[ + # We support tox 3.13 only to support Fedora 31. + # Fedora's tox 3.13 is patched to support Python 3.8 and 3.9, + # but the one downloaded from PyPI isn't and it doesn't work properly. + "tox>=3.15; python_version >= '3.8'", + "tox>=3.13; python_version < '3.8'", + ], python_requires=">=3.6", classifiers=[ "Development Status :: 3 - Alpha", diff --git a/src/tox_current_env/hooks.py b/src/tox_current_env/hooks.py index 16dd679..f04ad67 100644 --- a/src/tox_current_env/hooks.py +++ b/src/tox_current_env/hooks.py @@ -177,13 +177,11 @@ def tox_runtest(venv, redirect): return True -if hasattr(tox.hookspecs, "tox_cleanup"): - - @tox.hookimpl - def tox_cleanup(session): - """Remove the fake virtualenv not to collide with regular tox - Collisions can happen anyway (when tox is killed forcefully before this happens) - Note that we don't remove real venvs, as recreating them is expensive""" - for venv in session.venv_dict.values(): - if is_current_env_link(venv): - rm_venv(venv) +@tox.hookimpl +def tox_cleanup(session): + """Remove the fake virtualenv not to collide with regular tox + Collisions can happen anyway (when tox is killed forcefully before this happens) + Note that we don't remove real venvs, as recreating them is expensive""" + for venv in session.venv_dict.values(): + if is_current_env_link(venv): + rm_venv(venv) diff --git a/tests/test_integration.py b/tests/test_integration.py index 6e8e12d..6520858 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -49,8 +49,8 @@ def is_available(python): TOX_VERSION = version.parse(tox("--version").stdout.split(" ")[0]) -TOX38 = TOX_VERSION >= version.parse("3.8") -needs_tox38 = pytest.mark.skipif(not TOX38, reason="This test needs at least tox 3.8") +TOX313 = TOX_VERSION < version.parse("3.14") + needs_py36789 = pytest.mark.skipif( not all((is_available(f"python3.{x}") for x in range(6, 10))), @@ -195,8 +195,10 @@ def test_regular_run(): assert "/.tox/py39 is the exec_prefix" in lines[3] assert "congratulations" in result.stdout for y in 6, 7, 8, 9: - if y == 9 and not TOX38: - # tox 3.5 cannot handle Python 3.9 venvs + if TOX313 and y > 8: + # there is a bug in tox < 3.14, + # it creates venv with /usr/bin/python3 if the version is unknown + # See https://src.fedoraproject.org/rpms/python-tox/pull-request/15 continue for pkg in "py", "six", "test": sitelib = DOT_TOX / f"py3{y}/lib/python3.{y}/site-packages" @@ -217,7 +219,6 @@ def test_regular_run_native_toxenv(): assert len(list(sitelib.glob(f"{pkg}-*.dist-info"))) == 1 -@needs_tox38 def test_regular_after_current_is_supported(): result = tox("-e", NATIVE_TOXENV, "--current-env") assert result.stdout.splitlines()[0] == NATIVE_EXEC_PREFIX_MSG @@ -237,7 +238,6 @@ def test_regular_after_killed_current_is_not_supported(): assert "--recreate" in result.stderr -@needs_tox38 def test_regular_after_first_deps_only_is_supported(): result = tox("-e", NATIVE_TOXENV, "--print-deps-only") assert result.stdout.splitlines()[0] == "six" diff --git a/tox.ini b/tox.ini index c87a2a9..15b58f3 100644 --- a/tox.ini +++ b/tox.ini @@ -2,14 +2,15 @@ # This information is repeated in .github/workflows/main.yaml # (see https://github.com/fedora-python/tox-github-action/issues/8) -envlist = {py36,py37,py38,py39}-tox{35,release,master} +envlist = {py36,py37,py38,py39}-tox{release,master},{py36,py37}-tox313,{py38,py39}-tox315 [testenv] deps= pytest pytest-xdist packaging - tox35: tox >=3.5,<3.6 + tox313: tox >=3.13,<3.14 + tox315: tox >=3.15,<3.16 toxrelease: tox toxmaster: git+https://github.com/tox-dev/tox.git@master commands =