Skip to content

Commit 78e2071

Browse files
authored
chore: move code out of WORKSPACE.bzlmod and into MODULE (#2380)
The WORKSPACE.bzlmod file will eventually be ignored by later Bazel versions. To support setup of the extra repos we rely on it for, create a dev-only module extension that invokes the necessary repo rules. Work towards #2378
1 parent 00d352b commit 78e2071

File tree

3 files changed

+60
-62
lines changed

3 files changed

+60
-62
lines changed

MODULE.bazel

+16
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,27 @@ bazel_dep(name = "rules_bazel_integration_test", version = "0.20.0", dev_depende
7878
bazel_dep(name = "rules_testing", version = "0.6.0", dev_dependency = True)
7979
bazel_dep(name = "rules_shell", version = "0.2.0", dev_dependency = True)
8080
bazel_dep(name = "rules_multirun", version = "0.9.0", dev_dependency = True)
81+
bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True)
8182

8283
# Extra gazelle plugin deps so that WORKSPACE.bzlmod can continue including it for e2e tests.
8384
# We use `WORKSPACE.bzlmod` because it is impossible to have dev-only local overrides.
8485
bazel_dep(name = "rules_go", version = "0.41.0", dev_dependency = True, repo_name = "io_bazel_rules_go")
8586
bazel_dep(name = "gazelle", version = "0.33.0", dev_dependency = True, repo_name = "bazel_gazelle")
87+
bazel_dep(name = "rules_python_gazelle_plugin", version = "0", dev_dependency = True)
88+
89+
internal_dev_deps = use_extension(
90+
"//python/private:internal_dev_deps.bzl",
91+
"internal_dev_deps",
92+
dev_dependency = True,
93+
)
94+
use_repo(internal_dev_deps, "buildkite_config", "wheel_for_testing")
95+
96+
# Add gazelle plugin so that we can run the gazelle example as an e2e integration
97+
# test and include the distribution files.
98+
local_path_override(
99+
module_name = "rules_python_gazelle_plugin",
100+
path = "gazelle",
101+
)
86102

87103
dev_python = use_extension(
88104
"//python/extensions:python.bzl",

WORKSPACE.bzlmod

-62
Original file line numberDiff line numberDiff line change
@@ -1,62 +0,0 @@
1-
# Copyright 2024 The Bazel Authors. All rights reserved.
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
15-
# This file contains everything that is needed when using bzlmod
16-
workspace(name = "rules_python")
17-
18-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
19-
20-
# Used for Bazel CI
21-
http_archive(
22-
name = "bazelci_rules",
23-
sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e",
24-
strip_prefix = "bazelci_rules-1.0.0",
25-
url = "https://github.com/bazelbuild/continuous-integration/releases/download/rules-1.0.0/bazelci_rules-1.0.0.tar.gz",
26-
)
27-
28-
load("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig")
29-
30-
# Creates a default toolchain config for RBE.
31-
# Use this as is if you are using the rbe_ubuntu16_04 container,
32-
# otherwise refer to RBE docs.
33-
rbe_preconfig(
34-
name = "buildkite_config",
35-
toolchain = "ubuntu1804-bazel-java11",
36-
)
37-
38-
# Add gazelle plugin so that we can run the gazelle example as an e2e integration
39-
# test and include the distribution files.
40-
local_repository(
41-
name = "rules_python_gazelle_plugin",
42-
path = "gazelle",
43-
)
44-
45-
#####################
46-
47-
# This wheel is purely here to validate the wheel extraction code. It's not
48-
# intended for anything else.
49-
http_file(
50-
name = "wheel_for_testing",
51-
downloaded_file_path = "numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
52-
sha256 = "0d60fbae8e0019865fc4784745814cff1c421df5afee233db6d88ab4f14655a2",
53-
urls = [
54-
"https://files.pythonhosted.org/packages/50/67/3e966d99a07d60a21a21d7ec016e9e4c2642a86fea251ec68677daf71d4d/numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
55-
],
56-
)
57-
58-
# rules_proto expects //external:python_headers to point at the python headers.
59-
bind(
60-
name = "python_headers",
61-
actual = "//python/cc:current_py_cc_headers",
62-
)

python/private/internal_dev_deps.bzl

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright 2024 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""Module extension for internal dev_dependency=True setup."""
15+
16+
load("@bazel_ci_rules//:rbe_repo.bzl", "rbe_preconfig")
17+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
18+
19+
def _internal_dev_deps_impl(mctx):
20+
_ = mctx # @unused
21+
22+
# This wheel is purely here to validate the wheel extraction code. It's not
23+
# intended for anything else.
24+
http_file(
25+
name = "wheel_for_testing",
26+
downloaded_file_path = "numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
27+
sha256 = "0d60fbae8e0019865fc4784745814cff1c421df5afee233db6d88ab4f14655a2",
28+
urls = [
29+
"https://files.pythonhosted.org/packages/50/67/3e966d99a07d60a21a21d7ec016e9e4c2642a86fea251ec68677daf71d4d/numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
30+
],
31+
)
32+
33+
# Creates a default toolchain config for RBE.
34+
# Use this as is if you are using the rbe_ubuntu16_04 container,
35+
# otherwise refer to RBE docs.
36+
rbe_preconfig(
37+
name = "buildkite_config",
38+
toolchain = "ubuntu1804-bazel-java11",
39+
)
40+
41+
internal_dev_deps = module_extension(
42+
implementation = _internal_dev_deps_impl,
43+
doc = "This extension creates internal rules_python dev dependencies.",
44+
)

0 commit comments

Comments
 (0)