@@ -396,29 +396,26 @@ def test_namespace_accidental_config_in_lenient_mode(self, venv, tmp_path):
396
396
assert "mypkg.other not defined" in out
397
397
398
398
399
- # Moved here from test_develop:
400
- @pytest .mark .xfail (
401
- platform .python_implementation () == 'PyPy' ,
402
- reason = "Workaround fails on PyPy (why?)" ,
403
- )
404
399
def test_editable_with_prefix (tmp_path , sample_project , editable_opts ):
405
400
"""
406
401
Editable install to a prefix should be discoverable.
407
402
"""
408
403
prefix = tmp_path / 'prefix'
409
404
410
405
# 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 )
413
408
for path in sys .path
414
409
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 )
417
414
418
415
# install workaround
419
- _addsitedir ( site_packages )
416
+ _addsitedirs ( site_packages_all )
420
417
421
- env = dict (os .environ , PYTHONPATH = str ( site_packages ))
418
+ env = dict (os .environ , PYTHONPATH = os . pathsep . join ( map ( str , site_packages_all ) ))
422
419
cmd = [
423
420
sys .executable ,
424
421
'-m' ,
@@ -1250,14 +1247,17 @@ def install_project(name, venv, tmp_path, files, *opts):
1250
1247
return project , out
1251
1248
1252
1249
1253
- def _addsitedir ( new_dir : Path ):
1250
+ def _addsitedirs ( new_dirs ):
1254
1251
"""To use this function, it is necessary to insert new_dir in front of sys.path.
1255
1252
The Python process will try to import a ``sitecustomize`` module on startup.
1256
1253
If we manipulate sys.path/PYTHONPATH, we can force it to run our code,
1257
1254
which invokes ``addsitedir`` and ensure ``.pth`` files are loaded.
1258
1255
"""
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" )
1261
1261
1262
1262
1263
1263
# ---- Assertion Helpers ----
0 commit comments