@@ -407,6 +407,28 @@ def build(options: Options, tmp_path: Path) -> None:
407
407
)
408
408
extra_flags += build_frontend .args
409
409
410
+ build_env = env .copy ()
411
+ build_env ["VIRTUALENV_PIP" ] = get_pip_version (env )
412
+ if build_options .dependency_constraints :
413
+ constraints_path = build_options .dependency_constraints .get_for_python_version (
414
+ config .version
415
+ )
416
+ # Bug in pip <= 21.1.3 - we can't have a space in the
417
+ # constraints file, and pip doesn't support drive letters
418
+ # in uhi. After probably pip 21.2, we can use uri. For
419
+ # now, use a temporary file.
420
+ if " " in str (constraints_path ):
421
+ assert " " not in str (identifier_tmp_dir )
422
+ tmp_file = identifier_tmp_dir / "constraints.txt"
423
+ tmp_file .write_bytes (constraints_path .read_bytes ())
424
+ constraints_path = tmp_file
425
+
426
+ our_constraints = str (constraints_path )
427
+ user_constraints = build_env .get ("PIP_CONSTRAINT" )
428
+ build_env ["PIP_CONSTRAINT" ] = " " .join (
429
+ c for c in [our_constraints , user_constraints ] if c
430
+ )
431
+
410
432
if build_frontend .name == "pip" :
411
433
extra_flags += get_build_verbosity_extra_flags (build_options .build_verbosity )
412
434
# Path.resolve() is needed. Without it pip wheel may try to fetch package from pypi.org
@@ -420,46 +442,22 @@ def build(options: Options, tmp_path: Path) -> None:
420
442
f"--wheel-dir={ built_wheel_dir } " ,
421
443
"--no-deps" ,
422
444
* extra_flags ,
423
- env = env ,
445
+ env = build_env ,
424
446
)
425
447
elif build_frontend .name == "build" :
426
448
if not 0 <= build_options .build_verbosity < 2 :
427
449
msg = f"build_verbosity { build_options .build_verbosity } is not supported for build frontend. Ignoring."
428
450
log .warning (msg )
429
- build_env = env .copy ()
430
- if build_options .dependency_constraints :
431
- constraints_path = (
432
- build_options .dependency_constraints .get_for_python_version (
433
- config .version
434
- )
435
- )
436
- # Bug in pip <= 21.1.3 - we can't have a space in the
437
- # constraints file, and pip doesn't support drive letters
438
- # in uhi. After probably pip 21.2, we can use uri. For
439
- # now, use a temporary file.
440
- if " " in str (constraints_path ):
441
- assert " " not in str (identifier_tmp_dir )
442
- tmp_file = identifier_tmp_dir / "constraints.txt"
443
- tmp_file .write_bytes (constraints_path .read_bytes ())
444
- constraints_path = tmp_file
445
-
446
- our_constraints = str (constraints_path )
447
- user_constraints = build_env .get ("PIP_CONSTRAINT" )
448
- build_env ["PIP_CONSTRAINT" ] = " " .join (
449
- c for c in [our_constraints , user_constraints ] if c
450
- )
451
-
452
- build_env ["VIRTUALENV_PIP" ] = get_pip_version (env )
453
- call (
454
- "python" ,
455
- "-m" ,
456
- "build" ,
457
- build_options .package_dir ,
458
- "--wheel" ,
459
- f"--outdir={ built_wheel_dir } " ,
460
- * extra_flags ,
461
- env = build_env ,
462
- )
451
+ call (
452
+ "python" ,
453
+ "-m" ,
454
+ "build" ,
455
+ build_options .package_dir ,
456
+ "--wheel" ,
457
+ f"--outdir={ built_wheel_dir } " ,
458
+ * extra_flags ,
459
+ env = build_env ,
460
+ )
463
461
else :
464
462
assert_never (build_frontend )
465
463
0 commit comments