Skip to content

Commit ad26222

Browse files
committed
Fix build directories interference with auto-discovery (#3704)
2 parents 8f2cf58 + 9a020ce commit ad26222

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

changelog.d/3704.misc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix temporary build directories interference with auto-discovery.

setuptools/build_meta.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ def _build_with_temp_dir(self, setup_command, result_extension,
385385

386386
# Build in a temporary directory, then copy to the target.
387387
os.makedirs(result_directory, exist_ok=True)
388-
with tempfile.TemporaryDirectory(dir=result_directory) as tmp_dist_dir:
388+
temp_opts = {"prefix": ".tmp-", "dir": result_directory}
389+
with tempfile.TemporaryDirectory(**temp_opts) as tmp_dist_dir:
389390
sys.argv = [
390391
*sys.argv[:1],
391392
*self._global_args(config_settings),

setuptools/tests/test_config_discovery.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,19 @@ def test_flat_layout_with_multiple_modules(self, tmp_path):
248248
with pytest.raises(PackageDiscoveryError, match="multiple (packages|modules)"):
249249
_get_dist(tmp_path, {})
250250

251+
def test_py_modules_when_wheel_dir_is_cwd(self, tmp_path):
252+
"""Regression for issue 3692"""
253+
from setuptools import build_meta
254+
255+
pyproject = '[project]\nname = "test"\nversion = "1"'
256+
(tmp_path / "pyproject.toml").write_text(DALS(pyproject), encoding="utf-8")
257+
(tmp_path / "foo.py").touch()
258+
with jaraco.path.DirectoryStack().context(tmp_path):
259+
build_meta.build_wheel(".")
260+
# Ensure py_modules are found
261+
wheel_files = get_wheel_members(next(tmp_path.glob("*.whl")))
262+
assert "foo.py" in wheel_files
263+
251264

252265
class TestNoConfig:
253266
DEFAULT_VERSION = "0.0.0" # Default version given by setuptools

0 commit comments

Comments
 (0)