diff --git a/setuptools/build_meta.py b/setuptools/build_meta.py index e8f1c72d59..1fb4c3b108 100644 --- a/setuptools/build_meta.py +++ b/setuptools/build_meta.py @@ -385,7 +385,8 @@ def _build_with_temp_dir(self, setup_command, result_extension, # Build in a temporary directory, then copy to the target. os.makedirs(result_directory, exist_ok=True) - with tempfile.TemporaryDirectory(dir=result_directory) as tmp_dist_dir: + temp_opts = {"prefix": ".tmp-", "dir": result_directory} + with tempfile.TemporaryDirectory(**temp_opts) as tmp_dist_dir: sys.argv = [ *sys.argv[:1], *self._global_args(config_settings), diff --git a/setuptools/tests/test_config_discovery.py b/setuptools/tests/test_config_discovery.py index 85b64b31dd..f65b00b61f 100644 --- a/setuptools/tests/test_config_discovery.py +++ b/setuptools/tests/test_config_discovery.py @@ -248,6 +248,19 @@ def test_flat_layout_with_multiple_modules(self, tmp_path): with pytest.raises(PackageDiscoveryError, match="multiple (packages|modules)"): _get_dist(tmp_path, {}) + def test_py_modules_when_wheel_dir_is_cwd(self, tmp_path): + """Regression for issue 3692""" + from setuptools import build_meta + + pyproject = '[project]\nname = "test"\nversion = "1"' + (tmp_path / "pyproject.toml").write_text(DALS(pyproject), encoding="utf-8") + (tmp_path / "foo.py").touch() + with jaraco.path.DirectoryStack().context(tmp_path): + build_meta.build_wheel(".") + # Ensure py_modules are found + wheel_files = get_wheel_members(next(tmp_path.glob("*.whl"))) + assert "foo.py" in wheel_files + class TestNoConfig: DEFAULT_VERSION = "0.0.0" # Default version given by setuptools