Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 1 addition & 52 deletions .bazelci/presubmit.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -147,14 +147,6 @@ tasks:
<<: *reusable_config
name: "Default: Debian"
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
macos:
<<: *reusable_config
name: "Default: MacOS"
Expand All@@ -177,39 +169,19 @@ tasks:
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
# BazelCI sets --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1,
# which prevents cc toolchain autodetection from working correctly
# on Bazel 5.4 and earlier. To workaround this, manually specify the
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
rbe:
<<: *reusable_config
name: "RBE: Ubuntu"
platform: rbe_ubuntu1604
build_flags:
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
- "--test_tag_filters=-integration-test,-acceptance-test"

integration_test_build_file_generation_ubuntu_minimum_supported_workspace:
<<: *minimum_supported_version
Expand DownExpand Up@@ -262,21 +234,6 @@ tasks:
name: "examples/bzlmod: Debian"
working_directory: examples/bzlmod
platform: debian11
build_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
test_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
coverage_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
integration_test_bzlmod_macos:
<<: *reusable_build_test_all
<<: *coverage_targets_example_bzlmod
Expand DownExpand Up@@ -438,14 +395,6 @@ tasks:
name: "examples/py_proto_library: Debian, workspace"
working_directory: examples/py_proto_library
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
integration_test_py_proto_library_macos_workspace:
<<: *reusable_build_test_all
<<: *common_workspace_flags
Expand Down
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,9 +25,6 @@ A brief description of the categories of changes:
[x.x.x]: https://github.com/bazelbuild/rules_python/releases/tag/x.x.x

### Changed
* (rules) `py_proto_library` is deprecated in favour of the
implementation in https://github.com/protocolbuffers/protobuf. It will be
removed in the future release.
* (deps) Upgrade the `pip_install` dependencies to pick up a new version of pip.
* (toolchains) Optional toolchain dependency: `py_binary`, `py_test`, and
`py_library` now depend on the `//python:exec_tools_toolchain_type` for build
Expand Down
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,9 @@ bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "platforms", version = "0.0.4")

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

internal_deps = use_extension("//python/private/bzlmod:internal_deps.bzl", "internal_deps")
use_repo(
Expand Down
6 changes: 6 additions & 0 deletions WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -148,3 +148,9 @@ http_file(
"https://files.pythonhosted.org/packages/50/67/3e966d99a07d60a21a21d7ec016e9e4c2642a86fea251ec68677daf71d4d/numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 5 additions & 0 deletions WORKSPACE.bzlmod
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,3 +55,8 @@ http_file(
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 4 additions & 1 deletion examples/bzlmod/MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,8 +11,11 @@ local_path_override(
path = "../..",
)

# (py_proto_library specific) We are using rules_proto to define rules_proto targets to be consumed by py_proto_library.
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

# (py_proto_library specific) Add the protobuf library for well-known types (e.g. `Any`, `Timestamp`, etc)
bazel_dep(name = "protobuf", version = "27.0", repo_name = "com_google_protobuf")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")

# We next initialize the python toolchain using the extension.
# You can set different Python versions in this block.
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
19 changes: 16 additions & 3 deletions examples/py_proto_library/WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,11 +24,24 @@ python_register_toolchains(
# Then we need to setup dependencies in order to use py_proto_library
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz"],
sha256 = "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
strip_prefix = "protobuf-26.1",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v26.1.tar.gz"],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
4 changes: 2 additions & 2 deletions examples/py_proto_library/example.com/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
14 changes: 11 additions & 3 deletions internal_deps.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -164,12 +164,20 @@ def rules_python_internal_deps():
],
)

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
sha256 = "75be42bd736f4df6d702a0e4e4d30de9ee40eac024c4b845d17ae4cc831fe4ae",
strip_prefix = "protobuf-21.7",
urls = [
"https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
],
)

Expand Down
4 changes: 4 additions & 0 deletions internal_setup.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@ load("@cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies")
load("@rules_bazel_integration_test//bazel_integration_test:repo_defs.bzl", "bazel_binaries")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
load("//python/pip_install:repositories.bzl", "pip_install_dependencies")
load("//python/private:internal_config_repo.bzl", "internal_config_repo") # buildifier: disable=bzl-visibility
Expand All@@ -34,6 +35,9 @@ def rules_python_internal_setup():

bazel_skylib_workspace()

rules_proto_dependencies()
rules_proto_toolchains()

protobuf_deps()

bazel_integration_test_rules_dependencies()
Expand Down
2 changes: 1 addition & 1 deletion python/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -113,7 +113,7 @@ bzl_library(
],
visibility = ["//visibility:public"],
deps = [
"@com_google_protobuf//bazel:py_proto_library_bzl",
"//python/private/proto:py_proto_library_bzl",
],
)

Expand Down
1 change: 1 addition & 0 deletions python/private/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,7 @@ filegroup(
srcs = glob(["**"]) + [
"//python/private/bzlmod:distribution",
"//python/private/common:distribution",
"//python/private/proto:distribution",
"//python/private/whl_filegroup:distribution",
"//tools/build_defs/python/private:distribution",
],
Expand Down
46 changes: 46 additions & 0 deletions python/private/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
# Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")

package(default_visibility = ["//visibility:private"])

licenses(["notice"])

filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python/private:__pkg__"],
)

bzl_library(
name = "py_proto_library_bzl",
srcs = ["py_proto_library.bzl"],
visibility = ["//python:__pkg__"],
deps = [
"//python:defs_bzl",
"@rules_proto//proto:defs",
],
)

