@@ -241,25 +241,6 @@ def setup_python(
241
241
# we version pip ourselves, so we don't care about pip version checking
242
242
env ["PIP_DISABLE_PIP_VERSION_CHECK" ] = "1"
243
243
244
- # upgrade pip to the version matching our constraints
245
- # if necessary, reinstall it to ensure that it's available on PATH as 'pip'
246
- if build_frontend == "build[uv]" :
247
- assert uv_path is not None
248
- pip = [str (uv_path ), "pip" ]
249
- else :
250
- pip = ["python" , "-m" , "pip" ]
251
-
252
- if not use_uv :
253
- call (
254
- * pip ,
255
- "install" ,
256
- "--upgrade" ,
257
- "pip" ,
258
- * constraint_flags (dependency_constraint ),
259
- env = env ,
260
- cwd = venv_path ,
261
- )
262
-
263
244
# Apply our environment after pip is ready
264
245
env = environment .as_dictionary (prev_environment = env )
265
246
@@ -434,8 +415,7 @@ def build(options: Options, tmp_path: Path) -> None:
434
415
build_options .environment ,
435
416
build_frontend .name ,
436
417
)
437
- if not use_uv :
438
- pip_version = get_pip_version (env )
418
+ pip_version = None if use_uv else get_pip_version (env )
439
419
440
420
compatible_wheel = find_compatible_wheel (built_wheels , config .identifier )
441
421
if compatible_wheel :
@@ -460,7 +440,7 @@ def build(options: Options, tmp_path: Path) -> None:
460
440
)
461
441
462
442
build_env = env .copy ()
463
- if not use_uv :
443
+ if pip_version is not None :
464
444
build_env ["VIRTUALENV_PIP" ] = pip_version
465
445
if constraints_path :
466
446
combine_constraints (
@@ -614,19 +594,6 @@ def build(options: Options, tmp_path: Path) -> None:
614
594
else f"Testing wheel on { testing_arch } ..."
615
595
)
616
596
617
- # set up a virtual environment to install and test from, to make sure
618
- # there are no dependencies that were pulled in at build time.
619
- if not use_uv :
620
- call (
621
- "pip" ,
622
- "install" ,
623
- "virtualenv" ,
624
- * constraint_flags (constraints_path ),
625
- env = env ,
626
- )
627
-
628
- venv_dir = identifier_tmp_dir / f"venv-test-{ testing_arch } "
629
-
630
597
arch_prefix = []
631
598
uv_arch_args = []
632
599
if testing_arch != machine_arch :
@@ -642,29 +609,24 @@ def build(options: Options, tmp_path: Path) -> None:
642
609
call_with_arch = functools .partial (call , * arch_prefix )
643
610
shell_with_arch = functools .partial (call , * arch_prefix , "/bin/sh" , "-c" )
644
611
612
+ # set up a virtual environment to install and test from, to make sure
613
+ # there are no dependencies that were pulled in at build time.
614
+ venv_dir = identifier_tmp_dir / f"venv-test-{ testing_arch } "
615
+ virtualenv_env = virtualenv (
616
+ config .version ,
617
+ base_python ,
618
+ venv_dir ,
619
+ None ,
620
+ use_uv = use_uv ,
621
+ env = env ,
622
+ pip_version = pip_version ,
623
+ )
645
624
if use_uv :
646
625
pip_install = functools .partial (call , * pip , "install" , * uv_arch_args )
647
- call ("uv" , "venv" , venv_dir , f"--python={ base_python } " , env = env )
648
626
else :
649
627
pip_install = functools .partial (call_with_arch , * pip , "install" )
650
- # Use pip version from the initial env to ensure determinism
651
- venv_args = [
652
- "--no-periodic-update" ,
653
- f"--pip={ pip_version } " ,
654
- "--no-setuptools" ,
655
- "--no-wheel" ,
656
- ]
657
- call_with_arch ("python" , "-m" , "virtualenv" , * venv_args , venv_dir , env = env )
658
-
659
- virtualenv_env = env .copy ()
628
+
660
629
virtualenv_env ["MACOSX_DEPLOYMENT_TARGET" ] = get_test_macosx_deployment_target ()
661
- virtualenv_env ["PATH" ] = os .pathsep .join (
662
- [
663
- str (venv_dir / "bin" ),
664
- virtualenv_env ["PATH" ],
665
- ]
666
- )
667
- virtualenv_env ["VIRTUAL_ENV" ] = str (venv_dir )
668
630
669
631
# check that we are using the Python from the virtual environment
670
632
call_with_arch ("which" , "python" , env = virtualenv_env )
0 commit comments