Skip to content

Commit

Permalink
Improve egg_info isolation in test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Apr 28, 2023
1 parent 90bc19f commit 3449da1
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions setuptools/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=extra_setupcfg):
subprocess.check_call([
sys.executable, "-m", "build", "--sdist",
"--outdir", str(tmp), str(request.config.rootdir)
])
return next(tmp.glob("*.tar.gz"))


Expand All @@ -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=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"""
Expand Down

0 comments on commit 3449da1

Please sign in to comment.