From 5ea025072f16455b7b755cbf9d1e045047e0f313 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 28 Apr 2023 12:52:07 +0100 Subject: [PATCH] Improve egg_info isolation in test fixtures --- setuptools/tests/fixtures.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/setuptools/tests/fixtures.py b/setuptools/tests/fixtures.py index f1cfc66c81..9599d561c5 100644 --- a/setuptools/tests/fixtures.py +++ b/setuptools/tests/fixtures.py @@ -75,10 +75,12 @@ def setuptools_sdist(tmp_path_factory, request): if dist: return dist - subprocess.check_call([ - sys.executable, "-m", "build", "--sdist", - "--outdir", str(tmp), str(request.config.rootdir) - ]) + extra_setupcfg = _setupcfg_for_egginfo_isolation(tmp) + with contexts.environment(DIST_EXTRA_CONFIG=str(extra_setupcfg)): + subprocess.check_call([ + sys.executable, "-m", "build", "--sdist", + "--outdir", str(tmp), str(request.config.rootdir) + ]) return next(tmp.glob("*.tar.gz")) @@ -93,13 +95,22 @@ def setuptools_wheel(tmp_path_factory, request): if dist: return dist - subprocess.check_call([ - sys.executable, "-m", "build", "--wheel", - "--outdir", str(tmp) , str(request.config.rootdir) - ]) + extra_setupcfg = _setupcfg_for_egginfo_isolation(tmp) + with contexts.environment(DIST_EXTRA_CONFIG=str(extra_setupcfg)): + subprocess.check_call([ + sys.executable, "-m", "build", "--wheel", + "--outdir", str(tmp) , str(request.config.rootdir) + ]) return next(tmp.glob("*.whl")) +def _setupcfg_for_egginfo_isolation(tmp_path): + # TODO: Remove this workaround when `build_meta` isolation is more reliable + file = Path(tmp_path, "setup.cfg") + file.write_text(f"[egg_info]\negg_base={tmp_path}", encoding="utf-8") + return file + + @pytest.fixture def venv(tmp_path, setuptools_wheel): """Virtual env with the version of setuptools under test installed"""