Skip to content

Commit a51a052

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

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/platforms/ios.py

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

@@ -395,7 +395,7 @@ def build(options: Options, tmp_path: Path) -> None:
395395
build_options = options.build_options(config.identifier)
396396
build_frontend = build_options.build_frontend or BuildFrontendConfig("build")
397397
# uv doesn't support iOS
398-
if build_frontend.name == "build[uv]":
398+
if build_frontend.name == "build[uv]" or build_frontend.name == "uv":
399399
msg = "uv doesn't support iOS"
400400
raise errors.FatalError(msg)
401401

cibuildwheel/platforms/linux.py

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

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

cibuildwheel/platforms/macos.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,17 @@ def setup_python(
376376
*dependency_constraint_flags,
377377
env=env,
378378
)
379+
elif build_frontend == "uv":
380+
assert uv_path is not None
381+
call(
382+
uv_path,
383+
"pip",
384+
"install",
385+
"--upgrade",
386+
"delocate",
387+
*dependency_constraint_flags,
388+
env=env,
389+
)
379390
else:
380391
assert_never(build_frontend)
381392

@@ -408,7 +419,7 @@ def build(options: Options, tmp_path: Path) -> None:
408419
for config in python_configurations:
409420
build_options = options.build_options(config.identifier)
410421
build_frontend = build_options.build_frontend or BuildFrontendConfig("build")
411-
use_uv = build_frontend.name == "build[uv]"
422+
use_uv = build_frontend.name in {"build[uv]", "uv"}
412423
uv_path = find_uv()
413424
if use_uv and uv_path is None:
414425
msg = "uv not found"
@@ -498,6 +509,16 @@ def build(options: Options, tmp_path: Path) -> None:
498509
*extra_flags,
499510
env=build_env,
500511
)
512+
elif build_frontend.name == "uv":
513+
call(
514+
"uv",
515+
"build",
516+
build_options.package_dir,
517+
"--wheel",
518+
f"--out-dir={built_wheel_dir}",
519+
*extra_flags,
520+
env=build_env,
521+
)
501522
else:
502523
assert_never(build_frontend)
503524

cibuildwheel/platforms/windows.py

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

251-
use_uv = build_frontend == "build[uv]"
251+
use_uv = build_frontend in {"build[uv]", "uv"}
252252
uv_path = find_uv()
253253

254254
log.step("Setting up build environment...")
@@ -358,7 +358,7 @@ def build(options: Options, tmp_path: Path) -> None:
358358
for config in python_configurations:
359359
build_options = options.build_options(config.identifier)
360360
build_frontend = build_options.build_frontend or BuildFrontendConfig("build")
361-
use_uv = build_frontend.name == "build[uv]" and can_use_uv(config)
361+
use_uv = build_frontend.name in {"build[uv]", "uv"} and can_use_uv(config)
362362
log.build_start(config.identifier)
363363

364364
identifier_tmp_dir = tmp_path / config.identifier
@@ -444,6 +444,16 @@ def build(options: Options, tmp_path: Path) -> None:
444444
*extra_flags,
445445
env=build_env,
446446
)
447+
elif build_frontend.name == "uv":
448+
call(
449+
"uv",
450+
"build",
451+
build_options.package_dir,
452+
"--wheel",
453+
f"--out-dir={built_wheel_dir}",
454+
*extra_flags,
455+
env=build_env,
456+
)
447457
else:
448458
assert_never(build_frontend)
449459

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)