Skip to content

Commit 3895cac

Browse files
committed
bazel: Utilize universal lockfile support
This way, we support multiple platforms and multiple python versions at the same time.
1 parent 578f210 commit 3895cac

File tree

8 files changed

+1127
-763
lines changed

8 files changed

+1127
-763
lines changed

BUILD.bazel

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# load("@bazel_gazelle//:def.bzl", "gazelle")
22
# load("@pip//:requirements.bzl", "all_whl_requirements")
3-
# load("@rules_python//python:pip.bzl", "compile_pip_requirements")
43
# load("@rules_python_gazelle_plugin//manifest:defs.bzl", "gazelle_python_manifest")
54
# load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping")
65
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
6+
load("@rules_python//python/uv:lock.bzl", "lock")
77
load("//:requirements.bzl", "requirement")
88

99
# # BUILD.bazel
@@ -45,16 +45,11 @@ load("//:requirements.bzl", "requirement")
4545
# pip_repository_name = "pip",
4646
# requirements = "requirements_lock_3_9.txt",
4747
# )
48-
#
49-
# # This stanza calls a rule that generates targets for managing pip dependencies
50-
# # with pip-compile for a particular python version.
51-
# compile_pip_requirements(
52-
# name = "requirements_3_9",
53-
# timeout = "moderate",
54-
# src = "requirements.in",
55-
# requirements_txt = "requirements_lock_3_9.txt",
56-
# requirements_windows = "requirements_windows_3_9.txt",
57-
# )
48+
lock(
49+
name = "python_dependencies",
50+
srcs = ["requirements_dev.txt", "requirements.txt"],
51+
out = "requirements_lock.txt",
52+
)
5853

5954
py_library(
6055
name = "lobster",

MODULE.bazel

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,43 @@ bazel_dep(name = "rules_python_gazelle_plugin", version = "1.5.1")
1313

1414
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
1515

16+
1617
python.toolchain(
1718
is_default = True,
1819
configure_coverage_tool = True,
1920
python_version = "3.9",
2021
)
22+
python.toolchain(python_version = "3.10")
23+
python.toolchain(python_version = "3.11")
24+
python.toolchain(python_version = "3.12")
2125

2226
use_repo(python, "python_versions")
2327

28+
uv = use_extension("@rules_python//python/uv:uv.bzl", "uv")
29+
uv.configure(version = "0.8.24")
30+
2431
bazel_dep(name = "googletest", version = "1.13.0")
2532
bazel_dep(name = "trlc", version = "0.0.0")
2633

2734
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
2835

29-
pip.parse(
30-
hub_name = "lobster_dependencies",
31-
python_version = "3.12",
32-
requirements_lock = "//:requirements.txt",
33-
)
34-
35-
pip.parse(
36-
hub_name = "pip",
37-
python_version = "3.9",
38-
requirements_lock = "//:requirements_lock_3_9.txt",
39-
requirements_windows = "//:requirements_windows_3_9.txt",
40-
)
41-
42-
use_repo(pip, "pip")
36+
[
37+
pip.parse(
38+
hub_name = "lobster_pip_hub_dependencies",
39+
envsubst = ["PIP_INDEX_URL"],
40+
# For all .whl artifacts use the Bazel downloader, allowing caching of artifacts.
41+
# Also, the Bazel download approach is supposed to be faster and on top offers parallel downloading.
42+
# For sdist packages this will fall back automatically to 'python -m pip --isolated wheel ..', unless we set 'download_only = True'.
43+
experimental_index_url = "${PIP_INDEX_URL:-https://pypi.org/simple}",
44+
python_version = "3.{}".format(version),
45+
requirements_lock = "//:requirements_lock.txt".format(version),
46+
)
47+
for version in ["9", "10", "11", "12"]
48+
]
49+
50+
use_repo(pip, "lobster_pip_hub_dependencies")
4351

4452
bazel_dep(name = "gazelle", version = "0.44.0", repo_name = "bazel_gazelle")
45-
use_repo(python, "python_3_9")
4653

4754
git_override(
4855
commit = "650b51a47264a4f232b3341f473527710fc32669",

0 commit comments

Comments
 (0)