Skip to content

Commit

Permalink
test(bzlmod): use a universal requirements file for 3.9
Browse files Browse the repository at this point in the history
Summary:
- separate target to update the pip requirements
- Use a universal requirements file
  • Loading branch information
aignas committed Aug 21, 2024
1 parent 7a4a565 commit 65f6efa
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 840 deletions.
10 changes: 10 additions & 0 deletions examples/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# The following is experimental API and currently not intended for use outside this example.
load("@rules_python//python/uv/private:pin.bzl", "pin") # buildifier: disable=bzl-visibility

licenses(["notice"]) # Apache 2.0

pin(
name = "bzlmod_requirements_3_9_update",
srcs = ["bzlmod/requirements.in"],
out = "bzlmod/requirements_lock_3_9.txt",
python_version = "3.9.19",
)
12 changes: 1 addition & 11 deletions examples/bzlmod/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,10 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@pip//:requirements.bzl", "all_data_requirements", "all_requirements", "all_whl_requirements", "requirement")
load("@python_3_9//:defs.bzl", py_test_with_transition = "py_test")
load("@python_versions//3.10:defs.bzl", compile_pip_requirements_3_10 = "compile_pip_requirements")
load("@python_versions//3.9:defs.bzl", compile_pip_requirements_3_9 = "compile_pip_requirements")
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")

# This stanza calls a rule that generates targets for managing pip dependencies
# with pip-compile.
compile_pip_requirements_3_9(
name = "requirements_3_9",
src = "requirements.in",
requirements_txt = "requirements_lock_3_9.txt",
requirements_windows = "requirements_windows_3_9.txt",
)

# This stanza calls a rule that generates targets for managing pip dependencies
# with pip-compile.
# with pip-compile for a particular python version.
compile_pip_requirements_3_10(
name = "requirements_3_10",
timeout = "moderate",
Expand Down
25 changes: 12 additions & 13 deletions examples/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,7 @@ pip.parse(
],
hub_name = "pip",
python_version = "3.9",
# The requirements files for each platform that we want to support.
requirements_by_platform = {
# Default requirements file for needs to explicitly provide the platforms
"//:requirements_lock_3_9.txt": "linux_*,osx_*",
# This API allows one to specify additional platforms that the users
# configure the toolchains for themselves. In this example we add
# `windows_aarch64` to illustrate that `rules_python` won't fail to
# process the value, but it does not mean that this example will work
# on Windows ARM.
"//:requirements_windows_3_9.txt": "windows_x86_64,windows_aarch64",
},
requirements_lock = "requirements_lock_3_9.txt",
# These modifications were created above and we
# are providing pip.parse with the label of the mod
# and the name of the wheel.
Expand Down Expand Up @@ -179,8 +169,17 @@ pip.parse(
],
hub_name = "pip",
python_version = "3.10",
requirements_lock = "//:requirements_lock_3_10.txt",
requirements_windows = "//:requirements_windows_3_10.txt",
# The requirements files for each platform that we want to support.
requirements_by_platform = {
# Default requirements file for needs to explicitly provide the platforms
"//:requirements_lock_3_10.txt": "linux_*,osx_*",
# This API allows one to specify additional platforms that the users
# configure the toolchains for themselves. In this example we add
# `windows_aarch64` to illustrate that `rules_python` won't fail to
# process the value, but it does not mean that this example will work
# on Windows ARM.
"//:requirements_windows_3_10.txt": "windows_x86_64,windows_aarch64",
},
# These modifications were created above and we
# are providing pip.parse with the label of the mod
# and the name of the wheel.
Expand Down
Loading

0 comments on commit 65f6efa

Please sign in to comment.