Skip to content

Commit 88c3adb

Browse files
authored
example: add an example for rules_uv (#354)
### Changes are visible to end-users: yes - Searched for relevant documentation and updated as needed: yes - Breaking change (forces users to change their own code or config): no - Suggested release notes appear below: no ### Test plan - New test cases added
1 parent c37e679 commit 88c3adb

File tree

8 files changed

+46
-2
lines changed

8 files changed

+46
-2
lines changed

.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
e2e/
2+
examples/uv_pip_compile

.github/workflows/ci.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
test:
2222
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v6
2323
with:
24-
folders: '[".", "e2e/smoke", "e2e/repository-rule-deps", "e2e/system-interpreter"]'
24+
folders: '[".", "e2e/smoke", "e2e/repository-rule-deps", "e2e/system-interpreter", "examples/uv_pip_compile"]'
2525
# TODO: Build Windows tools and add to toolchain
2626
# TODO(alex): switch the root folder to bzlmod
2727
exclude: |
@@ -30,7 +30,9 @@ jobs:
3030
{"folder": ".", "bazelversion": "6.4.0"},
3131
{"folder": ".", "bzlmodEnabled": true},
3232
{"folder": "e2e/repository-rule-deps", "bzlmodEnabled": false},
33-
{"folder": "e2e/system-interpreter", "bzlmodEnabled": false}
33+
{"folder": "e2e/system-interpreter", "bzlmodEnabled": false},
34+
{"folder": "examples/uv_pip_compile", "bzlmodEnabled": false},
35+
{"folder": "examples/uv_pip_compile", "bazelversion": "6.4.0"},
3436
]
3537
3638
verify-bcr-patches:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
load("@rules_uv//uv:pip.bzl", "pip_compile")
2+
3+
pip_compile(name = "generate_requirements_txt")
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"uv pip compile example with py"
2+
3+
bazel_dep(name = "rules_uv", version = "0.14.0", dev_dependency = True)
4+
bazel_dep(name = "rules_python", version = "0.33.2")
5+
bazel_dep(name = "aspect_rules_py", version = "0.7.3", dev_dependency = True)
6+
7+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
8+
python.toolchain(python_version = "3.9.13")
9+
10+
use_repo(python, "python_3_9_13")
11+
12+
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
13+
pip.parse(
14+
hub_name = "pypi",
15+
python_version = "3.9.13",
16+
requirements_lock = "//:requirements.txt",
17+
)
18+
use_repo(pip, "pypi")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("@aspect_rules_py//py:defs.bzl", "py_binary")
2+
3+
py_binary(
4+
name = "app",
5+
srcs = ["say.py"],
6+
deps = [
7+
"@pypi//cowsay",
8+
],
9+
)

examples/uv_pip_compile/app/say.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import cowsay
2+
3+
cowsay.cow('hello py_binary!')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cowsay
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file was autogenerated by uv via the following command:
2+
# bazel run @@//:generate_requirements_txt
3+
--index-url https://pypi.org/simple
4+
5+
cowsay==6.1 \
6+
--hash=sha256:274b1e6fc1b966d53976333eb90ac94cb07a450a700b455af9fbdf882244b30a
7+
# via -r requirements.in

0 commit comments

Comments
 (0)