Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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 @@ -90,6 +90,7 @@ test = [
"flaky>=3.8.1",
"hatch-vcs>=0.4",
"hatchling>=1.27",
"pdm-backend",
"psutil>=6.1.1",
"pytest>=8.3.4",
"pytest-cov>=5",
Expand Down
11 changes: 9 additions & 2 deletions src/tox/tox_env/python/virtual_env/package/pyproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,15 @@ def root(self) -> Path:

@root.setter
def root(self, value: Path) -> None:
self._root = value
self._frontend_ = None # force recreating the frontend with new root
# NOTE(vytas): Recreating the frontend with a new root will orphan the
# current frontend.backend_executor, if any, making tox hang upon
# exit waiting for its threads and subprocesses (#3512).
#
# Here, we partially work around the issue by only resetting the root
# when it has actually changed:
if self._root != value:
self._root = value
self._frontend_ = None # force recreating the frontend with new root

@staticmethod
def id() -> str:
Expand Down
38 changes: 38 additions & 0 deletions tests/tox_env/python/virtual_env/package/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,41 @@ def pkg_with_extras_project(tmp_path_factory: pytest.TempPathFactory) -> Path:
toml = '[build-system]\nrequires=["setuptools", "wheel"]\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 @@ -458,3 +458,27 @@ 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_aaa_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), "--exit-and-dump-after", "10")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This --exit-and-dump-after should be increased to something larger (like 120) once I iron out the tests.

result.assert_success()
Loading