@@ -408,17 +408,19 @@ def test_editable_with_prefix(tmp_path, sample_project, editable_opts):
408
408
prefix = tmp_path / 'prefix'
409
409
410
410
# figure out where pip will likely install the package
411
- site_packages = prefix / next (
412
- Path (path ).relative_to (sys .prefix )
411
+ site_packages_all = [
412
+ prefix / Path (path ).relative_to (sys .prefix )
413
413
for path in sys .path
414
414
if 'site-packages' in path and path .startswith (sys .prefix )
415
- )
416
- site_packages .mkdir (parents = True )
415
+ ]
416
+
417
+ for sp in site_packages_all :
418
+ sp .mkdir (parents = True )
417
419
418
420
# install workaround
419
- _addsitedir ( site_packages )
421
+ _addsitedirs ( site_packages_all )
420
422
421
- env = dict (os .environ , PYTHONPATH = str ( site_packages ))
423
+ env = dict (os .environ , PYTHONPATH = os . pathsep . join ( map ( str , site_packages_all ) ))
422
424
cmd = [
423
425
sys .executable ,
424
426
'-m' ,
@@ -1250,14 +1252,17 @@ def install_project(name, venv, tmp_path, files, *opts):
1250
1252
return project , out
1251
1253
1252
1254
1253
- def _addsitedir ( new_dir : Path ):
1255
+ def _addsitedirs ( new_dirs ):
1254
1256
"""To use this function, it is necessary to insert new_dir in front of sys.path.
1255
1257
The Python process will try to import a ``sitecustomize`` module on startup.
1256
1258
If we manipulate sys.path/PYTHONPATH, we can force it to run our code,
1257
1259
which invokes ``addsitedir`` and ensure ``.pth`` files are loaded.
1258
1260
"""
1259
- file = f"import site; site.addsitedir({ os .fspath (new_dir )!r} )\n "
1260
- (new_dir / "sitecustomize.py" ).write_text (file , encoding = "utf-8" )
1261
+ content = '\n ' .join (
1262
+ ("import site" ,)
1263
+ + tuple (f"site.addsitedir({ os .fspath (new_dir )!r} )" for new_dir in new_dirs )
1264
+ )
1265
+ (new_dirs [0 ] / "sitecustomize.py" ).write_text (content , encoding = "utf-8" )
1261
1266
1262
1267
1263
1268
# ---- Assertion Helpers ----
0 commit comments