Skip to content

Commit

Permalink
Namespace pypi (#227)
Browse files Browse the repository at this point in the history
Bugfix to avoid bzlmod module namespace conflicts when integrating with
other repos.
  • Loading branch information
mgottscho authored Nov 27, 2024
1 parent 6163395 commit f6feee3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ load("@python_versions//3.12:defs.bzl", compile_pip_requirements_3_12 = "compile

compile_pip_requirements_3_12(
name = "requirements_3_12",
src = "requirements.in",
src = "requirements_3_12.in",
requirements_txt = "requirements_lock_3_12.txt",
)
10 changes: 7 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ python.toolchain(python_version = "3.12")
use_repo(python, "python_3_12", "python_versions", "pythons_hub")

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

# The requirements_lock_3_12.txt file is auto-generated from requirements_3_12.in and statically checked in.
# To regenerate it, run `bazel run //:requirements_3_12.update`.
pip.parse(
download_only = True,
hub_name = "pypi",
# Hub names must be unique across Bazel modules. To avoid problems when integrating
# this module with others, namespace the hub name using the git repo name.
hub_name = "bedrock-rtl-pypi",
# We need to use the same version here as in the `python.toolchain` call.
python_version = "3.12",
requirements_lock = "//:requirements_lock_3_12.txt",
)
use_repo(pip, "pypi")
use_repo(pip, "bedrock-rtl-pypi")
8 changes: 4 additions & 4 deletions python/eccgen/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package(default_visibility = ["//visibility:public"])
py_library(
name = "hsiao_secded",
srcs = ["hsiao_secded.py"],
deps = ["@pypi//numpy:pkg"],
deps = ["@bedrock-rtl-pypi//numpy:pkg"],
)

py_binary(
Expand All @@ -31,7 +31,7 @@ py_binary(
],
deps = [
":hsiao_secded",
"@pypi//jinja2:pkg",
"@bedrock-rtl-pypi//jinja2:pkg",
],
)

Expand All @@ -40,7 +40,7 @@ py_test(
srcs = ["hsiao_secded_test.py"],
deps = [
":hsiao_secded",
"@pypi//numpy:pkg",
"@pypi//parameterized:pkg",
"@bedrock-rtl-pypi//numpy:pkg",
"@bedrock-rtl-pypi//parameterized:pkg",
],
)
File renamed without changes.
6 changes: 3 additions & 3 deletions requirements_lock_3_12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
jinja2==3.1.4 \
--hash=sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369 \
--hash=sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d
# via -r requirements.in
# via -r requirements_3_12.in
markupsafe==3.0.2 \
--hash=sha256:0bff5e0ae4ef2e1ae4fdf2dfd5b76c75e5c2fa4132d05fc1b0dabcd20c7e28c4 \
--hash=sha256:0f4ca02bea9a23221c0182836703cbf8930c5e9454bacce27e767509fa286a30 \
Expand Down Expand Up @@ -127,8 +127,8 @@ numpy==2.1.3 \
--hash=sha256:f55ba01150f52b1027829b50d70ef1dafd9821ea82905b63936668403c3b471e \
--hash=sha256:f653490b33e9c3a4c1c01d41bc2aef08f9475af51146e4a7710c450cf9761598 \
--hash=sha256:fa2d1337dc61c8dc417fbccf20f6d1e139896a30721b7f1e832b2bb6ef4eb6c4
# via -r requirements.in
# via -r requirements_3_12.in
parameterized==0.9.0 \
--hash=sha256:4e0758e3d41bea3bbd05ec14fc2c24736723f243b28d702081aef438c9372b1b \
--hash=sha256:7fc905272cefa4f364c1a3429cbbe9c0f98b793988efb5bf90aac80f08db09b1
# via -r requirements.in
# via -r requirements_3_12.in

0 comments on commit f6feee3

Please sign in to comment.