Skip to content

Commit 6305d9a

Browse files
authored
Default tox min_version to 4.0 instead of current tox version (#2613)
1 parent 554bd0a commit 6305d9a

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

docs/changelog/2613.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Default tox min_version to 4.0 instead of current tox version - by :user:`gaborbernat`.

src/tox/provision.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from tox.tox_env.errors import Skip
2222
from tox.tox_env.python.pip.req_file import PythonDeps
2323
from tox.tox_env.python.runner import PythonRun
24-
from tox.version import version as current_version
2524

2625
if sys.version_info >= (3, 8): # pragma: no cover (py38+)
2726
from importlib.metadata import PackageNotFoundError, distribution
@@ -63,7 +62,7 @@ def provision(state: State) -> int | bool:
6362
keys=["min_version", "minversion"],
6463
of_type=Version,
6564
# do not include local version specifier (because it's not allowed in version spec per PEP-440)
66-
default=Version(current_version),
65+
default=Version("4.0"),
6766
desc="Define the minimal tox version required to run",
6867
)
6968
state.conf.core.add_config(
@@ -75,12 +74,7 @@ def provision(state: State) -> int | bool:
7574

7675
def add_tox_requires_min_version(requires: list[Requirement]) -> list[Requirement]:
7776
min_version: Version = state.conf.core["min_version"]
78-
# If own version can be a development one or a pre-release, we need to only use its base_version for
79-
# requirements, or pip will never be able to find a version that is compatible with the requirement.
80-
if min_version.is_devrelease or min_version.is_prerelease:
81-
# Earliest possible pre-release number for current base version.
82-
min_version = Version(f"{min_version.base_version}a0")
83-
requires.append(Requirement(f"tox >= {min_version.public}"))
77+
requires.append(Requirement(f"tox >= {min_version}"))
8478
return requires
8579

8680
state.conf.core.add_config(

tests/test_provision.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
from pathlib import Path
99
from subprocess import check_call
1010
from typing import Callable, Iterator
11+
from unittest import mock
1112
from zipfile import ZipFile
1213

1314
import pytest
1415
from devpi_process import Index, IndexServer
1516
from filelock import FileLock
1617
from packaging.requirements import Requirement
17-
from packaging.version import Version
1818

19-
from tox import __version__
2019
from tox.pytest import MonkeyPatch, TempPathFactory, ToxProjectCreator
2120

2221
if sys.version_info >= (3, 8): # pragma: no cover (py38+)
@@ -61,14 +60,11 @@ def _make_tox_wheel(
6160
pkg_builder: Callable[[Path, Path, list[str], bool], Path],
6261
) -> Path:
6362
with elapsed("acquire current tox wheel"): # takes around 3.2s on build
64-
package: Path | None = None
65-
if "TOX_PACKAGE" in os.environ:
66-
env_tox_pkg = Path(os.environ["TOX_PACKAGE"]) # pragma: no cover
67-
if env_tox_pkg.exists() and env_tox_pkg.suffix == ".whl": # pragma: no cover
68-
package = env_tox_pkg # pragma: no cover
69-
if package is None:
70-
# when we don't get a wheel path injected, build it (for example when running from an IDE)
71-
into = tmp_path_factory.mktemp("dist") # pragma: no cover
63+
into = tmp_path_factory.mktemp("dist") # pragma: no cover
64+
from tox.version import version_tuple
65+
66+
version = f"{version_tuple[0]}.{version_tuple[1]}.{version_tuple[2] +1}"
67+
with mock.patch.dict(os.environ, {"SETUPTOOLS_SCM_PRETEND_VERSION": version}):
7268
package = pkg_builder(into, Path(__file__).parents[1], ["wheel"], False) # pragma: no cover
7369
return package
7470

@@ -189,5 +185,4 @@ def test_provision_no_recreate_json(tox_project: ToxProjectCreator) -> None:
189185
assert msg in result.out
190186
with (project.path / "out.json").open() as file_handler:
191187
requires = json.load(file_handler)
192-
version = Version(__version__).base_version
193-
assert requires == {"minversion": version, "requires": ["p", f"tox>={version}"]}
188+
assert requires == {"minversion": "4.0", "requires": ["p", "tox>=4.0"]}

0 commit comments

Comments
 (0)