Skip to content

Commit

Permalink
Fix build directories interference with auto-discovery (#3704)
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Nov 23, 2022
2 parents 8f2cf58 + 9a020ce commit ad26222
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/3704.misc.rst
@@ -0,0 +1 @@
Fix temporary build directories interference with auto-discovery.
3 changes: 2 additions & 1 deletion setuptools/build_meta.py
Expand Up @@ -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),
Expand Down
13 changes: 13 additions & 0 deletions setuptools/tests/test_config_discovery.py
Expand Up @@ -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
Expand Down

0 comments on commit ad26222

Please sign in to comment.