Skip to content

Commit 834c210

Browse files
committed
test(bzlmod): use a universal requirements file for 3.9
Summary: - separate target to update the pip requirements - Use a universal requirements file
1 parent 95373f4 commit 834c210

File tree

6 files changed

+230
-840
lines changed

6 files changed

+230
-840
lines changed

examples/BUILD.bazel

+10
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,14 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# The following is experimental API and currently not intended for use outside this example.
16+
load("@rules_python//python/uv/private:pin.bzl", "pin") # buildifier: disable=bzl-visibility
17+
1518
licenses(["notice"]) # Apache 2.0
19+
20+
pin(
21+
name = "bzlmod_requirements_3_9_update",
22+
srcs = ["bzlmod/requirements.in"],
23+
out = "bzlmod/requirements_lock_3_9.txt",
24+
python_version = "3.9.19",
25+
)

examples/bzlmod/BUILD.bazel

+1-11
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,10 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test")
99
load("@pip//:requirements.bzl", "all_data_requirements", "all_requirements", "all_whl_requirements", "requirement")
1010
load("@python_3_9//:defs.bzl", py_test_with_transition = "py_test")
1111
load("@python_versions//3.10:defs.bzl", compile_pip_requirements_3_10 = "compile_pip_requirements")
12-
load("@python_versions//3.9:defs.bzl", compile_pip_requirements_3_9 = "compile_pip_requirements")
1312
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
1413

1514
# This stanza calls a rule that generates targets for managing pip dependencies
16-
# with pip-compile.
17-
compile_pip_requirements_3_9(
18-
name = "requirements_3_9",
19-
src = "requirements.in",
20-
requirements_txt = "requirements_lock_3_9.txt",
21-
requirements_windows = "requirements_windows_3_9.txt",
22-
)
23-
24-
# This stanza calls a rule that generates targets for managing pip dependencies
25-
# with pip-compile.
15+
# with pip-compile for a particular python version.
2616
compile_pip_requirements_3_10(
2717
name = "requirements_3_10",
2818
timeout = "moderate",

examples/bzlmod/MODULE.bazel

+12-13
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,7 @@ pip.parse(
135135
],
136136
hub_name = "pip",
137137
python_version = "3.9",
138-
# The requirements files for each platform that we want to support.
139-
requirements_by_platform = {
140-
# Default requirements file for needs to explicitly provide the platforms
141-
"//:requirements_lock_3_9.txt": "linux_*,osx_*",
142-
# This API allows one to specify additional platforms that the users
143-
# configure the toolchains for themselves. In this example we add
144-
# `windows_aarch64` to illustrate that `rules_python` won't fail to
145-
# process the value, but it does not mean that this example will work
146-
# on Windows ARM.
147-
"//:requirements_windows_3_9.txt": "windows_x86_64,windows_aarch64",
148-
},
138+
requirements_lock = "requirements_lock_3_9.txt",
149139
# These modifications were created above and we
150140
# are providing pip.parse with the label of the mod
151141
# and the name of the wheel.
@@ -179,8 +169,17 @@ pip.parse(
179169
],
180170
hub_name = "pip",
181171
python_version = "3.10",
182-
requirements_lock = "//:requirements_lock_3_10.txt",
183-
requirements_windows = "//:requirements_windows_3_10.txt",
172+
# The requirements files for each platform that we want to support.
173+
requirements_by_platform = {
174+
# Default requirements file for needs to explicitly provide the platforms
175+
"//:requirements_lock_3_10.txt": "linux_*,osx_*",
176+
# This API allows one to specify additional platforms that the users
177+
# configure the toolchains for themselves. In this example we add
178+
# `windows_aarch64` to illustrate that `rules_python` won't fail to
179+
# process the value, but it does not mean that this example will work
180+
# on Windows ARM.
181+
"//:requirements_windows_3_10.txt": "windows_x86_64,windows_aarch64",
182+
},
184183
# These modifications were created above and we
185184
# are providing pip.parse with the label of the mod
186185
# and the name of the wheel.

0 commit comments

Comments
 (0)