mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
Migrate Protobuf Python C extensions to rules_python toolchain targets.
Update _message to use rules_python's py_extension macro (which automatically injects required toolchain headers and manages shared library extensions across platforms), and update _api_implementation.so to depend directly on `@rules_python//python/cc:current_py_cc_headers` instead of `@system_python`. Using `py_extension` and `current_py_cc_headers` decouples Python C extensions from the custom system_python.bzl script while maintaining current host-interpreter behavior during the migration. #test-continuous PiperOrigin-RevId: 966345187
This commit is contained in:
parent
80d472933a
commit
720e5468ce
4 changed files with 13 additions and 13 deletions
|
|
@ -33,7 +33,7 @@ bazel_dep(name = "rules_jvm_external", version = "6.7")
|
|||
bazel_dep(name = "rules_kotlin", version = "2.3.20")
|
||||
bazel_dep(name = "rules_license", version = "1.0.0")
|
||||
bazel_dep(name = "rules_pkg", version = "1.0.1")
|
||||
bazel_dep(name = "rules_python", version = "1.6.0")
|
||||
bazel_dep(name = "rules_python", version = "2.3.0")
|
||||
bazel_dep(name = "rules_rust", version = "0.69.0")
|
||||
|
||||
bazel_dep(name = "rules_ruby", version = "0.20.1", dev_dependency = True)
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ bazel_dep(name = "bazel_skylib", version = "1.7.1")
|
|||
bazel_dep(name = "rules_cc", version = "0.2.18")
|
||||
bazel_dep(name = "rules_java", version = "8.6.1")
|
||||
bazel_dep(name = "rules_pkg", version = "1.0.1")
|
||||
bazel_dep(name = "rules_python", version = "1.6.0")
|
||||
bazel_dep(name = "rules_python", version = "2.3.0")
|
||||
|
|
|
|||
|
|
@ -131,9 +131,9 @@ def protobuf_deps():
|
|||
if not native.existing_rule("rules_python"):
|
||||
http_archive(
|
||||
name = "rules_python",
|
||||
sha256 = "fa7dd2c6b7d63b3585028dd8a90a6cf9db83c33b250959c2ee7b583a6c130e12",
|
||||
strip_prefix = "rules_python-1.6.0",
|
||||
url = "https://github.com/bazel-contrib/rules_python/releases/download/1.6.0/rules_python-1.6.0.tar.gz",
|
||||
sha256 = "70c519e8f0a5d9244c0d3496a6993bd42edf111c4499b68ce2f155c26fc8d4ee",
|
||||
strip_prefix = "rules_python-2.3.0",
|
||||
url = "https://github.com/bazel-contrib/rules_python/releases/download/2.3.0/rules_python-2.3.0.tar.gz",
|
||||
)
|
||||
|
||||
if not native.existing_rule("system_python"):
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
|
|||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
|
||||
load("@rules_python//python:defs.bzl", "py_library")
|
||||
load("@rules_python//python/cc:py_extension.bzl", "py_extension")
|
||||
load("//:protobuf.bzl", "internal_py_proto_library")
|
||||
load("//bazel/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain")
|
||||
load("//build_defs:arch_tests.bzl", "aarch64_test", "x86_64_test")
|
||||
|
|
@ -33,7 +34,7 @@ def build_targets(name):
|
|||
"//conditions:default": [],
|
||||
":use_fast_cpp_protos": [
|
||||
":google/protobuf/internal/_api_implementation.so",
|
||||
":google/protobuf/pyext/_message.so",
|
||||
":google/protobuf/pyext/_message",
|
||||
],
|
||||
}),
|
||||
visibility = ["//:__pkg__"],
|
||||
|
|
@ -99,7 +100,7 @@ def build_targets(name):
|
|||
# https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes
|
||||
"manual",
|
||||
],
|
||||
deps = ["@system_python//:python_headers"],
|
||||
deps = ["@rules_python//python/cc:current_py_cc_headers"],
|
||||
)
|
||||
|
||||
native.config_setting(
|
||||
|
|
@ -114,8 +115,8 @@ def build_targets(name):
|
|||
visibility = ["//python:__subpackages__"],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "google/protobuf/pyext/_message.so",
|
||||
py_extension(
|
||||
name = "google/protobuf/pyext/_message",
|
||||
srcs = native.glob([
|
||||
"google/protobuf/pyext/*.cc",
|
||||
"google/protobuf/pyext/*.h",
|
||||
|
|
@ -162,7 +163,6 @@ def build_targets(name):
|
|||
"@abseil-cpp//absl/strings",
|
||||
"@abseil-cpp//absl/synchronization",
|
||||
"@abseil-cpp//absl/types:span",
|
||||
"@system_python//:python_headers",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ def build_targets(name):
|
|||
name = "aarch64_test",
|
||||
bazel_binaries = [
|
||||
"google/protobuf/internal/_api_implementation.so",
|
||||
"google/protobuf/pyext/_message.so",
|
||||
"google/protobuf/pyext/_message",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ def build_targets(name):
|
|||
name = "x86_64_test",
|
||||
bazel_binaries = [
|
||||
"google/protobuf/internal/_api_implementation.so",
|
||||
"google/protobuf/pyext/_message.so",
|
||||
"google/protobuf/pyext/_message",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -485,7 +485,7 @@ def build_targets(name):
|
|||
"@abseil-cpp//absl/log:absl_check",
|
||||
"@abseil-cpp//absl/status",
|
||||
"@abseil-cpp//absl/status:statusor",
|
||||
"@system_python//:python_headers",
|
||||
"@rules_python//python/cc:current_py_cc_headers",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue