Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bdc2bc2
Fix Tox hanging with --installpkg sdist due to orphaned build backend.
vytas7 May 12, 2025
3220551
Fix swapped characters.
vytas7 May 12, 2025
356525f
Merge branch 'main' into 3512-hangs-on-installpkg-sdist
gaborbernat May 12, 2025
ed31344
Merge branch 'main' into 3512-hangs-on-installpkg-sdist
vytas7 May 13, 2025
6859b3b
Merge branch 'main' into 3512-hangs-on-installpkg-sdist
vytas7 May 13, 2025
5a83a44
Merge branch 'main' into 3512-hangs-on-installpkg-sdist
vytas7 May 13, 2025
d3e23c9
Add a Towncrier newsfragment.
vytas7 May 13, 2025
4ff3fcc
Add an integration test exercising the scenario from #3512.
vytas7 May 13, 2025
99adb4c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 13, 2025
735c891
Address issues found in static code analysis.
vytas7 May 13, 2025
6539415
Undo debugging changes.
vytas7 May 13, 2025
6708d1d
Fix a typing PEBCAK.
vytas7 May 13, 2025
8e02c54
Merge branch 'main' into 3512-hangs-on-installpkg-sdist
vytas7 May 14, 2025
3336289
Merge branch 'main' into 3512-hangs-on-installpkg-sdist
gaborbernat Sep 2, 2025
bfb34a5
Remove `--exit-and-dump-after` as it may be killing the suite itself.
vytas7 Sep 2, 2025
89f5ff7
Merge branch 'main' into 3512-hangs-on-installpkg-sdist
vytas7 Sep 2, 2025
79f3ec6
Wrap newsfragment lines at 120 characters.
vytas7 Sep 2, 2025
409b946
Explicitly close down the existing PEP 517 frontend when resetting root.
vytas7 Sep 2, 2025
85f6b69
Remove debugging leftovers from a test case name.
vytas7 Sep 2, 2025
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
3 changes: 3 additions & 0 deletions docs/changelog/3530.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Prevent tox from hanging upon exit due to orphaned build threads and subprocesses when the ``--installpkg`` option is
used with *sdist*.
- by :user:`vytas7`
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ test = [
"flaky>=3.8.1",
"hatch-vcs>=0.5",
"hatchling>=1.27",
"pdm-backend",
"psutil>=7",
"pytest>=8.4.1",
"pytest-cov>=6.2.1",
Expand Down
6 changes: 6 additions & 0 deletions src/tox/tox_env/python/virtual_env/package/pyproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ def root(self) -> Path:

@root.setter
def root(self, value: Path) -> None:
# Recreating the frontend with a new root would orphan the current frontend.backend_executor, if any, making tox
# hang upon exit waiting for its threads and subprocesses (#3512).
# Therefore, we make sure to close the existing back-end executor in the case of an existing PEP 517 frontend.
if self._frontend is not None:
self._frontend.backend_executor.close()

self._root = value
self._frontend_ = None # force recreating the frontend with new root

Expand Down
40 changes: 39 additions & 1 deletion tests/tox_env/python/virtual_env/package/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys
from textwrap import dedent
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Callable

import pytest

Expand Down Expand Up @@ -41,3 +41,41 @@ def pkg_with_extras_project(tmp_path_factory: pytest.TempPathFactory) -> Path:
toml = '[build-system]\nrequires=["setuptools"]\nbuild-backend = "setuptools.build_meta"'
(tmp_path / "pyproject.toml").write_text(toml)
return tmp_path


@pytest.fixture(scope="session")
def pkg_with_pdm_backend(
tmp_path_factory: pytest.TempPathFactory,
pkg_builder: Callable[[Path, Path, list[str], bool], Path],
) -> Path:
tmp_path = tmp_path_factory.mktemp("skeleton")

pyproject_toml = """
[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[project]
name = "skeleton"
description = "Just a skeleton for reproducing #3512."
version = "0.1.1337"
dependencies = [
"requests",
]

[tool.pdm.build]
includes = [
"skeleton/",
]
source-includes = [
"tox.ini",
]
"""
(tmp_path / "pyproject.toml").write_text(dedent(pyproject_toml))
(tmp_path / "skeleton").mkdir(exist_ok=True)
(tmp_path / "skeleton" / "__init__.py").touch()

dist = tmp_path / "dist"
pkg_builder(dist, tmp_path, ["sdist"], False)

return tmp_path
Original file line number Diff line number Diff line change
Expand Up @@ -464,3 +464,24 @@ def test_pyproject_config_settings_editable_legacy(
"get_requires_for_build_wheel": {"C": "3"},
"prepare_metadata_for_build_wheel": {"D": "4"},
}


@pytest.mark.usefixtures("enable_pip_pypi_access")
def test_pyproject_installpkg_pep517_envs(tox_project: ToxProjectCreator, pkg_with_pdm_backend: Path) -> None:
# Regression test for #3512
tox_ini = """
[tox]
envlist = dummy1,dummy2

[testenv:dummy1]
commands =
python -c print(1)

[testenv:dummy2]
commands =
python -c print(42)
"""
sdist = pkg_with_pdm_backend / "dist" / "skeleton-0.1.1337.tar.gz"
proj = tox_project({"tox.ini": tox_ini}, base=pkg_with_pdm_backend)
result = proj.run("--installpkg", str(sdist))
result.assert_success()