Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog/2414.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid impossible minversion version requirements. - by :user:`ssbarnea`.
5 changes: 5 additions & 0 deletions src/tox/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ def provision(state: State) -> int | bool:

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

Expand Down
4 changes: 3 additions & 1 deletion tests/test_provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import pytest
from filelock import FileLock
from packaging.requirements import Requirement
from packaging.version import Version

from tox import __version__
from tox.pytest import Index, IndexServer, MonkeyPatch, TempPathFactory, ToxProjectCreator
Expand Down Expand Up @@ -188,5 +189,6 @@ def test_provision_no_recreate_json(tox_project: ToxProjectCreator) -> None:
assert msg in result.out
with (project.path / "out.json").open() as file_handler:
requires = json.load(file_handler)
version = __version__.split("+")[0]
# __version__ could be something like 4.0.0rc1.dev1+? so we still need to sanitize it to keep the base and add "a0"
version = f"{Version(__version__).base_version}a0"
assert requires == {"minversion": version, "requires": ["p", f"tox>={version}"]}
5 changes: 5 additions & 0 deletions whitelist.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
0rc1
0x3
10ms
1s
2s
5s
a0
abi
addinivalue
addnodes
Expand Down Expand Up @@ -48,9 +50,11 @@ dep
deps
desc
dest
dev1
devenv
devnull
devpi
devrelease
dirname
distinfo
distlib
Expand Down Expand Up @@ -152,6 +156,7 @@ pos
posargs
posix
prepend
prerelease
prereleases
prj
prog
Expand Down