3
3
import shutil
4
4
import subprocess
5
5
import textwrap
6
- from collections .abc import MutableMapping , Sequence , Set
6
+ from collections .abc import MutableMapping , Set
7
7
from dataclasses import dataclass
8
8
from functools import cache
9
9
from pathlib import Path
18
18
from ..logger import log
19
19
from ..options import Options
20
20
from ..selector import BuildSelector
21
- from ..typing import PathOrStr
22
21
from ..util import resources
23
22
from ..util .cmd import call , shell
24
23
from ..util .file import CIBW_CACHE_PATH , copy_test_sources , download , extract_zip , move_file
25
24
from ..util .helpers import prepare_command , unwrap
26
25
from ..util .packaging import combine_constraints , find_compatible_wheel , get_pip_version
27
- from ..venv import find_uv , virtualenv
26
+ from ..venv import constraint_flags , find_uv , virtualenv
28
27
29
28
30
29
def get_nuget_args (
@@ -219,7 +218,7 @@ def can_use_uv(python_configuration: PythonConfiguration) -> bool:
219
218
def setup_python (
220
219
tmp : Path ,
221
220
python_configuration : PythonConfiguration ,
222
- dependency_constraint_flags : Sequence [ PathOrStr ] ,
221
+ dependency_constraint : Path | None ,
223
222
environment : ParsedEnvironment ,
224
223
build_frontend : BuildFrontendName ,
225
224
) -> tuple [Path , dict [str , str ]]:
@@ -248,7 +247,7 @@ def setup_python(
248
247
if build_frontend == "build[uv]" and not can_use_uv (python_configuration ):
249
248
build_frontend = "build"
250
249
251
- use_uv = build_frontend == "build[uv]"
250
+ use_uv = build_frontend in { "build[uv]" , "uv" }
252
251
uv_path = find_uv ()
253
252
254
253
log .step ("Setting up build environment..." )
@@ -257,10 +256,12 @@ def setup_python(
257
256
python_configuration .version ,
258
257
base_python ,
259
258
venv_path ,
260
- dependency_constraint_flags ,
259
+ dependency_constraint ,
261
260
use_uv = use_uv ,
262
261
)
263
262
263
+ dependency_constraint_flags = constraint_flags (dependency_constraint )
264
+
264
265
# set up environment variables for run_with_env
265
266
env ["PYTHON_VERSION" ] = python_configuration .version
266
267
env ["PYTHON_ARCH" ] = python_configuration .arch
@@ -276,7 +277,7 @@ def setup_python(
276
277
"install" ,
277
278
"--upgrade" ,
278
279
"pip" ,
279
- * dependency_constraint_flags ,
280
+ * constraint_flags ( dependency_constraint ) ,
280
281
env = env ,
281
282
cwd = venv_path ,
282
283
)
@@ -370,15 +371,15 @@ def build(options: Options, tmp_path: Path) -> None:
370
371
version = config .version ,
371
372
tmp_dir = identifier_tmp_dir ,
372
373
)
373
- dependency_constraint_flags : Sequence [ PathOrStr ] = (
374
- ["-c" , constraints_path ] if constraints_path else []
374
+ dependency_constraint_flags = (
375
+ ["-c" , constraints_path . as_uri () ] if constraints_path else []
375
376
)
376
377
377
378
# install Python
378
379
base_python , env = setup_python (
379
380
identifier_tmp_dir / "build" ,
380
381
config ,
381
- dependency_constraint_flags ,
382
+ constraints_path ,
382
383
build_options .environment ,
383
384
build_frontend .name ,
384
385
)
0 commit comments