proto_lang_toolchain(
name = "python_toolchain",
command_line = "--python_out=%s",
progress_message = "Generating Python proto_library %{label}",
runtime = "@com_google_protobuf//:protobuf_python",
# NOTE: This isn't *actually* public. It's an implicit dependency of py_proto_library,
# so must be public so user usages of the rule can reference it.
visibility = ["//visibility:public"],
)
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
revert: upgrade to protobuf 27.0 and remove py_proto_library (#1933) by aignas · Pull Request #1948 · bazel-contrib/rules_python · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 1 addition & 52 deletions .bazelci/presubmit.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -147,14 +147,6 @@ tasks:
<<: *reusable_config
name: "Default: Debian"
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
macos:
<<: *reusable_config
name: "Default: MacOS"
Expand All@@ -177,39 +169,19 @@ tasks:
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
# BazelCI sets --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1,
# which prevents cc toolchain autodetection from working correctly
# on Bazel 5.4 and earlier. To workaround this, manually specify the
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
rbe:
<<: *reusable_config
name: "RBE: Ubuntu"
platform: rbe_ubuntu1604
build_flags:
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
- "--test_tag_filters=-integration-test,-acceptance-test"

integration_test_build_file_generation_ubuntu_minimum_supported_workspace:
<<: *minimum_supported_version
Expand DownExpand Up@@ -262,21 +234,6 @@ tasks:
name: "examples/bzlmod: Debian"
working_directory: examples/bzlmod
platform: debian11
build_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
test_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
coverage_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
integration_test_bzlmod_macos:
<<: *reusable_build_test_all
<<: *coverage_targets_example_bzlmod
Expand DownExpand Up@@ -438,14 +395,6 @@ tasks:
name: "examples/py_proto_library: Debian, workspace"
working_directory: examples/py_proto_library
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
integration_test_py_proto_library_macos_workspace:
<<: *reusable_build_test_all
<<: *common_workspace_flags
Expand Down
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,9 +25,6 @@ A brief description of the categories of changes:
[x.x.x]: https://github.com/bazelbuild/rules_python/releases/tag/x.x.x

### Changed
* (rules) `py_proto_library` is deprecated in favour of the
implementation in https://github.com/protocolbuffers/protobuf. It will be
removed in the future release.
* (deps) Upgrade the `pip_install` dependencies to pick up a new version of pip.
* (toolchains) Optional toolchain dependency: `py_binary`, `py_test`, and
`py_library` now depend on the `//python:exec_tools_toolchain_type` for build
Expand Down
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,9 @@ bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "platforms", version = "0.0.4")

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

internal_deps = use_extension("//python/private/bzlmod:internal_deps.bzl", "internal_deps")
use_repo(
Expand Down
6 changes: 6 additions & 0 deletions WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -148,3 +148,9 @@ http_file(
"https://files.pythonhosted.org/packages/50/67/3e966d99a07d60a21a21d7ec016e9e4c2642a86fea251ec68677daf71d4d/numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 5 additions & 0 deletions WORKSPACE.bzlmod
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,3 +55,8 @@ http_file(
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 4 additions & 1 deletion examples/bzlmod/MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,8 +11,11 @@ local_path_override(
path = "../..",
)

# (py_proto_library specific) We are using rules_proto to define rules_proto targets to be consumed by py_proto_library.
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

# (py_proto_library specific) Add the protobuf library for well-known types (e.g. `Any`, `Timestamp`, etc)
bazel_dep(name = "protobuf", version = "27.0", repo_name = "com_google_protobuf")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")

# We next initialize the python toolchain using the extension.
# You can set different Python versions in this block.
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
19 changes: 16 additions & 3 deletions examples/py_proto_library/WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,11 +24,24 @@ python_register_toolchains(
# Then we need to setup dependencies in order to use py_proto_library
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz"],
sha256 = "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
strip_prefix = "protobuf-26.1",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v26.1.tar.gz"],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
4 changes: 2 additions & 2 deletions examples/py_proto_library/example.com/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
14 changes: 11 additions & 3 deletions internal_deps.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -164,12 +164,20 @@ def rules_python_internal_deps():
],
)

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
sha256 = "75be42bd736f4df6d702a0e4e4d30de9ee40eac024c4b845d17ae4cc831fe4ae",
strip_prefix = "protobuf-21.7",
urls = [
"https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
],
)

Expand Down
4 changes: 4 additions & 0 deletions internal_setup.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@ load("@cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies")
load("@rules_bazel_integration_test//bazel_integration_test:repo_defs.bzl", "bazel_binaries")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
load("//python/pip_install:repositories.bzl", "pip_install_dependencies")
load("//python/private:internal_config_repo.bzl", "internal_config_repo") # buildifier: disable=bzl-visibility
Expand All@@ -34,6 +35,9 @@ def rules_python_internal_setup():

bazel_skylib_workspace()

rules_proto_dependencies()
rules_proto_toolchains()

protobuf_deps()

bazel_integration_test_rules_dependencies()
Expand Down
2 changes: 1 addition & 1 deletion python/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -113,7 +113,7 @@ bzl_library(
],
visibility = ["//visibility:public"],
deps = [
"@com_google_protobuf//bazel:py_proto_library_bzl",
"//python/private/proto:py_proto_library_bzl",
],
)

Expand Down
1 change: 1 addition & 0 deletions python/private/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,7 @@ filegroup(
srcs = glob(["**"]) + [
"//python/private/bzlmod:distribution",
"//python/private/common:distribution",
"//python/private/proto:distribution",
"//python/private/whl_filegroup:distribution",
"//tools/build_defs/python/private:distribution",
],
Expand Down
46 changes: 46 additions & 0 deletions python/private/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
# Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")

package(default_visibility = ["//visibility:private"])

licenses(["notice"])

filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python/private:__pkg__"],
)

bzl_library(
name = "py_proto_library_bzl",
srcs = ["py_proto_library.bzl"],
visibility = ["//python:__pkg__"],
deps = [
"//python:defs_bzl",
"@rules_proto//proto:defs",
],
)

proto_lang_toolchain(
name = "python_toolchain",
command_line = "--python_out=%s",
progress_message = "Generating Python proto_library %{label}",
runtime = "@com_google_protobuf//:protobuf_python",
# NOTE: This isn't *actually* public. It's an implicit dependency of py_proto_library,
# so must be public so user usages of the rule can reference it.
visibility = ["//visibility:public"],
)
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' revert: upgrade to protobuf 27.0 and remove py_proto_library (#1933) by aignas · Pull Request #1948 · bazel-contrib/rules_python · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 1 addition & 52 deletions .bazelci/presubmit.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -147,14 +147,6 @@ tasks:
<<: *reusable_config
name: "Default: Debian"
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
macos:
<<: *reusable_config
name: "Default: MacOS"
Expand All@@ -177,39 +169,19 @@ tasks:
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
# BazelCI sets --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1,
# which prevents cc toolchain autodetection from working correctly
# on Bazel 5.4 and earlier. To workaround this, manually specify the
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
rbe:
<<: *reusable_config
name: "RBE: Ubuntu"
platform: rbe_ubuntu1604
build_flags:
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
- "--test_tag_filters=-integration-test,-acceptance-test"

