@@ -408,17 +408,19 @@ def test_editable_with_prefix(tmp_path, sample_project, editable_opts):
408408 prefix = tmp_path / 'prefix'
409409
410410 # 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 )
413413 for path in sys .path
414414 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 )
417419
418420 # install workaround
419- _addsitedir ( site_packages )
421+ _addsitedirs ( site_packages_all )
420422
421- env = dict (os .environ , PYTHONPATH = str ( site_packages ))
423+ env = dict (os .environ , PYTHONPATH = os . pathsep . join ( map ( str , site_packages_all ) ))
422424 cmd = [
423425 sys .executable ,
424426 '-m' ,
@@ -1250,14 +1252,17 @@ def install_project(name, venv, tmp_path, files, *opts):
12501252 return project , out
12511253
12521254
1253- def _addsitedir ( new_dir : Path ):
1255+ def _addsitedirs ( new_dirs ):
12541256 """To use this function, it is necessary to insert new_dir in front of sys.path.
12551257 The Python process will try to import a ``sitecustomize`` module on startup.
12561258 If we manipulate sys.path/PYTHONPATH, we can force it to run our code,
12571259 which invokes ``addsitedir`` and ensure ``.pth`` files are loaded.
12581260 """
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" )
12611266
12621267
12631268# ---- Assertion Helpers ----
0 commit comments