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

fix skip with package = wheel #3269

Merged
merged 10 commits into from Apr 27, 2024
1 change: 1 addition & 0 deletions docs/changelog/3269.feature.rst
@@ -0,0 +1 @@
Fix ``skip_missing_interpreters`` option for ``package = wheel``
7 changes: 6 additions & 1 deletion src/tox/tox_env/python/package.py
Expand Up @@ -120,7 +120,12 @@ def default_wheel_tag(conf: Config, env_name: str | None) -> str: # noqa: ARG00

def child_pkg_envs(self, run_conf: EnvConfigSet) -> Iterator[PackageToxEnv]:
if run_conf["package"] == "wheel":
env = self._wheel_build_envs.get(run_conf["wheel_build_env"])
try:
conf = run_conf["wheel_build_env"]
except Skip:
# the __getitem__ method might raise Skip if the interpreter is not available
return
env = self._wheel_build_envs.get(conf)
if env is not None and env.name != self.name:
yield env

Expand Down
51 changes: 47 additions & 4 deletions tests/session/cmd/test_depends.py
Expand Up @@ -8,7 +8,7 @@
from tox.pytest import ToxProjectCreator


def test_depends(tox_project: ToxProjectCreator, patch_prev_py: Callable[[bool], tuple[str, str]]) -> None:
def test_depends_wheel(tox_project: ToxProjectCreator, patch_prev_py: Callable[[bool], tuple[str, str]]) -> None:
prev_ver, impl = patch_prev_py(True) # has previous python
ver = sys.version_info[0:2]
py = f"py{''.join(str(i) for i in ver)}"
Expand All @@ -35,18 +35,61 @@ def test_depends(tox_project: ToxProjectCreator, patch_prev_py: Callable[[bool],
py ~ .pkg
{py} ~ .pkg
{prev_py} ~ .pkg | .pkg-{impl}{prev_ver}
py31 ~ .pkg | ... (could not find python interpreter with spec(s): py31)
py31 ~ .pkg
cov2
cov
py ~ .pkg
{py} ~ .pkg
{prev_py} ~ .pkg | .pkg-{impl}{prev_ver}
py31 ~ .pkg | ... (could not find python interpreter with spec(s): py31)
py31 ~ .pkg
cov
py ~ .pkg
{py} ~ .pkg
{prev_py} ~ .pkg | .pkg-{impl}{prev_ver}
py31 ~ .pkg | ... (could not find python interpreter with spec(s): py31)
py31 ~ .pkg
"""
assert outcome.out == dedent(expected).lstrip()


def test_depends_sdist(tox_project: ToxProjectCreator, patch_prev_py: Callable[[bool], tuple[str, str]]) -> None:
prev_ver, _impl = patch_prev_py(True) # has previous python
ver = sys.version_info[0:2]
py = f"py{''.join(str(i) for i in ver)}"
prev_py = f"py{prev_ver}"
ini = f"""
[tox]
env_list = py,{py},{prev_py},py31,cov2,cov
[testenv]
package = sdist
[testenv:cov]
depends = py,{py},{prev_py},py31
skip_install = true
[testenv:cov2]
depends = cov
skip_install = true
"""
project = tox_project({"tox.ini": ini, "pyproject.toml": ""})
outcome = project.run("de")
outcome.assert_success()

expected = f"""
Execution order: py, {py}, {prev_py}, py31, cov, cov2
ALL
py ~ .pkg
{py} ~ .pkg
{prev_py} ~ .pkg
py31 ~ .pkg
cov2
cov
py ~ .pkg
{py} ~ .pkg
{prev_py} ~ .pkg
py31 ~ .pkg
cov
py ~ .pkg
{py} ~ .pkg
{prev_py} ~ .pkg
py31 ~ .pkg
"""
assert outcome.out == dedent(expected).lstrip()

Expand Down
8 changes: 7 additions & 1 deletion tests/test_provision.py
Expand Up @@ -62,7 +62,13 @@ def _make_tox_wheel(
into = tmp_path_factory.mktemp("dist") # pragma: no cover
from tox.version import version_tuple # noqa: PLC0415

version = f"{version_tuple[0]}.{version_tuple[1]}.{int(version_tuple[2]) + 1}"
_patch_version = version_tuple[2]
if isinstance(_patch_version, str) and _patch_version[:3] == "dev":
# Version is in the form of 1.23.dev456, we need to increment the 456 part
version = f"{version_tuple[0]}.{version_tuple[1]}.dev{int(_patch_version[3:]) + 1}"
else:
version = f"{version_tuple[0]}.{version_tuple[1]}.{int(_patch_version) + 1}"

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

Expand Down