From 1e75fbf2c2b5457839d3576c9634d2933263c9b2 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sat, 26 Feb 2022 09:55:13 -0800 Subject: [PATCH] Ported api_implementation to py_extension(). --- bazel/py_extension.bzl | 2 +- python/BUILD | 34 +++++++--------------------------- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/bazel/py_extension.bzl b/bazel/py_extension.bzl index 7c1adf4146..beee32148f 100644 --- a/bazel/py_extension.bzl +++ b/bazel/py_extension.bzl @@ -4,7 +4,7 @@ load( "UPB_DEFAULT_COPTS", ) -def py_extension(name, srcs, deps): +def py_extension(name, srcs, deps=[]): version_script = name + "_version_script.lds" symbol = "PyInit_" + name native.genrule( diff --git a/python/BUILD b/python/BUILD index 687ebe6003..369f09701e 100644 --- a/python/BUILD +++ b/python/BUILD @@ -23,22 +23,9 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -load( - "//bazel:build_defs.bzl", - "UPB_DEFAULT_COPTS", -) -load( - "//bazel:py_proto_library.bzl", - "py_proto_library", -) -load( - "//bazel:py_extension.bzl", - "py_extension", -) -load( - "@rules_python//python:packaging.bzl", - "py_wheel", -) +load("//bazel:py_proto_library.bzl", "py_proto_library") +load("//bazel:py_extension.bzl", "py_extension") # copybara:strip_for_google3_begin +load("@rules_python//python:packaging.bzl", "py_wheel") licenses(["notice"]) @@ -76,16 +63,9 @@ py_extension( ], ) -cc_binary( - name = "api_implementation", - srcs = [ - "api_implementation.c", - ], - linkshared = True, - linkstatic = True, - # Enable once linker script is available. - #copts = ["-fvisibility=hidden"], - deps = ["@system_python//:python_headers"], +py_extension( + name = "_api_implementation", + srcs = ["api_implementation.c"], ) # Copy the extensions into the location recognized by Python. @@ -101,7 +81,7 @@ genrule( genrule( name = "copy_api_implementation", - srcs = [":api_implementation"], + srcs = [":_api_implementation"], outs = ["google/protobuf/internal/_api_implementation" + EXT_SUFFIX], cmd = "cp $< $@", visibility = ["//python:__subpackages__"],