Skip to content

Commit e6a6a3a

Browse files
comiusrickeylev
andauthored
fix: use com_google_protobuf in WORKSPACE (#2432)
The only way to support both workspace and bzlmod mode, is to call protobuf com_google_protobuf. This is because old Bazel's encode it in default values of `--protoco_compiler` flag, and so new Bazel 8 needs to do the same. For bzlmod, upgrade rules_cc to 0.0.16 and rules_java (dev dep) to 8.3.1. Those are minimal versions that are also calling protobuf again com_google_protobuf. For workspace, upgrade rules_cc to 0.1.0. This is an incompatible version that doesn't call Protobuf. rules_python users may use it. In case they need cc_proto_library in `@rules_cc//cc/defs.bzl`, they can overwrite the version to 0.0.16 in WORKSPACE (or use protobuf_deps that already does that). Disable docs generation targets on WORKSPACE CI setups. They are broken by rules_java upgrade. Upgrades dependencies: * rules_cc 0.0.16 (Bzlmod) and rules_cc 0.1.0 (WORKSPACE) * rules_java 8.3.1 * bazel_skylib 1.7.0 (workspace; bzlmod already specifying that version) * protobuf 29.0-rc2 (workspace; bzlmod already specifying that version) Fixes #2429 --------- Co-authored-by: Richard Levasseur <[email protected]>
1 parent d73a74f commit e6a6a3a

File tree

12 files changed

+45
-35
lines changed

12 files changed

+45
-35
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,15 @@ Unreleased changes template.
7070
bzlmod extension.
7171
* (bzlmod) `pip.parse.parse_all_requirements_files` attribute has been removed.
7272
See notes in the previous versions about what to do.
73+
* (deps) rules_cc 0.1.0 (workspace) and 0.0.16 (bzlmod).
74+
* (deps) protobuf 29.0-rc2 (workspace; bzlmod already specifying that version).
7375

7476
Other changes:
7577
* (python_repository) Start honoring the `strip_prefix` field for `zstd` archives.
7678
* (pypi) {bzl:obj}`pip_parse.extra_hub_aliases` now works in WORKSPACE files.
7779
* (binaries/tests) For {obj}`--bootstrap_impl=script`, a binary-specific (but
7880
otherwise empty) virtual env is used to customize `sys.path` initialization.
81+
* (deps) bazel_skylib 1.7.0 (workspace; bzlmod already specifying that version)
7982

8083
{#v0-0-0-fixed}
8184
### Fixed
@@ -88,6 +91,8 @@ Other changes:
8891
* (binaries/tests) ({obj}`--bootstrap_impl=scipt`) Using `sys.executable` will
8992
use the same `sys.path` setup as the calling binary.
9093
([2169](https://github.com/bazelbuild/rules_python/issues/2169)).
94+
* (workspace) Corrected protobuf's name to com_google_protobuf, the name is
95+
hardcoded in Bazel, WORKSPACE mode.
9196

9297
{#v0-0-0-added}
9398
### Added

MODULE.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module(
66

77
bazel_dep(name = "bazel_features", version = "1.9.1")
88
bazel_dep(name = "bazel_skylib", version = "1.7.1")
9-
bazel_dep(name = "rules_cc", version = "0.0.14")
9+
bazel_dep(name = "rules_cc", version = "0.0.16")
1010
bazel_dep(name = "platforms", version = "0.0.4")
1111

1212
# Those are loaded only when using py_proto_library

docs/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _TARGET_COMPATIBLE_WITH = select({
3636
"@platforms//os:linux": [],
3737
"@platforms//os:macos": [],
3838
"//conditions:default": ["@platforms//:incompatible"],
39-
}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"]
39+
}) if BZLMOD_ENABLED else ["@platforms//:incompatible"]
4040

4141
# See README.md for instructions. Short version:
4242
# * `bazel run //docs:docs.serve` in a separate terminal

examples/bzlmod/MODULE.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bazel_dep(name = "protobuf", version = "27.0", repo_name = "com_google_protobuf"
1919

2020
# Only needed to make rules_python's CI happy. rules_java 8.3.0+ is needed so
2121
# that --java_runtime_version=remotejdk_11 works with Bazel 8.
22-
bazel_dep(name = "rules_java", version = "8.3.0")
22+
bazel_dep(name = "rules_java", version = "8.3.1")
2323

2424
# Only needed to make rules_python's CI happy. A test verifies that
2525
# MODULE.bazel.lock is cross-platform friendly, and there are transitive

examples/bzlmod/MODULE.bazel.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/bzlmod_build_file_generation/MODULE.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ local_path_override(
8787
)
8888

8989
# Only needed to make rules_python's CI happy
90-
bazel_dep(name = "rules_java", version = "8.3.0")
90+
bazel_dep(name = "rules_java", version = "8.3.1")

examples/multi_python_versions/MODULE.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ bazel_dep(name = "rules_shell", version = "0.2.0", dev_dependency = True)
6262

6363
# Only needed to make rules_python's CI happy. rules_java 8.3.0+ is needed so
6464
# that --java_runtime_version=remotejdk_11 works with Bazel 8.
65-
bazel_dep(name = "rules_java", version = "8.3.0")
65+
bazel_dep(name = "rules_java", version = "8.3.1")

gazelle/MODULE.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ bazel_dep(name = "bazel_skylib", version = "1.6.1")
88
bazel_dep(name = "rules_python", version = "0.18.0")
99
bazel_dep(name = "rules_go", version = "0.41.0", repo_name = "io_bazel_rules_go")
1010
bazel_dep(name = "gazelle", version = "0.33.0", repo_name = "bazel_gazelle")
11+
bazel_dep(name = "rules_cc", version = "0.0.16")
1112

1213
local_path_override(
1314
module_name = "rules_python",

internal_deps.bzl

+9-11
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,19 @@ def rules_python_internal_deps():
178178

179179
http_archive(
180180
name = "com_google_protobuf",
181-
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
182-
strip_prefix = "protobuf-27.0",
183-
urls = [
184-
"https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
185-
],
181+
sha256 = "23082dca1ca73a1e9c6cbe40097b41e81f71f3b4d6201e36c134acc30a1b3660",
182+
url = "https://github.com/protocolbuffers/protobuf/releases/download/v29.0-rc2/protobuf-29.0-rc2.zip",
183+
strip_prefix = "protobuf-29.0-rc2",
186184
)
187185

188186
# Needed for stardoc
189187
http_archive(
190188
name = "rules_java",
191189
urls = [
192-
"https://mirror.bazel.build/github.com/bazelbuild/rules_java/releases/download/6.3.0/rules_java-6.3.0.tar.gz",
193-
"https://github.com/bazelbuild/rules_java/releases/download/6.3.0/rules_java-6.3.0.tar.gz",
190+
"https://mirror.bazel.build/github.com/bazelbuild/rules_java/releases/download/8.3.1/rules_java-8.3.1.tar.gz",
191+
"https://github.com/bazelbuild/rules_java/releases/download/8.3.1/rules_java-8.3.1.tar.gz",
194192
],
195-
sha256 = "29ba147c583aaf5d211686029842c5278e12aaea86f66bd4a9eb5e525b7f2701",
193+
sha256 = "ee786b943e00da4fea7c233e70e5f5b8a01cc69b9341b3f49169f174fe0df1c5",
196194
)
197195

198196
RULES_JVM_EXTERNAL_TAG = "5.2"
@@ -224,9 +222,9 @@ def rules_python_internal_deps():
224222

225223
http_archive(
226224
name = "rules_cc",
227-
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.14/rules_cc-0.0.14.tar.gz"],
228-
sha256 = "906e89286acc67c20819c3c88b3283de0d5868afda33635d70acae0de9777bb7",
229-
strip_prefix = "rules_cc-0.0.14",
225+
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.16/rules_cc-0.0.16.tar.gz"],
226+
sha256 = "bbf1ae2f83305b7053b11e4467d317a7ba3517a12cef608543c1b1c5bf48a4df",
227+
strip_prefix = "rules_cc-0.0.16",
230228
)
231229

232230
http_archive(

internal_setup.bzl

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ load("@cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies")
2020
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
2121
load("@rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies")
2222
load("@rules_bazel_integration_test//bazel_integration_test:repo_defs.bzl", "bazel_binaries")
23+
load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
2324
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
2425
load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains")
2526
load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
@@ -52,6 +53,9 @@ def rules_python_internal_setup():
5253

5354
protobuf_deps()
5455

56+
rules_java_dependencies()
57+
rules_java_toolchains()
58+
5559
bazel_integration_test_rules_dependencies()
5660
bazel_starlib_dependencies()
5761
bazel_binaries(versions = SUPPORTED_BAZEL_VERSIONS)

python/private/py_repositories.bzl

+13-11
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,26 @@ def py_repositories():
4747
)
4848
http_archive(
4949
name = "bazel_skylib",
50-
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
50+
sha256 = "d00f1389ee20b60018e92644e0948e16e350a7707219e7a390fb0a99b6ec9262",
5151
urls = [
52-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
53-
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
52+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.0/bazel-skylib-1.7.0.tar.gz",
53+
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.0/bazel-skylib-1.7.0.tar.gz",
5454
],
5555
)
5656
http_archive(
5757
name = "rules_cc",
58-
sha256 = "d9bdd3ec66b6871456ec9c965809f43a0901e692d754885e89293807762d3d80",
59-
strip_prefix = "rules_cc-0.0.13",
60-
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.13/rules_cc-0.0.13.tar.gz"],
58+
sha256 = "4b12149a041ddfb8306a8fd0e904e39d673552ce82e4296e96fac9cbf0780e59",
59+
strip_prefix = "rules_cc-0.1.0",
60+
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.1.0/rules_cc-0.1.0.tar.gz"],
6161
)
6262

63-
# Needed by rules_cc, triggerred by @rules_java_prebuilt in Bazel by using @rules_cc//cc:defs.bzl
63+
# Needed by rules_cc, triggered by @rules_java_prebuilt in Bazel by using @rules_cc//cc:defs.bzl
64+
# NOTE: This name must be com_google_protobuf until Bazel drops WORKSPACE
65+
# support; Bazel itself has references to com_google_protobuf.
6466
http_archive(
65-
name = "protobuf",
66-
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
67-
strip_prefix = "protobuf-27.0",
68-
url = "https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
67+
name = "com_google_protobuf",
68+
sha256 = "23082dca1ca73a1e9c6cbe40097b41e81f71f3b4d6201e36c134acc30a1b3660",
69+
url = "https://github.com/protocolbuffers/protobuf/releases/download/v29.0-rc2/protobuf-29.0-rc2.zip",
70+
strip_prefix = "protobuf-29.0-rc2",
6971
)
7072
pypi_deps()

sphinxdocs/docs/BUILD.bazel

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
1+
load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility
22
load("//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
33
load("//sphinxdocs:sphinx_stardoc.bzl", "sphinx_stardocs")
44

@@ -14,7 +14,7 @@ _TARGET_COMPATIBLE_WITH = select({
1414
"@platforms//os:linux": [],
1515
"@platforms//os:macos": [],
1616
"//conditions:default": ["@platforms//:incompatible"],
17-
}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"]
17+
}) if BZLMOD_ENABLED else ["@platforms//:incompatible"]
1818

1919
sphinx_docs_library(
2020
name = "docs_lib",

0 commit comments

Comments
 (0)