integration_test_build_file_generation_ubuntu_minimum_supported_workspace:
<<: *minimum_supported_version
Expand DownExpand Up@@ -262,21 +234,6 @@ tasks:
name: "examples/bzlmod: Debian"
working_directory: examples/bzlmod
platform: debian11
build_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
test_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
coverage_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
integration_test_bzlmod_macos:
<<: *reusable_build_test_all
<<: *coverage_targets_example_bzlmod
Expand DownExpand Up@@ -438,14 +395,6 @@ tasks:
name: "examples/py_proto_library: Debian, workspace"
working_directory: examples/py_proto_library
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
integration_test_py_proto_library_macos_workspace:
<<: *reusable_build_test_all
<<: *common_workspace_flags
Expand Down
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,9 +25,6 @@ A brief description of the categories of changes:
[x.x.x]: https://github.com/bazelbuild/rules_python/releases/tag/x.x.x

### Changed
* (rules) `py_proto_library` is deprecated in favour of the
implementation in https://github.com/protocolbuffers/protobuf. It will be
removed in the future release.
* (deps) Upgrade the `pip_install` dependencies to pick up a new version of pip.
* (toolchains) Optional toolchain dependency: `py_binary`, `py_test`, and
`py_library` now depend on the `//python:exec_tools_toolchain_type` for build
Expand Down
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,9 @@ bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "platforms", version = "0.0.4")

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

internal_deps = use_extension("//python/private/bzlmod:internal_deps.bzl", "internal_deps")
use_repo(
Expand Down
6 changes: 6 additions & 0 deletions WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -148,3 +148,9 @@ http_file(
"https://files.pythonhosted.org/packages/50/67/3e966d99a07d60a21a21d7ec016e9e4c2642a86fea251ec68677daf71d4d/numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 5 additions & 0 deletions WORKSPACE.bzlmod
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,3 +55,8 @@ http_file(
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 4 additions & 1 deletion examples/bzlmod/MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,8 +11,11 @@ local_path_override(
path = "../..",
)

# (py_proto_library specific) We are using rules_proto to define rules_proto targets to be consumed by py_proto_library.
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

# (py_proto_library specific) Add the protobuf library for well-known types (e.g. `Any`, `Timestamp`, etc)
bazel_dep(name = "protobuf", version = "27.0", repo_name = "com_google_protobuf")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")

# We next initialize the python toolchain using the extension.
# You can set different Python versions in this block.
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
19 changes: 16 additions & 3 deletions examples/py_proto_library/WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,11 +24,24 @@ python_register_toolchains(
# Then we need to setup dependencies in order to use py_proto_library
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz"],
sha256 = "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
strip_prefix = "protobuf-26.1",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v26.1.tar.gz"],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
4 changes: 2 additions & 2 deletions examples/py_proto_library/example.com/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
14 changes: 11 additions & 3 deletions internal_deps.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -164,12 +164,20 @@ def rules_python_internal_deps():
],
)

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
sha256 = "75be42bd736f4df6d702a0e4e4d30de9ee40eac024c4b845d17ae4cc831fe4ae",
strip_prefix = "protobuf-21.7",
urls = [
"https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
],
)

Expand Down
4 changes: 4 additions & 0 deletions internal_setup.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@ load("@cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies")
load("@rules_bazel_integration_test//bazel_integration_test:repo_defs.bzl", "bazel_binaries")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
load("//python/pip_install:repositories.bzl", "pip_install_dependencies")
load("//python/private:internal_config_repo.bzl", "internal_config_repo") # buildifier: disable=bzl-visibility
Expand All@@ -34,6 +35,9 @@ def rules_python_internal_setup():

bazel_skylib_workspace()

rules_proto_dependencies()
rules_proto_toolchains()

protobuf_deps()

bazel_integration_test_rules_dependencies()
Expand Down
2 changes: 1 addition & 1 deletion python/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -113,7 +113,7 @@ bzl_library(
],
visibility = ["//visibility:public"],
deps = [
"@com_google_protobuf//bazel:py_proto_library_bzl",
"//python/private/proto:py_proto_library_bzl",
],
)

Expand Down
1 change: 1 addition & 0 deletions python/private/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,7 @@ filegroup(
srcs = glob(["**"]) + [
"//python/private/bzlmod:distribution",
"//python/private/common:distribution",
"//python/private/proto:distribution",
"//python/private/whl_filegroup:distribution",
"//tools/build_defs/python/private:distribution",
],
Expand Down
46 changes: 46 additions & 0 deletions python/private/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
# Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")

package(default_visibility = ["//visibility:private"])

licenses(["notice"])

filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python/private:__pkg__"],
)

bzl_library(
name = "py_proto_library_bzl",
srcs = ["py_proto_library.bzl"],
visibility = ["//python:__pkg__"],
deps = [
"//python:defs_bzl",
"@rules_proto//proto:defs",
],
)

proto_lang_toolchain(
name = "python_toolchain",
command_line = "--python_out=%s",
progress_message = "Generating Python proto_library %{label}",
runtime = "@com_google_protobuf//:protobuf_python",
# NOTE: This isn't *actually* public. It's an implicit dependency of py_proto_library,
# so must be public so user usages of the rule can reference it.
visibility = ["//visibility:public"],
)
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' revert: upgrade to protobuf 27.0 and remove py_proto_library (#1933) by aignas · Pull Request #1948 · bazel-contrib/rules_python · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 1 addition & 52 deletions .bazelci/presubmit.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -147,14 +147,6 @@ tasks:
<<: *reusable_config
name: "Default: Debian"
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
macos:
<<: *reusable_config
name: "Default: MacOS"
Expand All@@ -177,39 +169,19 @@ tasks:
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
# BazelCI sets --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1,
# which prevents cc toolchain autodetection from working correctly
# on Bazel 5.4 and earlier. To workaround this, manually specify the
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
rbe:
<<: *reusable_config
name: "RBE: Ubuntu"
platform: rbe_ubuntu1604
build_flags:
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
- "--test_tag_filters=-integration-test,-acceptance-test"

