Skip to content

Commit a873888

Browse files
committed
Merge branch 'main' into vendored-wheel
2 parents 92a3310 + 6c1ef57 commit a873888

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

setuptools/tests/test_editable_install.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -396,29 +396,26 @@ def test_namespace_accidental_config_in_lenient_mode(self, venv, tmp_path):
396396
assert "mypkg.other not defined" in out
397397

398398

399-
# Moved here from test_develop:
400-
@pytest.mark.xfail(
401-
platform.python_implementation() == 'PyPy',
402-
reason="Workaround fails on PyPy (why?)",
403-
)
404399
def test_editable_with_prefix(tmp_path, sample_project, editable_opts):
405400
"""
406401
Editable install to a prefix should be discoverable.
407402
"""
408403
prefix = tmp_path / 'prefix'
409404

410405
# figure out where pip will likely install the package
411-
site_packages = prefix / next(
412-
Path(path).relative_to(sys.prefix)
406+
site_packages_all = [
407+
prefix / Path(path).relative_to(sys.prefix)
413408
for path in sys.path
414409
if 'site-packages' in path and path.startswith(sys.prefix)
415-
)
416-
site_packages.mkdir(parents=True)
410+
]
411+
412+
for sp in site_packages_all:
413+
sp.mkdir(parents=True)
417414

418415
# install workaround
419-
_addsitedir(site_packages)
416+
_addsitedirs(site_packages_all)
420417

421-
env = dict(os.environ, PYTHONPATH=str(site_packages))
418+
env = dict(os.environ, PYTHONPATH=os.pathsep.join(map(str, site_packages_all)))
422419
cmd = [
423420
sys.executable,
424421
'-m',
@@ -1250,14 +1247,17 @@ def install_project(name, venv, tmp_path, files, *opts):
12501247
return project, out
12511248

12521249

1253-
def _addsitedir(new_dir: Path):
1250+
def _addsitedirs(new_dirs):
12541251
"""To use this function, it is necessary to insert new_dir in front of sys.path.
12551252
The Python process will try to import a ``sitecustomize`` module on startup.
12561253
If we manipulate sys.path/PYTHONPATH, we can force it to run our code,
12571254
which invokes ``addsitedir`` and ensure ``.pth`` files are loaded.
12581255
"""
1259-
file = f"import site; site.addsitedir({os.fspath(new_dir)!r})\n"
1260-
(new_dir / "sitecustomize.py").write_text(file, encoding="utf-8")
1256+
content = '\n'.join(
1257+
("import site",)
1258+
+ tuple(f"site.addsitedir({os.fspath(new_dir)!r})" for new_dir in new_dirs)
1259+
)
1260+
(new_dirs[0] / "sitecustomize.py").write_text(content, encoding="utf-8")
12611261

12621262

12631263
# ---- Assertion Helpers ----

0 commit comments

Comments
 (0)