@@ -376,6 +376,36 @@ def not_code_files_and_folders(path: str, names: List[str]) -> Iterable[str]:
376
376
return pip_src
377
377
378
378
379
+ @pytest .fixture (scope = "session" )
380
+ def pip_editable_parts (
381
+ pip_src : Path , tmpdir_factory : pytest .TempPathFactory
382
+ ) -> Tuple [Path , ...]:
383
+ pip_editable = tmpdir_factory .mktemp ("pip" ) / "pip"
384
+ shutil .copytree (pip_src , pip_editable , symlinks = True )
385
+ # noxfile.py is Python 3 only
386
+ assert compileall .compile_dir (
387
+ pip_editable ,
388
+ quiet = 1 ,
389
+ rx = re .compile ("noxfile.py$" ),
390
+ )
391
+ pip_self_install_path = tmpdir_factory .mktemp ("pip_self_install" )
392
+ subprocess .check_call (
393
+ [
394
+ sys .executable ,
395
+ "-m" ,
396
+ "pip" ,
397
+ "install" ,
398
+ "--target" ,
399
+ pip_self_install_path ,
400
+ "-e" ,
401
+ pip_editable ,
402
+ ]
403
+ )
404
+ pth = next (pip_self_install_path .glob ("*pip*.pth" ))
405
+ dist_info = next (pip_self_install_path .glob ("*.dist-info" ))
406
+ return (pth , dist_info )
407
+
408
+
379
409
def _common_wheel_editable_install (
380
410
tmpdir_factory : pytest .TempPathFactory , common_wheels : Path , package : str
381
411
) -> Path :
@@ -439,6 +469,7 @@ def virtualenv_template(
439
469
request : pytest .FixtureRequest ,
440
470
tmpdir_factory : pytest .TempPathFactory ,
441
471
pip_src : Path ,
472
+ pip_editable_parts : Tuple [Path , ...],
442
473
setuptools_install : Path ,
443
474
wheel_install : Path ,
444
475
coverage_install : Path ,
@@ -456,17 +487,17 @@ def virtualenv_template(
456
487
# Install setuptools, wheel and pip.
457
488
install_pth_link (venv , "setuptools" , setuptools_install )
458
489
install_pth_link (venv , "wheel" , wheel_install )
459
- pip_editable = tmpdir_factory .mktemp ("pip" ) / "pip"
460
- shutil .copytree (pip_src , pip_editable , symlinks = True )
461
- # noxfile.py is Python 3 only
462
- assert compileall .compile_dir (
463
- str (pip_editable ),
464
- quiet = 1 ,
465
- rx = re .compile ("noxfile.py$" ),
466
- )
467
- subprocess .check_call (
468
- [os .fspath (venv .bin / "python" ), "setup.py" , "-q" , "develop" ], cwd = pip_editable
490
+
491
+ pth , dist_info = pip_editable_parts
492
+
493
+ shutil .copy (pth , venv .site )
494
+ shutil .copytree (
495
+ dist_info , venv .site / dist_info .name , dirs_exist_ok = True , symlinks = True
469
496
)
497
+ # Create placeholder ``easy-install.pth``, as several tests depend on its
498
+ # existance. TODO: Ensure ``tests.lib.TestPipResult.files_updated`` correctly
499
+ # detects changed files.
500
+ venv .site .joinpath ("easy-install.pth" ).touch ()
470
501
471
502
# Install coverage and pth file for executing it in any spawned processes
472
503
# in this virtual environment.
0 commit comments