integration_test_build_file_generation_ubuntu_minimum_supported_workspace:
<<: *minimum_supported_version
Expand DownExpand Up@@ -262,21 +234,6 @@ tasks:
name: "examples/bzlmod: Debian"
working_directory: examples/bzlmod
platform: debian11
build_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
test_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
coverage_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
integration_test_bzlmod_macos:
<<: *reusable_build_test_all
<<: *coverage_targets_example_bzlmod
Expand DownExpand Up@@ -438,14 +395,6 @@ tasks:
name: "examples/py_proto_library: Debian, workspace"
working_directory: examples/py_proto_library
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
integration_test_py_proto_library_macos_workspace:
<<: *reusable_build_test_all
<<: *common_workspace_flags
Expand Down
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,9 +25,6 @@ A brief description of the categories of changes:
[x.x.x]: https://github.com/bazelbuild/rules_python/releases/tag/x.x.x

### Changed
* (rules) `py_proto_library` is deprecated in favour of the
implementation in https://github.com/protocolbuffers/protobuf. It will be
removed in the future release.
* (deps) Upgrade the `pip_install` dependencies to pick up a new version of pip.
* (toolchains) Optional toolchain dependency: `py_binary`, `py_test`, and
`py_library` now depend on the `//python:exec_tools_toolchain_type` for build
Expand Down
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,9 @@ bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "platforms", version = "0.0.4")

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

internal_deps = use_extension("//python/private/bzlmod:internal_deps.bzl", "internal_deps")
use_repo(
Expand Down
6 changes: 6 additions & 0 deletions WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -148,3 +148,9 @@ http_file(
"https://files.pythonhosted.org/packages/50/67/3e966d99a07d60a21a21d7ec016e9e4c2642a86fea251ec68677daf71d4d/numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 5 additions & 0 deletions WORKSPACE.bzlmod
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,3 +55,8 @@ http_file(
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 4 additions & 1 deletion examples/bzlmod/MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,8 +11,11 @@ local_path_override(
path = "../..",
)

# (py_proto_library specific) We are using rules_proto to define rules_proto targets to be consumed by py_proto_library.
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

# (py_proto_library specific) Add the protobuf library for well-known types (e.g. `Any`, `Timestamp`, etc)
bazel_dep(name = "protobuf", version = "27.0", repo_name = "com_google_protobuf")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")

# We next initialize the python toolchain using the extension.
# You can set different Python versions in this block.
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
19 changes: 16 additions & 3 deletions examples/py_proto_library/WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,11 +24,24 @@ python_register_toolchains(
# Then we need to setup dependencies in order to use py_proto_library
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz"],
sha256 = "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
strip_prefix = "protobuf-26.1",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v26.1.tar.gz"],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
4 changes: 2 additions & 2 deletions examples/py_proto_library/example.com/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
14 changes: 11 additions & 3 deletions internal_deps.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -164,12 +164,20 @@ def rules_python_internal_deps():
],
)

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
sha256 = "75be42bd736f4df6d702a0e4e4d30de9ee40eac024c4b845d17ae4cc831fe4ae",
strip_prefix = "protobuf-21.7",
urls = [
"https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
],
)

Expand Down
4 changes: 4 additions & 0 deletions internal_setup.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@ load("@cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies")
load("@rules_bazel_integration_test//bazel_integration_test:repo_defs.bzl", "bazel_binaries")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
load("//python/pip_install:repositories.bzl", "pip_install_dependencies")
load("//python/private:internal_config_repo.bzl", "internal_config_repo") # buildifier: disable=bzl-visibility
Expand All@@ -34,6 +35,9 @@ def rules_python_internal_setup():

bazel_skylib_workspace()

rules_proto_dependencies()
rules_proto_toolchains()

protobuf_deps()

bazel_integration_test_rules_dependencies()
Expand Down
2 changes: 1 addition & 1 deletion python/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -113,7 +113,7 @@ bzl_library(
],
visibility = ["//visibility:public"],
deps = [
"@com_google_protobuf//bazel:py_proto_library_bzl",
"//python/private/proto:py_proto_library_bzl",
],
)

Expand Down
1 change: 1 addition & 0 deletions python/private/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,7 @@ filegroup(
srcs = glob(["**"]) + [
"//python/private/bzlmod:distribution",
"//python/private/common:distribution",
"//python/private/proto:distribution",
"//python/private/whl_filegroup:distribution",
"//tools/build_defs/python/private:distribution",
],
Expand Down
46 changes: 46 additions & 0 deletions python/private/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
# Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")

package(default_visibility = ["//visibility:private"])

licenses(["notice"])

filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python/private:__pkg__"],
)

bzl_library(
name = "py_proto_library_bzl",
srcs = ["py_proto_library.bzl"],
visibility = ["//python:__pkg__"],
deps = [
"//python:defs_bzl",
"@rules_proto//proto:defs",
],
)

proto_lang_toolchain(
name = "python_toolchain",
command_line = "--python_out=%s",
progress_message = "Generating Python proto_library %{label}",
runtime = "@com_google_protobuf//:protobuf_python",
# NOTE: This isn't *actually* public. It's an implicit dependency of py_proto_library,
# so must be public so user usages of the rule can reference it.
visibility = ["//visibility:public"],
)
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' revert: upgrade to protobuf 27.0 and remove py_proto_library (#1933) by aignas · Pull Request #1948 · bazel-contrib/rules_python · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 1 addition & 52 deletions .bazelci/presubmit.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -147,14 +147,6 @@ tasks:
<<: *reusable_config
name: "Default: Debian"
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
macos:
<<: *reusable_config
name: "Default: MacOS"
Expand All@@ -177,39 +169,19 @@ tasks:
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
# BazelCI sets --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1,
# which prevents cc toolchain autodetection from working correctly
# on Bazel 5.4 and earlier. To workaround this, manually specify the
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
rbe:
<<: *reusable_config
name: "RBE: Ubuntu"
platform: rbe_ubuntu1604
build_flags:
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
- "--test_tag_filters=-integration-test,-acceptance-test"

