Skip to content

Commit b6d81d1

Browse files
committed
feat(uv): Create a UV driver
1 parent 9661dd7 commit b6d81d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+6542
-97
lines changed

.bcr/patches/remove_dev_deps.patch

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
--- a/MODULE.bazel 2025-10-30 12:25:53
2-
+++ b/MODULE.bazel 2025-10-30 12:25:53
3-
@@ -24,554 +24,3 @@
4-
"@aspect_rules_py//py/private/toolchain/shim/...",
5-
)
1+
--- a/MODULE.bazel 2025-11-04 13:27:34
2+
+++ b/MODULE.bazel 2025-11-04 13:27:34
3+
@@ -45,556 +45,6 @@
64

5+
# HACK: In prod the includer's patch inserts the use_repo for multitool. This
6+
# solves the problem of needing a use_repo here in prod and below in dev.
7+
-
78
-################################################################################
89
-# Dev deps
910
-#
@@ -292,7 +293,7 @@
292293
- target_triple = "x86_64-unknown-linux-musl",
293294
- versions = [RUST_VERSION], # "versions" only set in first instance of "rust_darwin_x86_64" repository_set (see comment above)
294295
-)
295-
-
296+
296297
-# -> linux arm (musl)
297298
-rust.repository_set(
298299
- name = "rust_darwin_x86_64",
@@ -303,7 +304,7 @@
303304
- ],
304305
- target_triple = "aarch64-unknown-linux-musl",
305306
-)
306-
-
307+
307308
-# -> darwin x86
308309
-rust.repository_set(
309310
- name = "rust_darwin_x86_64",
@@ -543,11 +544,12 @@
543544
-# from bazel/include/multitool.MODULE.bazel
544545
-# Multitool configuration
545546
-
546-
-bazel_dep(name = "rules_multitool", version = "1.9.0")
547+
-# Multitool is a prod dep (for now) so we don't need this
548+
-# bazel_dep(name = "rules_multitool", version = "1.9.0")
549+
-# multitool = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
547550
-
548-
-multitool = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
549551
-multitool.hub(lockfile = "//tools:tools.lock.json")
550-
-use_repo(multitool, "multitool")
552+
use_repo(multitool, "multitool")
551553
-
552554
-########################################
553555
-# from bazel/include/tools.MODULE.bazel

MODULE.bazel

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ bazel_dep(name = "bazel_skylib", version = "1.4.2")
1212
bazel_dep(name = "platforms", version = "1.0.0")
1313
bazel_dep(name = "rules_python", version = "1.0.0")
1414

15+
# FIXME: We're using this to pull in multitool for source builds. Could use an
16+
# internal tool instead.
17+
bazel_dep(name = "rules_multitool", version = "1.9.0")
18+
1519
tools = use_extension("//py:extensions.bzl", "py_tools")
1620
tools.rules_py_tools()
1721
use_repo(tools, "rules_py_tools")
@@ -24,6 +28,24 @@ register_toolchains(
2428
"@aspect_rules_py//py/private/toolchain/shim/...",
2529
)
2630

31+
toml = use_extension("//uv/private/tomltool:extension.bzl", "tomltool")
32+
use_repo(
33+
toml,
34+
"toml2json_aarch64_linux_gnu",
35+
"toml2json_aarch64_osx_libsystem",
36+
"toml2json_x86_64_linux_gnu",
37+
"toml2json_x86_64_osx_libsystem",
38+
)
39+
40+
host = use_extension("//uv/private/host:extension.bzl", "host_platform")
41+
use_repo(host, "aspect_rules_py_uv_host")
42+
43+
multitool = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
44+
multitool.hub(lockfile = "//uv/private/uv:uv.lock.json")
45+
46+
# HACK: In prod the includer's patch inserts the use_repo for multitool. This
47+
# solves the problem of needing a use_repo here in prod and below in dev.
48+
2749
################################################################################
2850
# Dev deps
2951
#
@@ -563,9 +585,10 @@ bazel_dep(name = "rules_pkg", version = "1.1.0")
563585
# from bazel/include/multitool.MODULE.bazel
564586
# Multitool configuration
565587

566-
bazel_dep(name = "rules_multitool", version = "1.9.0")
588+
# Multitool is a prod dep (for now) so we don't need this
589+
# bazel_dep(name = "rules_multitool", version = "1.9.0")
590+
# multitool = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
567591

568-
multitool = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
569592
multitool.hub(lockfile = "//tools:tools.lock.json")
570593
use_repo(multitool, "multitool")
571594

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Multitool configuration
22

3-
bazel_dep(name = "rules_multitool", version = "1.9.0")
3+
# Multitool is a prod dep (for now) so we don't need this
4+
# bazel_dep(name = "rules_multitool", version = "1.9.0")
5+
# multitool = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
46

5-
multitool = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
67
multitool.hub(lockfile = "//tools:tools.lock.json")
78
use_repo(multitool, "multitool")

e2e/MODULE.bazel

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,26 @@ local_repository(
6868
# For cases/repository-rule-deps-299
6969
importer = use_extension("//cases/repository-rule-deps-299/rules:import.bzl", "importer")
7070
use_repo(importer, "myrepo")
71+
72+
# For cases/uv-deps-650
73+
uv = use_extension("@aspect_rules_py//uv:extension.bzl", "uv")
74+
uv.declare_hub(hub_name = "pypi")
75+
uv.declare_venv(
76+
hub_name = "pypi",
77+
venv_name = "default",
78+
)
79+
uv.lockfile(
80+
hub_name = "pypi",
81+
lockfile = "//cases/uv-deps-650:uv-default.lock",
82+
venv_name = "default",
83+
)
84+
uv.declare_venv(
85+
hub_name = "pypi",
86+
venv_name = "airflow",
87+
)
88+
uv.lockfile(
89+
hub_name = "pypi",
90+
lockfile = "//cases/uv-deps-650:uv-airflow.lock",
91+
venv_name = "airflow",
92+
)
93+
use_repo(uv, "pypi")

e2e/cases/uv-deps-650/BUILD.bazel

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.11
3+
# by the following command:
4+
#
5+
# bazel run //:requirements.update
6+
#
7+
cowsay==6.1 \
8+
--hash=sha256:274b1e6fc1b966d53976333eb90ac94cb07a450a700b455af9fbdf882244b30a
9+
# via -r requirements.in
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
load("@aspect_rules_py//py/unstable:defs.bzl", "py_venv_test")
2+
3+
py_venv_test(
4+
name = "airflow",
5+
srcs = [
6+
"__test__.py",
7+
],
8+
main = "__test__.py",
9+
python_version = "3.13",
10+
venv = "airflow",
11+
deps = [
12+
"@pypi//apache_airflow",
13+
],
14+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env python3
2+
3+
# TODO: Deprecated API, need an alternative
4+
import pkgutil
5+
assert "tests/airflow/.airflow/" in pkgutil.get_loader("airflow").get_filename()
6+
7+
import sys
8+
assert sys.version_info.major == 3
9+
assert sys.version_info.minor == 13
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
load("@aspect_rules_py//py/unstable:defs.bzl", "py_venv_test")
2+
3+
py_venv_test(
4+
name = "say",
5+
srcs = [
6+
"__test__.py",
7+
],
8+
main = "__test__.py",
9+
python_version = "3.11",
10+
venv = "default",
11+
deps = [
12+
"@pypi//cowsay",
13+
],
14+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python3
2+
3+
import cowsay
4+
assert "tests/say/.say/" in cowsay.__file__
5+
6+
import sys
7+
assert sys.version_info.major == 3
8+
assert sys.version_info.minor == 11

0 commit comments

Comments
 (0)