Skip to content

Commit 2dd6fe2

Browse files
authored
Upgrade rules_python to version 1.1.0-rc0 (#1355)
1 parent 7273e20 commit 2dd6fe2

21 files changed

+153
-58
lines changed

.github/workflows/release_prep.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ git archive --format=tar --prefix="${PREFIX}"/ "${TAG}" | gzip > "$ARCHIVE"
1212
SHA="$(shasum -a 256 "$ARCHIVE" | awk '{print $1}')"
1313

1414
cat << EOF
15-
## Using Bzlmod with Bazel 6
15+
## Using Bzlmod
1616
1717
1. Enable with \`common --enable_bzlmod\` in \`.bazelrc\`.
1818
2. Add to your \`MODULE.bazel\` file:
@@ -37,8 +37,24 @@ http_archive(
3737
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
3838
3939
# This sets up some common toolchains for building targets. For more details, please see
40-
# https://bazelbuild.github.io/rules_foreign_cc/${TAG}/flatten.html#rules_foreign_cc_dependencies
40+
# https://bazel-contrib.github.io/rules_foreign_cc/${TAG}/flatten.html#rules_foreign_cc_dependencies
4141
rules_foreign_cc_dependencies()
42+
43+
# If you're not already using bazel_skylib, bazel_features or rules_python,
44+
# you'll need to add these calls as well.
45+
46+
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
47+
48+
bazel_skylib_workspace()
49+
50+
load("@bazel_features//:deps.bzl", "bazel_features_deps")
51+
52+
bazel_features_deps()
53+
54+
load("@rules_python//python:repositories.bzl", "py_repositories")
55+
56+
py_repositories()
57+
4258
EOF
4359

4460
# TODO: add example of how to configure for bzlmod

MODULE.bazel

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ module(
99
bazel_dep(name = "bazel_features", version = "1.15.0")
1010
bazel_dep(name = "bazel_skylib", version = "1.3.0")
1111
bazel_dep(name = "platforms", version = "0.0.5")
12-
bazel_dep(name = "rules_python", version = "0.23.1")
12+
bazel_dep(name = "rules_cc", version = "0.0.17")
13+
bazel_dep(name = "rules_python", version = "1.1.0-rc0")
1314
bazel_dep(name = "rules_shell", version = "0.3.0")
1415

16+
# This is only here because of the docs generation!
17+
bazel_dep(name = "protobuf", version = "29.3", repo_name = "com_google_protobuf")
18+
1519
# Dev dependencies
16-
bazel_dep(name = "gazelle", version = "0.34.0", dev_dependency = True, repo_name = "bazel_gazelle")
17-
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependency = True)
20+
bazel_dep(name = "gazelle", version = "0.41.0", dev_dependency = True, repo_name = "bazel_gazelle")
21+
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.7.1", dev_dependency = True)
1822
bazel_dep(name = "stardoc", version = "0.5.6", dev_dependency = True, repo_name = "io_bazel_stardoc")
1923
bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True)
2024

21-
# note that this dev_dependency is only needed because bazel_ci_rules
22-
# depends on it. If you are not using bazel_ci_rules; ideally we'd be able to remove this.
23-
bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True)
24-
2525
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
26-
python.toolchain(python_version = "3.9")
27-
use_repo(python, "python_3_9")
26+
python.toolchain(python_version = "3.12")
27+
use_repo(python, "python_3_12")
2828

2929
tools = use_extension("@rules_foreign_cc//foreign_cc:extensions.bzl", "tools")
3030
use_repo(
@@ -46,6 +46,6 @@ register_toolchains(
4646
"@rules_foreign_cc_framework_toolchains//:all",
4747
"@cmake_3.23.2_toolchains//:all",
4848
"@ninja_1.12.1_toolchains//:all",
49-
"@python_3_9//:all",
49+
"@python_3_12//:all",
5050
"@rules_foreign_cc//toolchains:all",
5151
)

WORKSPACE.bazel

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
2424

2525
bazel_skylib_workspace()
2626

27-
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
27+
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
28+
29+
py_repositories()
2830

2931
python_register_toolchains(
30-
name = "python3_10",
31-
python_version = "3.10",
32+
name = "python_3_12",
33+
python_version = "3.12",
3234
)
3335

36+
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
37+
38+
protobuf_deps()
39+
3440
load("//:docs/stardoc_repository.bzl", "stardoc_repository")
3541

3642
stardoc_repository()

docs/MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ bazel_dep(
3030
)
3131
bazel_dep(
3232
name = "rules_python",
33-
version = "1.0.0",
33+
version = "1.1.0-rc0",
3434
)

docs/MODULE.bazel.lock

Lines changed: 27 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ python.toolchain(
3131

3232
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
3333
pip.parse(
34-
name = "pip",
34+
hub_name = "pip",
35+
python_version = "3.10",
3536
requirements_lock = "//:requirements_lock.txt",
36-
requirements_windows = "//:requirements_windows.txt",
3737
)
3838
use_repo(pip, "pip")
3939

examples/WORKSPACE.bazel

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,6 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
1313

1414
bazel_skylib_workspace()
1515

16-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
17-
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
18-
19-
maybe(
20-
http_archive,
21-
name = "rules_cc",
22-
sha256 = "4dccbfd22c0def164c8f47458bd50e0c7148f3d92002cdb459c2a96a68498241",
23-
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.1/rules_cc-0.0.1.tar.gz"],
24-
)
25-
2616
load("//deps:repositories.bzl", "repositories")
2717

2818
repositories()
@@ -35,19 +25,24 @@ load("//deps:deps_jvm_external.bzl", "deps_jvm_external")
3525

3626
deps_jvm_external()
3727

38-
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
28+
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
29+
30+
py_repositories()
31+
32+
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
33+
34+
protobuf_deps()
3935

4036
python_register_toolchains(
41-
name = "python3_10",
37+
name = "python_3_10",
4238
python_version = "3.10",
4339
)
4440

45-
load("@python3_10//:defs.bzl", py3_interpreter = "interpreter")
4641
load("@rules_python//python:pip.bzl", "pip_parse")
4742

4843
pip_parse(
4944
name = "pip",
50-
python_interpreter_target = py3_interpreter,
45+
python_interpreter_target = "@python_3_10_host//:python",
5146
requirements_lock = "//:requirements_lock.txt",
5247
)
5348

@@ -68,6 +63,8 @@ load("@rules_foreign_cc_examples_third_party//:setup.bzl", examples_third_party_
6863

6964
examples_third_party_setup()
7065

66+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
67+
7168
http_archive(
7269
name = "bazelci_rules",
7370
sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e",
@@ -125,6 +122,8 @@ load(
125122

126123
apple_support_dependencies()
127124

125+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
126+
128127
maybe(
129128
http_archive,
130129
name = "rules_rust",

foreign_cc/BUILD.bazel

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ bzl_library(
2727
"//foreign_cc/private:transitions",
2828
"//foreign_cc/private/framework:platform",
2929
"//toolchains/native_tools:tool_access",
30+
"@com_google_protobuf//bazel:cc_proto_library_bzl",
31+
"@rules_cc//cc:bzl_srcs",
32+
"@rules_cc//cc/common",
33+
"@rules_cc//cc/toolchains:toolchain_rules",
3034
],
3135
)
3236

@@ -41,6 +45,10 @@ bzl_library(
4145
"//foreign_cc/private:framework",
4246
"//foreign_cc/private:transitions",
4347
"//toolchains/native_tools:tool_access",
48+
"@com_google_protobuf//bazel:cc_proto_library_bzl",
49+
"@rules_cc//cc:bzl_srcs",
50+
"@rules_cc//cc/common",
51+
"@rules_cc//cc/toolchains:toolchain_rules",
4452
],
4553
)
4654

@@ -80,6 +88,10 @@ bzl_library(
8088
"//foreign_cc/private:make_script",
8189
"//foreign_cc/private:transitions",
8290
"//toolchains/native_tools:tool_access",
91+
"@com_google_protobuf//bazel:cc_proto_library_bzl",
92+
"@rules_cc//cc:bzl_srcs",
93+
"@rules_cc//cc/common",
94+
"@rules_cc//cc/toolchains:toolchain_rules",
8395
],
8496
)
8597

@@ -96,6 +108,11 @@ bzl_library(
96108
"//foreign_cc/private:transitions",
97109
"//toolchains/native_tools:native_tools_toolchain",
98110
"//toolchains/native_tools:tool_access",
111+
"@com_google_protobuf//bazel:cc_proto_library_bzl",
112+
"@rules_cc//cc:bzl_srcs",
113+
"@rules_cc//cc/common",
114+
"@rules_cc//cc/toolchains:toolchain_rules",
115+
"@rules_python//python:features_bzl",
99116
],
100117
)
101118

@@ -107,6 +124,10 @@ bzl_library(
107124
"//foreign_cc/private:detect_root",
108125
"//foreign_cc/private:framework",
109126
"//toolchains/native_tools:tool_access",
127+
"@com_google_protobuf//bazel:cc_proto_library_bzl",
128+
"@rules_cc//cc:bzl_srcs",
129+
"@rules_cc//cc/common",
130+
"@rules_cc//cc/toolchains:toolchain_rules",
110131
],
111132
)
112133

@@ -123,14 +144,14 @@ bzl_library(
123144
)
124145

125146
bzl_library(
126-
name = "providers",
127-
srcs = ["providers.bzl"],
147+
name = "utils",
148+
srcs = ["utils.bzl"],
128149
visibility = ["//visibility:public"],
150+
deps = ["@rules_shell//shell:rules_bzl"],
129151
)
130152

131153
bzl_library(
132-
name = "utils",
133-
srcs = ["utils.bzl"],
154+
name = "providers",
155+
srcs = ["providers.bzl"],
134156
visibility = ["//visibility:public"],
135-
deps = ["@rules_shell//shell:rules_bzl"],
136157
)

foreign_cc/boost_build.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
""" Rule for building Boost from sources. """
22

3+
load("@rules_cc//cc:defs.bzl", "CcInfo")
34
load("//foreign_cc/private:detect_root.bzl", "detect_root")
45
load(
56
"//foreign_cc/private:framework.bzl",

foreign_cc/built_tools/meson_build.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
""" Rule for building meson from source. """
22

33
load("@rules_python//python:defs.bzl", "py_binary")
4+
load("@rules_python//python:features.bzl", "features")
45

56
def meson_tool(name, main, data, requirements = [], **kwargs):
7+
kwargs.pop("precompile", None)
8+
if not features.uses_builtin_rules:
9+
kwargs["precompile"] = "disabled"
610
py_binary(
711
name = name,
812
srcs = [main],

0 commit comments

Comments
 (0)