integration_test_build_file_generation_ubuntu_minimum_supported_workspace:
<<: *minimum_supported_version
Expand DownExpand Up@@ -262,21 +234,6 @@ tasks:
name: "examples/bzlmod: Debian"
working_directory: examples/bzlmod
platform: debian11
build_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
test_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
coverage_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
integration_test_bzlmod_macos:
<<: *reusable_build_test_all
<<: *coverage_targets_example_bzlmod
Expand DownExpand Up@@ -438,14 +395,6 @@ tasks:
name: "examples/py_proto_library: Debian, workspace"
working_directory: examples/py_proto_library
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
integration_test_py_proto_library_macos_workspace:
<<: *reusable_build_test_all
<<: *common_workspace_flags
Expand Down
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,9 +25,6 @@ A brief description of the categories of changes:
[x.x.x]: https://github.com/bazelbuild/rules_python/releases/tag/x.x.x

### Changed
* (rules) `py_proto_library` is deprecated in favour of the
implementation in https://github.com/protocolbuffers/protobuf. It will be
removed in the future release.
* (deps) Upgrade the `pip_install` dependencies to pick up a new version of pip.
* (toolchains) Optional toolchain dependency: `py_binary`, `py_test`, and
`py_library` now depend on the `//python:exec_tools_toolchain_type` for build
Expand Down
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,9 @@ bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "platforms", version = "0.0.4")

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

internal_deps = use_extension("//python/private/bzlmod:internal_deps.bzl", "internal_deps")
use_repo(
Expand Down
6 changes: 6 additions & 0 deletions WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -148,3 +148,9 @@ http_file(
"https://files.pythonhosted.org/packages/50/67/3e966d99a07d60a21a21d7ec016e9e4c2642a86fea251ec68677daf71d4d/numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 5 additions & 0 deletions WORKSPACE.bzlmod
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,3 +55,8 @@ http_file(
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 4 additions & 1 deletion examples/bzlmod/MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,8 +11,11 @@ local_path_override(
path = "../..",
)

# (py_proto_library specific) We are using rules_proto to define rules_proto targets to be consumed by py_proto_library.
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

# (py_proto_library specific) Add the protobuf library for well-known types (e.g. `Any`, `Timestamp`, etc)
bazel_dep(name = "protobuf", version = "27.0", repo_name = "com_google_protobuf")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")

# We next initialize the python toolchain using the extension.
# You can set different Python versions in this block.
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
19 changes: 16 additions & 3 deletions examples/py_proto_library/WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,11 +24,24 @@ python_register_toolchains(
# Then we need to setup dependencies in order to use py_proto_library
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz"],
sha256 = "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
strip_prefix = "protobuf-26.1",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v26.1.tar.gz"],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
4 changes: 2 additions & 2 deletions examples/py_proto_library/example.com/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
14 changes: 11 additions & 3 deletions internal_deps.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -164,12 +164,20 @@ def rules_python_internal_deps():
],
)

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
sha256 = "75be42bd736f4df6d702a0e4e4d30de9ee40eac024c4b845d17ae4cc831fe4ae",
strip_prefix = "protobuf-21.7",
urls = [
"https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
],
)

Expand Down
4 changes: 4 additions & 0 deletions internal_setup.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@ load("@cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies")
load("@rules_bazel_integration_test//bazel_integration_test:repo_defs.bzl", "bazel_binaries")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
load("//python/pip_install:repositories.bzl", "pip_install_dependencies")
load("//python/private:internal_config_repo.bzl", "internal_config_repo") # buildifier: disable=bzl-visibility
Expand All@@ -34,6 +35,9 @@ def rules_python_internal_setup():

bazel_skylib_workspace()

rules_proto_dependencies()
rules_proto_toolchains()

protobuf_deps()

bazel_integration_test_rules_dependencies()
Expand Down
2 changes: 1 addition & 1 deletion python/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -113,7 +113,7 @@ bzl_library(
],
visibility = ["//visibility:public"],
deps = [
"@com_google_protobuf//bazel:py_proto_library_bzl",
"//python/private/proto:py_proto_library_bzl",
],
)

Expand Down
1 change: 1 addition & 0 deletions python/private/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,7 @@ filegroup(
srcs = glob(["**"]) + [
"//python/private/bzlmod:distribution",
"//python/private/common:distribution",
"//python/private/proto:distribution",
"//python/private/whl_filegroup:distribution",
"//tools/build_defs/python/private:distribution",
],
Expand Down
46 changes: 46 additions & 0 deletions python/private/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
# Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")

package(default_visibility = ["//visibility:private"])

licenses(["notice"])

filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python/private:__pkg__"],
)

bzl_library(
name = "py_proto_library_bzl",
srcs = ["py_proto_library.bzl"],
visibility = ["//python:__pkg__"],
deps = [
"//python:defs_bzl",
"@rules_proto//proto:defs",
],
)

proto_lang_toolchain(
name = "python_toolchain",
command_line = "--python_out=%s",
progress_message = "Generating Python proto_library %{label}",
runtime = "@com_google_protobuf//:protobuf_python",
# NOTE: This isn't *actually* public. It's an implicit dependency of py_proto_library,
# so must be public so user usages of the rule can reference it.
visibility = ["//visibility:public"],
)
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' revert: upgrade to protobuf 27.0 and remove py_proto_library (#1933) by aignas · Pull Request #1948 · bazel-contrib/rules_python · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 1 addition & 52 deletions .bazelci/presubmit.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -147,14 +147,6 @@ tasks:
<<: *reusable_config
name: "Default: Debian"
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
macos:
<<: *reusable_config
name: "Default: MacOS"
Expand All@@ -177,39 +169,19 @@ tasks:
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
# BazelCI sets --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1,
# which prevents cc toolchain autodetection from working correctly
# on Bazel 5.4 and earlier. To workaround this, manually specify the
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
rbe:
<<: *reusable_config
name: "RBE: Ubuntu"
platform: rbe_ubuntu1604
build_flags:
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
- "--test_tag_filters=-integration-test,-acceptance-test"

