Skip to content

Commit 6801268

Browse files
committed
feat: option to build directly with uv
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 1826f70 commit 6801268

File tree

7 files changed

+60
-10
lines changed

7 files changed

+60
-10
lines changed

bin/generate_schema.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,23 @@
5454
type: string_array
5555
build-frontend:
5656
default: default
57-
description: Set the tool to use to build, either "pip" (default for now), "build", or "build[uv]"
57+
description: Set the tool to use to build, either "pip" (default for now), "build", "build[uv]", or "uv".
5858
oneOf:
59-
- enum: [pip, build, "build[uv]", default]
59+
- enum: [pip, build, "build[uv]", uv, default]
6060
- type: string
6161
pattern: '^pip; ?args:'
6262
- type: string
6363
pattern: '^build; ?args:'
6464
- type: string
6565
pattern: '^build\\[uv\\]; ?args:'
66+
- type: string
67+
pattern: '^uv; ?args:'
6668
- type: object
6769
additionalProperties: false
6870
required: [name]
6971
properties:
7072
name:
71-
enum: [pip, build, "build[uv]"]
73+
enum: [pip, build, "build[uv]", uv]
7274
args:
7375
type: array
7476
items:

cibuildwheel/frontend.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .logger import log
88
from .util.helpers import parse_key_value_string
99

10-
BuildFrontendName = Literal["pip", "build", "build[uv]"]
10+
BuildFrontendName = Literal["pip", "build", "build[uv]", "uv"]
1111

1212

1313
@dataclass(frozen=True)

cibuildwheel/ios.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def setup_python(
236236
environment: ParsedEnvironment,
237237
build_frontend: BuildFrontendName,
238238
) -> tuple[Path, dict[str, str]]:
239-
if build_frontend == "build[uv]":
239+
if build_frontend == "build[uv]" or build_frontend == "uv":
240240
msg = "uv doesn't support iOS"
241241
raise errors.FatalError(msg)
242242

@@ -391,7 +391,7 @@ def build(options: Options, tmp_path: Path) -> None:
391391
build_options = options.build_options(config.identifier)
392392
build_frontend = build_options.build_frontend or BuildFrontendConfig("pip")
393393
# uv doesn't support iOS
394-
if build_frontend.name == "build[uv]":
394+
if build_frontend.name == "build[uv]" or build_frontend.name == "uv":
395395
msg = "uv doesn't support iOS"
396396
raise errors.FatalError(msg)
397397

cibuildwheel/linux.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def build_in_container(
203203
local_identifier_tmp_dir = local_tmp_dir / config.identifier
204204
build_options = options.build_options(config.identifier)
205205
build_frontend = build_options.build_frontend or BuildFrontendConfig("pip")
206-
use_uv = build_frontend.name == "build[uv]"
206+
use_uv = build_frontend.name in {"build[uv]", "uv"}
207207
pip = ["uv", "pip"] if use_uv else ["pip"]
208208

209209
log.step("Setting up build environment...")
@@ -302,6 +302,18 @@ def build_in_container(
302302
],
303303
env=env,
304304
)
305+
elif build_frontend.name == "uv":
306+
container.call(
307+
[
308+
"uv",
309+
"build",
310+
container_package_dir,
311+
"--wheel",
312+
f"--out-dir={built_wheel_dir}",
313+
*extra_flags,
314+
],
315+
env=env,
316+
)
305317
else:
306318
assert_never(build_frontend)
307319

cibuildwheel/macos.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,17 @@ def setup_python(
373373
*dependency_constraint_flags,
374374
env=env,
375375
)
376+
elif build_frontend == "uv":
377+
assert uv_path is not None
378+
call(
379+
uv_path,
380+
"pip",
381+
"install",
382+
"--upgrade",
383+
"delocate",
384+
*dependency_constraint_flags,
385+
env=env,
386+
)
376387
else:
377388
assert_never(build_frontend)
378389

@@ -405,7 +416,7 @@ def build(options: Options, tmp_path: Path) -> None:
405416
for config in python_configurations:
406417
build_options = options.build_options(config.identifier)
407418
build_frontend = build_options.build_frontend or BuildFrontendConfig("pip")
408-
use_uv = build_frontend.name == "build[uv]"
419+
use_uv = build_frontend.name in {"build[uv]", "uv"}
409420
uv_path = find_uv()
410421
if use_uv and uv_path is None:
411422
msg = "uv not found"
@@ -495,6 +506,16 @@ def build(options: Options, tmp_path: Path) -> None:
495506
*extra_flags,
496507
env=build_env,
497508
)
509+
elif build_frontend.name == "uv":
510+
call(
511+
"uv",
512+
"build",
513+
build_options.package_dir,
514+
"--wheel",
515+
f"--out-dir={built_wheel_dir}",
516+
*extra_flags,
517+
env=build_env,
518+
)
498519
else:
499520
assert_never(build_frontend)
500521

cibuildwheel/windows.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def setup_python(
246246
if build_frontend == "build[uv]" and not can_use_uv(python_configuration):
247247
build_frontend = "build"
248248

249-
use_uv = build_frontend == "build[uv]"
249+
use_uv = build_frontend in {"build[uv]", "uv"}
250250
uv_path = find_uv()
251251

252252
log.step("Setting up build environment...")
@@ -356,7 +356,7 @@ def build(options: Options, tmp_path: Path) -> None:
356356
for config in python_configurations:
357357
build_options = options.build_options(config.identifier)
358358
build_frontend = build_options.build_frontend or BuildFrontendConfig("pip")
359-
use_uv = build_frontend.name == "build[uv]" and can_use_uv(config)
359+
use_uv = build_frontend.name in {"build[uv]", "uv"} and can_use_uv(config)
360360
log.build_start(config.identifier)
361361

362362
identifier_tmp_dir = tmp_path / config.identifier
@@ -442,6 +442,16 @@ def build(options: Options, tmp_path: Path) -> None:
442442
*extra_flags,
443443
env=build_env,
444444
)
445+
elif build_frontend.name == "uv":
446+
call(
447+
"uv",
448+
"build",
449+
build_options.package_dir,
450+
"--wheel",
451+
f"--out-dir={built_wheel_dir}",
452+
*extra_flags,
453+
env=build_env,
454+
)
445455
else:
446456
assert_never(build_frontend)
447457

unit_test/options_test.py

+5
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,11 @@ def test_environment_pass_references():
317317
"build",
318318
[],
319319
),
320+
(
321+
'build-frontend = "uv"',
322+
"uv",
323+
[],
324+
),
320325
(
321326
'build-frontend = {name = "build"}',
322327
"build",

0 commit comments

Comments
 (0)