Skip to content

Commit dd08165

Browse files
committed
feat: upgrade to protobuf 27.0 and remove py_proto_library (#1933)
Reintroduce the changes in #1933, which got reverted in commit 8b0eaed (#1948).
1 parent 2a19374 commit dd08165

File tree

18 files changed

+77
-333
lines changed

18 files changed

+77
-333
lines changed

.bazelci/presubmit.yml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ tasks:
147147
<<: *reusable_config
148148
name: "Default: Debian"
149149
platform: debian11
150+
build_flags:
151+
# For protobuf compilation
152+
- '--host_copt=-Wno-deprecated-declarations'
153+
- '--copt=-Wno-deprecated-declarations'
154+
test_flags:
155+
# For protobuf compilation
156+
- '--host_copt=-Wno-deprecated-declarations'
157+
- '--copt=-Wno-deprecated-declarations'
150158
macos:
151159
<<: *reusable_config
152160
name: "Default: MacOS"
@@ -169,19 +177,39 @@ tasks:
169177
# build kite cc toolchain.
170178
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
171179
- "--build_tag_filters=-docs"
180+
build_targets:
181+
- "--"
182+
- "..."
183+
- '-//sphinxdocs/...' # protobuf compilation fails
172184
test_flags:
173185
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
174186
# BazelCI sets --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1,
175187
# which prevents cc toolchain autodetection from working correctly
176188
# on Bazel 5.4 and earlier. To workaround this, manually specify the
177189
# build kite cc toolchain.
178190
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
191+
test_targets:
192+
- "--"
193+
- "..."
194+
- '-//sphinxdocs/...' # protobuf compilation fails
179195
rbe:
180196
<<: *reusable_config
181197
name: "RBE: Ubuntu"
182198
platform: rbe_ubuntu1604
199+
build_flags:
200+
- "--build_tag_filters=-docs"
201+
build_targets:
202+
- "--"
203+
- "..."
204+
- '-//sphinxdocs/...' # protobuf compilation fails
205+
- '-//docs/...'
183206
test_flags:
184-
- "--test_tag_filters=-integration-test,-acceptance-test"
207+
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
208+
test_targets:
209+
- "--"
210+
- "..."
211+
- '-//sphinxdocs/...' # protobuf compilation fails
212+
- '-//docs/...'
185213

186214
integration_test_build_file_generation_ubuntu_minimum_supported_workspace:
187215
<<: *minimum_supported_version
@@ -234,6 +262,21 @@ tasks:
234262
name: "examples/bzlmod: Debian"
235263
working_directory: examples/bzlmod
236264
platform: debian11
265+
build_targets:
266+
# For protobuf compilation
267+
- "--"
268+
- "..."
269+
- "-//py_proto_library/..."
270+
test_targets:
271+
# For protobuf compilation
272+
- "--"
273+
- "..."
274+
- "-//py_proto_library/..."
275+
coverage_targets:
276+
# For protobuf compilation
277+
- "--"
278+
- "..."
279+
- "-//py_proto_library/..."
237280
integration_test_bzlmod_macos:
238281
<<: *reusable_build_test_all
239282
<<: *coverage_targets_example_bzlmod
@@ -395,6 +438,14 @@ tasks:
395438
name: "examples/py_proto_library: Debian, workspace"
396439
working_directory: examples/py_proto_library
397440
platform: debian11
441+
build_flags:
442+
# For protobuf compilation
443+
- '--host_copt=-Wno-deprecated-declarations'
444+
- '--copt=-Wno-deprecated-declarations'
445+
test_flags:
446+
# For protobuf compilation
447+
- '--host_copt=-Wno-deprecated-declarations'
448+
- '--copt=-Wno-deprecated-declarations'
398449
integration_test_py_proto_library_macos_workspace:
399450
<<: *reusable_build_test_all
400451
<<: *common_workspace_flags

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ A brief description of the categories of changes:
2525
[x.x.x]: https://github.com/bazelbuild/rules_python/releases/tag/x.x.x
2626

2727
### Changed
28-
* Nothing yet
28+
* (rules) `py_proto_library` is deprecated in favour of the
29+
implementation in https://github.com/protocolbuffers/protobuf. It will be
30+
removed in the future release.
2931

3032
### Fixed
3133
* Nothing yet

MODULE.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ bazel_dep(name = "bazel_skylib", version = "1.6.1")
99
bazel_dep(name = "rules_cc", version = "0.0.9")
1010
bazel_dep(name = "platforms", version = "0.0.4")
1111

12-
# Those are loaded only when using py_proto_library
13-
bazel_dep(name = "rules_proto", version = "6.0.0-rc1")
14-
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
12+
# For backwards compatibility, those are loaded only when using py_proto_library
13+
# Use py_proto_library directly from protobuf repository
14+
bazel_dep(name = "protobuf", version = "27.0", repo_name = "com_google_protobuf")
1515

1616
internal_deps = use_extension("//python/private/bzlmod:internal_deps.bzl", "internal_deps")
1717
use_repo(

WORKSPACE

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,3 @@ http_file(
148148
"https://files.pythonhosted.org/packages/50/67/3e966d99a07d60a21a21d7ec016e9e4c2642a86fea251ec68677daf71d4d/numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
149149
],
150150
)
151-
152-
# rules_proto expects //external:python_headers to point at the python headers.
153-
bind(
154-
name = "python_headers",
155-
actual = "//python/cc:current_py_cc_headers",
156-
)

WORKSPACE.bzlmod

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,3 @@ http_file(
5555
],
5656
)
5757

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-
)