integration_test_build_file_generation_ubuntu_minimum_supported_workspace:
<<: *minimum_supported_version
Expand DownExpand Up@@ -262,21 +234,6 @@ tasks:
name: "examples/bzlmod: Debian"
working_directory: examples/bzlmod
platform: debian11
build_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
test_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
coverage_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
integration_test_bzlmod_macos:
<<: *reusable_build_test_all
<<: *coverage_targets_example_bzlmod
Expand DownExpand Up@@ -438,14 +395,6 @@ tasks:
name: "examples/py_proto_library: Debian, workspace"
working_directory: examples/py_proto_library
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
integration_test_py_proto_library_macos_workspace:
<<: *reusable_build_test_all
<<: *common_workspace_flags
Expand Down
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,9 +25,6 @@ A brief description of the categories of changes:
[x.x.x]: https://github.com/bazelbuild/rules_python/releases/tag/x.x.x

### Changed
* (rules) `py_proto_library` is deprecated in favour of the
implementation in https://github.com/protocolbuffers/protobuf. It will be
removed in the future release.
* (deps) Upgrade the `pip_install` dependencies to pick up a new version of pip.
* (toolchains) Optional toolchain dependency: `py_binary`, `py_test`, and
`py_library` now depend on the `//python:exec_tools_toolchain_type` for build
Expand Down
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,9 @@ bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "platforms", version = "0.0.4")

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

internal_deps = use_extension("//python/private/bzlmod:internal_deps.bzl", "internal_deps")
use_repo(
Expand Down
6 changes: 6 additions & 0 deletions WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -148,3 +148,9 @@ http_file(
"https://files.pythonhosted.org/packages/50/67/3e966d99a07d60a21a21d7ec016e9e4c2642a86fea251ec68677daf71d4d/numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 5 additions & 0 deletions WORKSPACE.bzlmod
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,3 +55,8 @@ http_file(
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 4 additions & 1 deletion examples/bzlmod/MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,8 +11,11 @@ local_path_override(
path = "../..",
)

# (py_proto_library specific) We are using rules_proto to define rules_proto targets to be consumed by py_proto_library.
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

# (py_proto_library specific) Add the protobuf library for well-known types (e.g. `Any`, `Timestamp`, etc)
bazel_dep(name = "protobuf", version = "27.0", repo_name = "com_google_protobuf")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")

# We next initialize the python toolchain using the extension.
# You can set different Python versions in this block.
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
19 changes: 16 additions & 3 deletions examples/py_proto_library/WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,11 +24,24 @@ python_register_toolchains(
# Then we need to setup dependencies in order to use py_proto_library
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz"],
sha256 = "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
strip_prefix = "protobuf-26.1",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v26.1.tar.gz"],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
4 changes: 2 additions & 2 deletions examples/py_proto_library/example.com/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
14 changes: 11 additions & 3 deletions internal_deps.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -164,12 +164,20 @@ def rules_python_internal_deps():
],
)

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
sha256 = "75be42bd736f4df6d702a0e4e4d30de9ee40eac024c4b845d17ae4cc831fe4ae",
strip_prefix = "protobuf-21.7",
urls = [
"https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
],
)

Expand Down
4 changes: 4 additions & 0 deletions internal_setup.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@ load("@cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies")
load("@rules_bazel_integration_test//bazel_integration_test:repo_defs.bzl", "bazel_binaries")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
load("//python/pip_install:repositories.bzl", "pip_install_dependencies")
load("//python/private:internal_config_repo.bzl", "internal_config_repo") # buildifier: disable=bzl-visibility
Expand All@@ -34,6 +35,9 @@ def rules_python_internal_setup():

bazel_skylib_workspace()

rules_proto_dependencies()
rules_proto_toolchains()

protobuf_deps()

bazel_integration_test_rules_dependencies()
Expand Down
2 changes: 1 addition & 1 deletion python/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -113,7 +113,7 @@ bzl_library(
],
visibility = ["//visibility:public"],
deps = [
"@com_google_protobuf//bazel:py_proto_library_bzl",
"//python/private/proto:py_proto_library_bzl",
],
)

Expand Down
1 change: 1 addition & 0 deletions python/private/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,7 @@ filegroup(
srcs = glob(["**"]) + [
"//python/private/bzlmod:distribution",
"//python/private/common:distribution",
"//python/private/proto:distribution",
"//python/private/whl_filegroup:distribution",
"//tools/build_defs/python/private:distribution",
],
Expand Down
46 changes: 46 additions & 0 deletions python/private/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
# Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")

package(default_visibility = ["//visibility:private"])

licenses(["notice"])

filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python/private:__pkg__"],
)

bzl_library(
name = "py_proto_library_bzl",
srcs = ["py_proto_library.bzl"],
visibility = ["//python:__pkg__"],
deps = [
"//python:defs_bzl",
"@rules_proto//proto:defs",
],
)

proto_lang_toolchain(
name = "python_toolchain",
command_line = "--python_out=%s",
progress_message = "Generating Python proto_library %{label}",
runtime = "@com_google_protobuf//:protobuf_python",
# NOTE: This isn't *actually* public. It's an implicit dependency of py_proto_library,
# so must be public so user usages of the rule can reference it.
visibility = ["//visibility:public"],
)
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' revert: upgrade to protobuf 27.0 and remove py_proto_library (#1933) by aignas · Pull Request #1948 · bazel-contrib/rules_python · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 1 addition & 52 deletions .bazelci/presubmit.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -147,14 +147,6 @@ tasks:
<<: *reusable_config
name: "Default: Debian"
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
macos:
<<: *reusable_config
name: "Default: MacOS"
Expand All@@ -177,39 +169,19 @@ tasks:
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
# BazelCI sets --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1,
# which prevents cc toolchain autodetection from working correctly
# on Bazel 5.4 and earlier. To workaround this, manually specify the
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
rbe:
<<: *reusable_config
name: "RBE: Ubuntu"
platform: rbe_ubuntu1604
build_flags:
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
- "--test_tag_filters=-integration-test,-acceptance-test"

