Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default tox min_version to 4.0 instead of current tox version #2613

Merged
merged 1 commit into from
Dec 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog/2613.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Default tox min_version to 4.0 instead of current tox version - by :user:`gaborbernat`.
10 changes: 2 additions & 8 deletions src/tox/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from tox.tox_env.errors import Skip
from tox.tox_env.python.pip.req_file import PythonDeps
from tox.tox_env.python.runner import PythonRun
from tox.version import version as current_version

if sys.version_info >= (3, 8): # pragma: no cover (py38+)
from importlib.metadata import PackageNotFoundError, distribution
Expand Down Expand Up @@ -63,7 +62,7 @@ def provision(state: State) -> int | bool:
keys=["min_version", "minversion"],
of_type=Version,
# do not include local version specifier (because it's not allowed in version spec per PEP-440)
default=Version(current_version),
default=Version("4.0"),
desc="Define the minimal tox version required to run",
)
state.conf.core.add_config(
Expand All @@ -75,12 +74,7 @@ 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}"))
requires.append(Requirement(f"tox >= {min_version}"))
return requires

state.conf.core.add_config(
Expand Down
19 changes: 7 additions & 12 deletions tests/test_provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
from pathlib import Path
from subprocess import check_call
from typing import Callable, Iterator
from unittest import mock
from zipfile import ZipFile

import pytest
from devpi_process import Index, IndexServer
from filelock import FileLock
from packaging.requirements import Requirement
from packaging.version import Version

from tox import __version__
from tox.pytest import MonkeyPatch, TempPathFactory, ToxProjectCreator

if sys.version_info >= (3, 8): # pragma: no cover (py38+)
Expand Down Expand Up @@ -61,14 +60,11 @@ def _make_tox_wheel(
pkg_builder: Callable[[Path, Path, list[str], bool], Path],
) -> Path:
with elapsed("acquire current tox wheel"): # takes around 3.2s on build
package: Path | None = None
if "TOX_PACKAGE" in os.environ:
env_tox_pkg = Path(os.environ["TOX_PACKAGE"]) # pragma: no cover
if env_tox_pkg.exists() and env_tox_pkg.suffix == ".whl": # pragma: no cover
package = env_tox_pkg # pragma: no cover
if package is None:
# when we don't get a wheel path injected, build it (for example when running from an IDE)
into = tmp_path_factory.mktemp("dist") # pragma: no cover
into = tmp_path_factory.mktemp("dist") # pragma: no cover
from tox.version import version_tuple

version = f"{version_tuple[0]}.{version_tuple[1]}.{version_tuple[2] +1}"
with mock.patch.dict(os.environ, {"SETUPTOOLS_SCM_PRETEND_VERSION": version}):
package = pkg_builder(into, Path(__file__).parents[1], ["wheel"], False) # pragma: no cover
return package

Expand Down Expand Up @@ -189,5 +185,4 @@ 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(__version__).base_version
assert requires == {"minversion": version, "requires": ["p", f"tox>={version}"]}
assert requires == {"minversion": "4.0", "requires": ["p", "tox>=4.0"]}