examples/bzlmod/MODULE.bazel

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ local_path_override(
1111
path = "../..",
1212
)
1313

14-
# (py_proto_library specific) We are using rules_proto to define rules_proto targets to be consumed by py_proto_library.
15-
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
16-
1714
# (py_proto_library specific) Add the protobuf library for well-known types (e.g. `Any`, `Timestamp`, etc)
18-
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
15+
bazel_dep(name = "protobuf", version = "27.0", repo_name = "com_google_protobuf")
1916

2017
# We next initialize the python toolchain using the extension.
2118
# You can set different Python versions in this block.

examples/bzlmod/py_proto_library/example.com/another_proto/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@rules_proto//proto:defs.bzl", "proto_library")
2-
load("@rules_python//python:proto.bzl", "py_proto_library")
1+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
2+
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
33

44
py_proto_library(
55
name = "message_proto_py_pb2",

examples/bzlmod/py_proto_library/example.com/proto/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@rules_proto//proto:defs.bzl", "proto_library")
2-
load("@rules_python//python:proto.bzl", "py_proto_library")
1+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
2+
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
33

44
py_proto_library(
55
name = "pricetag_proto_py_pb2",

examples/py_proto_library/WORKSPACE

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,11 @@ python_register_toolchains(
2424
# Then we need to setup dependencies in order to use py_proto_library
2525
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2626

27-
http_archive(
28-
name = "rules_proto",
29-
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
30-
strip_prefix = "rules_proto-6.0.0-rc1",
31-
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
32-
)
33-
34-
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
35-
36-
rules_proto_dependencies()
37-
38-
rules_proto_toolchains()
39-
4027
http_archive(
4128
name = "com_google_protobuf",
42-
sha256 = "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
43-
strip_prefix = "protobuf-26.1",
44-
urls = ["https://github.com/protocolbuffers/protobuf/archive/v26.1.tar.gz"],
29+
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
30+
strip_prefix = "protobuf-27.0",
31+
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz"],
4532
)
4633

4734
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

examples/py_proto_library/example.com/another_proto/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@rules_proto//proto:defs.bzl", "proto_library")
2-
load("@rules_python//python:proto.bzl", "py_proto_library")
1+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
2+
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
33

44
py_proto_library(
55
name = "message_proto_py_pb2",

0 commit comments

Comments
 (0)