integration_test_build_file_generation_ubuntu_minimum_supported_workspace:
<<: *minimum_supported_version
Expand DownExpand Up@@ -262,21 +234,6 @@ tasks:
name: "examples/bzlmod: Debian"
working_directory: examples/bzlmod
platform: debian11
build_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
test_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
coverage_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
integration_test_bzlmod_macos:
<<: *reusable_build_test_all
<<: *coverage_targets_example_bzlmod
Expand DownExpand Up@@ -438,14 +395,6 @@ tasks:
name: "examples/py_proto_library: Debian, workspace"
working_directory: examples/py_proto_library
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
integration_test_py_proto_library_macos_workspace:
<<: *reusable_build_test_all
<<: *common_workspace_flags
Expand Down
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,9 +25,6 @@ A brief description of the categories of changes:
[x.x.x]: https://github.com/bazelbuild/rules_python/releases/tag/x.x.x

### Changed
* (rules) `py_proto_library` is deprecated in favour of the
implementation in https://github.com/protocolbuffers/protobuf. It will be
removed in the future release.
* (deps) Upgrade the `pip_install` dependencies to pick up a new version of pip.
* (toolchains) Optional toolchain dependency: `py_binary`, `py_test`, and
`py_library` now depend on the `//python:exec_tools_toolchain_type` for build
Expand Down
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,9 @@ bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "platforms", version = "0.0.4")

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

internal_deps = use_extension("//python/private/bzlmod:internal_deps.bzl", "internal_deps")
use_repo(
Expand Down
6 changes: 6 additions & 0 deletions WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -148,3 +148,9 @@ http_file(
"https://files.pythonhosted.org/packages/50/67/3e966d99a07d60a21a21d7ec016e9e4c2642a86fea251ec68677daf71d4d/numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 5 additions & 0 deletions WORKSPACE.bzlmod
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,3 +55,8 @@ http_file(
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 4 additions & 1 deletion examples/bzlmod/MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,8 +11,11 @@ local_path_override(
path = "../..",
)

# (py_proto_library specific) We are using rules_proto to define rules_proto targets to be consumed by py_proto_library.
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

# (py_proto_library specific) Add the protobuf library for well-known types (e.g. `Any`, `Timestamp`, etc)
bazel_dep(name = "protobuf", version = "27.0", repo_name = "com_google_protobuf")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")

# We next initialize the python toolchain using the extension.
# You can set different Python versions in this block.
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
19 changes: 16 additions & 3 deletions examples/py_proto_library/WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,11 +24,24 @@ python_register_toolchains(
# Then we need to setup dependencies in order to use py_proto_library
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz"],
sha256 = "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
strip_prefix = "protobuf-26.1",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v26.1.tar.gz"],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
4 changes: 2 additions & 2 deletions examples/py_proto_library/example.com/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
14 changes: 11 additions & 3 deletions internal_deps.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -164,12 +164,20 @@ def rules_python_internal_deps():
],
)

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
sha256 = "75be42bd736f4df6d702a0e4e4d30de9ee40eac024c4b845d17ae4cc831fe4ae",
strip_prefix = "protobuf-21.7",
urls = [
"https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
],
)

Expand Down
4 changes: 4 additions & 0 deletions internal_setup.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@ load("@cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies")
load("@rules_bazel_integration_test//bazel_integration_test:repo_defs.bzl", "bazel_binaries")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
load("//python/pip_install:repositories.bzl", "pip_install_dependencies")
load("//python/private:internal_config_repo.bzl", "internal_config_repo") # buildifier: disable=bzl-visibility
Expand All@@ -34,6 +35,9 @@ def rules_python_internal_setup():

bazel_skylib_workspace()

rules_proto_dependencies()
rules_proto_toolchains()

protobuf_deps()

bazel_integration_test_rules_dependencies()
Expand Down
2 changes: 1 addition & 1 deletion python/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -113,7 +113,7 @@ bzl_library(
],
visibility = ["//visibility:public"],
deps = [
"@com_google_protobuf//bazel:py_proto_library_bzl",
"//python/private/proto:py_proto_library_bzl",
],
)

Expand Down
1 change: 1 addition & 0 deletions python/private/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,7 @@ filegroup(
srcs = glob(["**"]) + [
"//python/private/bzlmod:distribution",
"//python/private/common:distribution",
"//python/private/proto:distribution",
"//python/private/whl_filegroup:distribution",
"//tools/build_defs/python/private:distribution",
],
Expand Down
46 changes: 46 additions & 0 deletions python/private/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
# Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")

package(default_visibility = ["//visibility:private"])

licenses(["notice"])

filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python/private:__pkg__"],
)

bzl_library(
name = "py_proto_library_bzl",
srcs = ["py_proto_library.bzl"],
visibility = ["//python:__pkg__"],
deps = [
"//python:defs_bzl",
"@rules_proto//proto:defs",
],
)

proto_lang_toolchain(
name = "python_toolchain",
command_line = "--python_out=%s",
progress_message = "Generating Python proto_library %{label}",
runtime = "@com_google_protobuf//:protobuf_python",
# NOTE: This isn't *actually* public. It's an implicit dependency of py_proto_library,
# so must be public so user usages of the rule can reference it.
visibility = ["//visibility:public"],
)
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); revert: upgrade to protobuf 27.0 and remove py_proto_library (#1933) by aignas · Pull Request #1948 · bazel-contrib/rules_python · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 1 addition & 52 deletions .bazelci/presubmit.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -147,14 +147,6 @@ tasks:
<<: *reusable_config
name: "Default: Debian"
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
macos:
<<: *reusable_config
name: "Default: MacOS"
Expand All@@ -177,39 +169,19 @@ tasks:
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
# BazelCI sets --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1,
# which prevents cc toolchain autodetection from working correctly
# on Bazel 5.4 and earlier. To workaround this, manually specify the
# build kite cc toolchain.
- "--extra_toolchains=@buildkite_config//config:cc-toolchain"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
rbe:
<<: *reusable_config
name: "RBE: Ubuntu"
platform: rbe_ubuntu1604
build_flags:
- "--build_tag_filters=-docs"
build_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
test_flags:
- "--test_tag_filters=-integration-test,-acceptance-test,-docs"
test_targets:
- "--"
- "..."
- '-//sphinxdocs/...' # protobuf compilation fails
- '-//docs/...'
- "--test_tag_filters=-integration-test,-acceptance-test"

integration_test_build_file_generation_ubuntu_minimum_supported_workspace:
<<: *minimum_supported_version
Expand DownExpand Up@@ -262,21 +234,6 @@ tasks:
name: "examples/bzlmod: Debian"
working_directory: examples/bzlmod
platform: debian11
build_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
test_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
coverage_targets:
# For protobuf compilation
- "--"
- "..."
- "-//py_proto_library/..."
integration_test_bzlmod_macos:
<<: *reusable_build_test_all
<<: *coverage_targets_example_bzlmod
Expand DownExpand Up@@ -438,14 +395,6 @@ tasks:
name: "examples/py_proto_library: Debian, workspace"
working_directory: examples/py_proto_library
platform: debian11
build_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
test_flags:
# For protobuf compilation
- '--host_copt=-Wno-deprecated-declarations'
- '--copt=-Wno-deprecated-declarations'
integration_test_py_proto_library_macos_workspace:
<<: *reusable_build_test_all
<<: *common_workspace_flags
Expand Down
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,9 +25,6 @@ A brief description of the categories of changes:
[x.x.x]: https://github.com/bazelbuild/rules_python/releases/tag/x.x.x

### Changed
* (rules) `py_proto_library` is deprecated in favour of the
implementation in https://github.com/protocolbuffers/protobuf. It will be
removed in the future release.
* (deps) Upgrade the `pip_install` dependencies to pick up a new version of pip.
* (toolchains) Optional toolchain dependency: `py_binary`, `py_test`, and
`py_library` now depend on the `//python:exec_tools_toolchain_type` for build
Expand Down
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,9 @@ bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "platforms", version = "0.0.4")

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

internal_deps = use_extension("//python/private/bzlmod:internal_deps.bzl", "internal_deps")
use_repo(
Expand Down
6 changes: 6 additions & 0 deletions WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -148,3 +148,9 @@ http_file(
"https://files.pythonhosted.org/packages/50/67/3e966d99a07d60a21a21d7ec016e9e4c2642a86fea251ec68677daf71d4d/numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 5 additions & 0 deletions WORKSPACE.bzlmod
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,3 +55,8 @@ http_file(
],
)

# rules_proto expects //external:python_headers to point at the python headers.
bind(
name = "python_headers",
actual = "//python/cc:current_py_cc_headers",
)
5 changes: 4 additions & 1 deletion examples/bzlmod/MODULE.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,8 +11,11 @@ local_path_override(
path = "../..",
)

# (py_proto_library specific) We are using rules_proto to define rules_proto targets to be consumed by py_proto_library.
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

# (py_proto_library specific) Add the protobuf library for well-known types (e.g. `Any`, `Timestamp`, etc)
bazel_dep(name = "protobuf", version = "27.0", repo_name = "com_google_protobuf")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")

# We next initialize the python toolchain using the extension.
# You can set different Python versions in this block.
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
19 changes: 16 additions & 3 deletions examples/py_proto_library/WORKSPACE
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,11 +24,24 @@ python_register_toolchains(
# Then we need to setup dependencies in order to use py_proto_library
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz"],
sha256 = "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
strip_prefix = "protobuf-26.1",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v26.1.tar.gz"],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "message_proto_py_pb2",
Expand Down
4 changes: 2 additions & 2 deletions examples/py_proto_library/example.com/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

py_proto_library(
name = "pricetag_proto_py_pb2",
Expand Down
14 changes: 11 additions & 3 deletions internal_deps.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -164,12 +164,20 @@ def rules_python_internal_deps():
],
)

http_archive(
name = "rules_proto",
sha256 = "904a8097fae42a690c8e08d805210e40cccb069f5f9a0f6727cf4faa7bed2c9c",
strip_prefix = "rules_proto-6.0.0-rc1",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc1/rules_proto-6.0.0-rc1.tar.gz",
)

http_archive(
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
sha256 = "75be42bd736f4df6d702a0e4e4d30de9ee40eac024c4b845d17ae4cc831fe4ae",
strip_prefix = "protobuf-21.7",
urls = [
"https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
],
)

Expand Down
4 changes: 4 additions & 0 deletions internal_setup.bzl
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@ load("@cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies")
load("@rules_bazel_integration_test//bazel_integration_test:repo_defs.bzl", "bazel_binaries")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
load("//python/pip_install:repositories.bzl", "pip_install_dependencies")
load("//python/private:internal_config_repo.bzl", "internal_config_repo") # buildifier: disable=bzl-visibility
Expand All@@ -34,6 +35,9 @@ def rules_python_internal_setup():

bazel_skylib_workspace()

rules_proto_dependencies()
rules_proto_toolchains()

protobuf_deps()

bazel_integration_test_rules_dependencies()
Expand Down
2 changes: 1 addition & 1 deletion python/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -113,7 +113,7 @@ bzl_library(
],
visibility = ["//visibility:public"],
deps = [
"@com_google_protobuf//bazel:py_proto_library_bzl",
"//python/private/proto:py_proto_library_bzl",
],
)

Expand Down
1 change: 1 addition & 0 deletions python/private/BUILD.bazel
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,7 @@ filegroup(
srcs = glob(["**"]) + [
"//python/private/bzlmod:distribution",
"//python/private/common:distribution",
"//python/private/proto:distribution",
"//python/private/whl_filegroup:distribution",
"//tools/build_defs/python/private:distribution",
],
Expand Down
46 changes: 46 additions & 0 deletions python/private/proto/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
# Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")

package(default_visibility = ["//visibility:private"])

licenses(["notice"])

filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python/private:__pkg__"],
)

bzl_library(
name = "py_proto_library_bzl",
srcs = ["py_proto_library.bzl"],
visibility = ["//python:__pkg__"],
deps = [
"//python:defs_bzl",
"@rules_proto//proto:defs",
],
)

proto_lang_toolchain(
name = "python_toolchain",
command_line = "--python_out=%s",
progress_message = "Generating Python proto_library %{label}",
runtime = "@com_google_protobuf//:protobuf_python",
# NOTE: This isn't *actually* public. It's an implicit dependency of py_proto_library,
# so must be public so user usages of the rule can reference it.
visibility = ["//visibility:public"],
)
Loading