Protocol Buffers - Google's data interchange format (grpc依赖)
https://developers.google.com/protocol-buffers/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
471 lines
13 KiB
471 lines
13 KiB
3 years ago
|
# Copyright (c) 2009-2022, Google LLC
|
||
|
# All rights reserved.
|
||
|
#
|
||
|
# Redistribution and use in source and binary forms, with or without
|
||
|
# modification, are permitted provided that the following conditions are met:
|
||
|
# * Redistributions of source code must retain the above copyright
|
||
|
# notice, this list of conditions and the following disclaimer.
|
||
|
# * Redistributions in binary form must reproduce the above copyright
|
||
|
# notice, this list of conditions and the following disclaimer in the
|
||
|
# documentation and/or other materials provided with the distribution.
|
||
|
# * Neither the name of Google LLC nor the
|
||
|
# names of its contributors may be used to endorse or promote products
|
||
|
# derived from this software without specific prior written permission.
|
||
|
#
|
||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||
|
# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY
|
||
|
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||
|
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||
|
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||
|
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||
|
# (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:py_proto_library.bzl", "py_proto_library")
|
||
|
load(":dist.bzl", "py_dist", "py_dist_module")
|
||
|
load("@bazel_skylib//lib:selects.bzl", "selects")
|
||
3 years ago
|
load("@com_google_protobuf//:protobuf_version.bzl", "PROTOBUF_PYTHON_VERSION")
|
||
1 year ago
|
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
|
||
2 years ago
|
load("@rules_pkg//:pkg.bzl", "pkg_tar")
|
||
3 years ago
|
load("@rules_python//python:packaging.bzl", "py_wheel")
|
||
3 years ago
|
load("@system_python//:version.bzl", "SYSTEM_PYTHON_VERSION")
|
||
3 years ago
|
|
||
|
licenses(["notice"])
|
||
|
|
||
|
py_dist_module(
|
||
|
name = "message_mod",
|
||
|
extension = "//python:_message_binary",
|
||
3 years ago
|
module_name = "google._upb._message",
|
||
3 years ago
|
)
|
||
|
|
||
|
py_proto_library(
|
||
|
name = "well_known_proto_py_pb2",
|
||
|
deps = [
|
||
|
"@com_google_protobuf//:any_proto",
|
||
|
"@com_google_protobuf//:api_proto",
|
||
|
"@com_google_protobuf//:descriptor_proto",
|
||
|
"@com_google_protobuf//:duration_proto",
|
||
|
"@com_google_protobuf//:empty_proto",
|
||
|
"@com_google_protobuf//:field_mask_proto",
|
||
|
"@com_google_protobuf//:source_context_proto",
|
||
|
"@com_google_protobuf//:struct_proto",
|
||
|
"@com_google_protobuf//:timestamp_proto",
|
||
|
"@com_google_protobuf//:type_proto",
|
||
|
"@com_google_protobuf//:wrappers_proto",
|
||
|
],
|
||
|
)
|
||
|
|
||
2 years ago
|
py_proto_library(
|
||
2 years ago
|
name = "plugin_py_pb2",
|
||
2 years ago
|
deps = ["@com_google_protobuf//:compiler_plugin_proto"],
|
||
|
)
|
||
|
|
||
3 years ago
|
config_setting(
|
||
2 years ago
|
name = "linux_aarch64_release",
|
||
1 year ago
|
flag_values = {
|
||
|
"@com_google_protobuf//toolchain:release": "True",
|
||
|
},
|
||
3 years ago
|
values = {"cpu": "linux-aarch_64"},
|
||
|
)
|
||
|
|
||
|
config_setting(
|
||
2 years ago
|
name = "linux_aarch64_local",
|
||
|
constraint_values = [
|
||
2 years ago
|
"@platforms//os:linux",
|
||
|
"@platforms//cpu:aarch64",
|
||
2 years ago
|
],
|
||
1 year ago
|
flag_values = {
|
||
|
"@com_google_protobuf//toolchain:release": "False",
|
||
|
},
|
||
2 years ago
|
)
|
||
|
|
||
|
config_setting(
|
||
|
name = "linux_x86_64_release",
|
||
1 year ago
|
flag_values = {
|
||
|
"@com_google_protobuf//toolchain:release": "True",
|
||
|
},
|
||
3 years ago
|
values = {"cpu": "linux-x86_64"},
|
||
|
)
|
||
|
|
||
|
config_setting(
|
||
2 years ago
|
name = "linux_x86_64_local",
|
||
|
constraint_values = [
|
||
2 years ago
|
"@platforms//os:linux",
|
||
|
"@platforms//cpu:x86_64",
|
||
2 years ago
|
],
|
||
1 year ago
|
flag_values = {
|
||
|
"@com_google_protobuf//toolchain:release": "False",
|
||
|
},
|
||
2 years ago
|
)
|
||
|
|
||
|
config_setting(
|
||
|
name = "osx_x86_64_release",
|
||
1 year ago
|
flag_values = {
|
||
|
"@com_google_protobuf//toolchain:release": "True",
|
||
|
},
|
||
3 years ago
|
values = {"cpu": "osx-x86_64"},
|
||
|
)
|
||
|
|
||
3 years ago
|
config_setting(
|
||
2 years ago
|
name = "osx_x86_64_local",
|
||
|
constraint_values = [
|
||
2 years ago
|
"@platforms//os:osx",
|
||
|
"@platforms//cpu:x86_64",
|
||
2 years ago
|
],
|
||
1 year ago
|
flag_values = {
|
||
|
"@com_google_protobuf//toolchain:release": "False",
|
||
|
},
|
||
2 years ago
|
)
|
||
|
|
||
|
selects.config_setting_group(
|
||
|
name = "osx_x86_64",
|
||
|
match_any = [
|
||
|
":osx_x86_64_release",
|
||
|
":osx_x86_64_local",
|
||
|
],
|
||
|
)
|
||
|
|
||
|
config_setting(
|
||
|
name = "osx_aarch64_release",
|
||
1 year ago
|
flag_values = {
|
||
|
"@com_google_protobuf//toolchain:release": "True",
|
||
|
},
|
||
3 years ago
|
values = {"cpu": "osx-aarch_64"},
|
||
|
)
|
||
|
|
||
3 years ago
|
config_setting(
|
||
2 years ago
|
name = "osx_aarch64_local",
|
||
|
constraint_values = [
|
||
2 years ago
|
"@platforms//os:osx",
|
||
|
"@platforms//cpu:aarch64",
|
||
2 years ago
|
],
|
||
1 year ago
|
flag_values = {
|
||
|
"@com_google_protobuf//toolchain:release": "False",
|
||
|
},
|
||
2 years ago
|
)
|
||
|
|
||
|
selects.config_setting_group(
|
||
|
name = "osx_aarch64",
|
||
|
match_any = [
|
||
|
":osx_aarch64_release",
|
||
|
":osx_aarch64_local",
|
||
|
],
|
||
|
)
|
||
|
|
||
|
config_setting(
|
||
|
name = "osx_universal2",
|
||
3 years ago
|
values = {"cpu": "osx-universal2"},
|
||
|
)
|
||
|
|
||
3 years ago
|
config_setting(
|
||
2 years ago
|
name = "windows_x86_32_release",
|
||
1 year ago
|
flag_values = {
|
||
|
"@com_google_protobuf//toolchain:release": "True",
|
||
|
},
|
||
3 years ago
|
values = {"cpu": "win32"},
|
||
|
)
|
||
|
|
||
|
config_setting(
|
||
2 years ago
|
name = "windows_x86_32_local",
|
||
|
constraint_values = [
|
||
2 years ago
|
"@platforms//os:windows",
|
||
|
"@platforms//cpu:x86_32",
|
||
2 years ago
|
],
|
||
1 year ago
|
flag_values = {
|
||
|
"@com_google_protobuf//toolchain:release": "False",
|
||
|
},
|
||
2 years ago
|
)
|
||
|
|
||
|
selects.config_setting_group(
|
||
|
name = "windows_x86_32",
|
||
|
match_any = [
|
||
|
":windows_x86_32_release",
|
||
|
":windows_x86_32_local",
|
||
|
],
|
||
|
)
|
||
|
|
||
|
config_setting(
|
||
|
name = "windows_x86_64_release",
|
||
1 year ago
|
flag_values = {
|
||
|
"@com_google_protobuf//toolchain:release": "True",
|
||
|
},
|
||
3 years ago
|
values = {"cpu": "win64"},
|
||
|
)
|
||
|
|
||
2 years ago
|
config_setting(
|
||
|
name = "windows_x86_64_local",
|
||
|
constraint_values = [
|
||
2 years ago
|
"@platforms//os:windows",
|
||
|
"@platforms//cpu:x86_64",
|
||
2 years ago
|
],
|
||
1 year ago
|
flag_values = {
|
||
|
"@com_google_protobuf//toolchain:release": "False",
|
||
|
},
|
||
2 years ago
|
)
|
||
|
|
||
|
selects.config_setting_group(
|
||
|
name = "windows_x86_64",
|
||
|
match_any = [
|
||
|
":windows_x86_64_release",
|
||
|
":windows_x86_64_local",
|
||
|
],
|
||
|
)
|
||
|
|
||
2 years ago
|
pkg_files(
|
||
|
name = "generated_wkt",
|
||
|
srcs = [
|
||
|
":well_known_proto_py_pb2",
|
||
2 years ago
|
"//:descriptor_upb_proto",
|
||
|
"//:descriptor_upb_proto_reflection",
|
||
2 years ago
|
],
|
||
|
prefix = "google/protobuf",
|
||
|
)
|
||
|
|
||
|
pkg_files(
|
||
|
name = "generated_wkt_compiler",
|
||
|
srcs = [
|
||
2 years ago
|
":plugin_py_pb2",
|
||
2 years ago
|
],
|
||
|
prefix = "google/protobuf/compiler",
|
||
|
)
|
||
|
|
||
2 years ago
|
pkg_files(
|
||
|
name = "utf8_range_source_files",
|
||
|
srcs = ["@utf8_range//:utf8_range_srcs"],
|
||
|
prefix = "utf8_range",
|
||
|
)
|
||
|
|
||
1 year ago
|
pkg_files(
|
||
|
name = "dist_source_files",
|
||
2 years ago
|
srcs = [
|
||
2 years ago
|
"MANIFEST.in",
|
||
2 years ago
|
"setup.py",
|
||
1 year ago
|
],
|
||
|
)
|
||
|
|
||
|
# Passing filegroups to pkg_tar directly results in incorrect
|
||
|
# `protobuf/external/upb/` directory structure when built from the protobuf
|
||
|
# repo. This can be removed once repositories are merged.
|
||
|
pkg_files(
|
||
|
name = "filegroup_source_files",
|
||
|
srcs = [
|
||
2 years ago
|
"//:LICENSE",
|
||
1 year ago
|
"//:source_files",
|
||
|
"//python:message_srcs",
|
||
1 year ago
|
"//upb/base:source_files",
|
||
1 year ago
|
"//upb/collections:source_files",
|
||
|
"//upb/hash:source_files",
|
||
|
"//upb/lex:source_files",
|
||
1 year ago
|
"//upb/mem:source_files",
|
||
1 year ago
|
"//upb/message:source_files",
|
||
1 year ago
|
"//upb/mini_descriptor:source_files",
|
||
1 year ago
|
"//upb/mini_table:source_files",
|
||
1 year ago
|
"//upb/port:source_files",
|
||
1 year ago
|
"//upb/text:source_files",
|
||
1 year ago
|
"//upb/util:source_files",
|
||
1 year ago
|
"//upb/wire:source_files",
|
||
1 year ago
|
],
|
||
|
strip_prefix = strip_prefix.from_root(""),
|
||
|
)
|
||
|
|
||
|
# NOTE: This package currently only works for macos and ubuntu, MSVC users
|
||
|
# should use a binary wheel.
|
||
|
pkg_tar(
|
||
|
name = "source_tarball",
|
||
|
srcs = [
|
||
|
":dist_source_files",
|
||
|
":filegroup_source_files",
|
||
|
":generated_wkt",
|
||
|
":generated_wkt_compiler",
|
||
|
":utf8_range_source_files",
|
||
2 years ago
|
"@com_google_protobuf//python:python_source_files",
|
||
|
],
|
||
2 years ago
|
extension = "tar.gz",
|
||
2 years ago
|
package_dir = "protobuf",
|
||
|
package_file_name = "protobuf.tar.gz",
|
||
1 year ago
|
strip_prefix = ".",
|
||
2 years ago
|
target_compatible_with = select({
|
||
|
"@system_python//:none": ["@platforms//:incompatible"],
|
||
|
"//conditions:default": [],
|
||
|
}),
|
||
2 years ago
|
)
|
||
|
|
||
|
genrule(
|
||
|
name = "source_wheel",
|
||
|
srcs = [":source_tarball"],
|
||
|
outs = ["protobuf-%s.tar.gz" % PROTOBUF_PYTHON_VERSION],
|
||
|
cmd = """
|
||
|
set -eux
|
||
|
tar -xzvf $(location :source_tarball)
|
||
|
cd protobuf/
|
||
|
python3 setup.py sdist
|
||
|
cd ..
|
||
|
mv protobuf/dist/*.tar.gz $@
|
||
|
""",
|
||
2 years ago
|
target_compatible_with = select({
|
||
|
"@system_python//:none": ["@platforms//:incompatible"],
|
||
|
"//conditions:default": [],
|
||
|
}),
|
||
2 years ago
|
)
|
||
|
|
||
3 years ago
|
py_wheel(
|
||
|
name = "binary_wheel",
|
||
|
abi = select({
|
||
|
"//python:full_api_3.7": "cp37m",
|
||
|
"//python:full_api_3.8": "cp38",
|
||
|
"//python:full_api_3.9": "cp39",
|
||
|
"//conditions:default": "abi3",
|
||
|
}),
|
||
3 years ago
|
author = "protobuf@googlegroups.com",
|
||
|
author_email = "protobuf@googlegroups.com",
|
||
|
classifiers = [
|
||
|
"Programming Language :: Python",
|
||
|
"Programming Language :: Python :: 3",
|
||
|
"Programming Language :: Python :: 3.7",
|
||
|
"Programming Language :: Python :: 3.8",
|
||
|
"Programming Language :: Python :: 3.9",
|
||
|
"Programming Language :: Python :: 3.10",
|
||
|
],
|
||
3 years ago
|
distribution = "protobuf",
|
||
2 years ago
|
extra_distinfo_files = {
|
||
|
"//:LICENSE": "LICENSE",
|
||
|
},
|
||
3 years ago
|
homepage = "https://developers.google.com/protocol-buffers/",
|
||
|
license = "3-Clause BSD License",
|
||
3 years ago
|
platform = select({
|
||
2 years ago
|
":linux_x86_64_local": "linux_x86_64",
|
||
|
":linux_x86_64_release": "manylinux2014_x86_64",
|
||
|
":linux_aarch64_local": "linux_aarch64",
|
||
|
":linux_aarch64_release": "manylinux2014_aarch64",
|
||
2 years ago
|
":osx_universal2": "macosx_10_9_universal2",
|
||
|
":osx_aarch64": "macosx_11_0_arm64",
|
||
|
":windows_x86_32": "win32",
|
||
|
":windows_x86_64": "win_amd64",
|
||
3 years ago
|
"//conditions:default": "any",
|
||
|
}),
|
||
3 years ago
|
python_requires = ">=3.7",
|
||
3 years ago
|
python_tag = selects.with_or({
|
||
|
("//python:limited_api_3.7", "//python:full_api_3.7"): "cp37",
|
||
|
"//python:full_api_3.8": "cp38",
|
||
|
"//python:full_api_3.9": "cp39",
|
||
|
"//python:limited_api_3.10": "cp310",
|
||
3 years ago
|
"//conditions:default": "cp" + SYSTEM_PYTHON_VERSION,
|
||
3 years ago
|
}),
|
||
3 years ago
|
strip_path_prefixes = [
|
||
|
"python/dist/",
|
||
|
"python/",
|
||
2 years ago
|
"src/",
|
||
3 years ago
|
],
|
||
2 years ago
|
target_compatible_with = select({
|
||
|
"@system_python//:none": ["@platforms//:incompatible"],
|
||
|
"//conditions:default": [],
|
||
|
}),
|
||
3 years ago
|
version = PROTOBUF_PYTHON_VERSION,
|
||
3 years ago
|
deps = [
|
||
|
":message_mod",
|
||
2 years ago
|
":plugin_py_pb2",
|
||
3 years ago
|
":well_known_proto_py_pb2",
|
||
3 years ago
|
"@com_google_protobuf//:python_srcs",
|
||
|
],
|
||
|
)
|
||
|
|
||
|
py_wheel(
|
||
|
name = "pure_python_wheel",
|
||
|
abi = "none",
|
||
3 years ago
|
author = "protobuf@googlegroups.com",
|
||
|
author_email = "protobuf@googlegroups.com",
|
||
|
classifiers = [
|
||
|
"Programming Language :: Python",
|
||
|
"Programming Language :: Python :: 3",
|
||
|
"Programming Language :: Python :: 3.7",
|
||
|
"Programming Language :: Python :: 3.8",
|
||
|
"Programming Language :: Python :: 3.9",
|
||
|
"Programming Language :: Python :: 3.10",
|
||
|
],
|
||
3 years ago
|
distribution = "protobuf",
|
||
2 years ago
|
extra_distinfo_files = {
|
||
|
"//:LICENSE": "LICENSE",
|
||
|
},
|
||
3 years ago
|
homepage = "https://developers.google.com/protocol-buffers/",
|
||
|
license = "3-Clause BSD License",
|
||
3 years ago
|
platform = "any",
|
||
3 years ago
|
python_requires = ">=3.7",
|
||
3 years ago
|
python_tag = "py3",
|
||
|
strip_path_prefixes = [
|
||
|
"python/",
|
||
2 years ago
|
"src/",
|
||
3 years ago
|
],
|
||
2 years ago
|
target_compatible_with = select({
|
||
|
"@system_python//:none": ["@platforms//:incompatible"],
|
||
|
"//conditions:default": [],
|
||
|
}),
|
||
3 years ago
|
version = PROTOBUF_PYTHON_VERSION,
|
||
3 years ago
|
deps = [
|
||
2 years ago
|
":plugin_py_pb2",
|
||
3 years ago
|
":well_known_proto_py_pb2",
|
||
3 years ago
|
"@com_google_protobuf//:python_srcs",
|
||
|
],
|
||
|
)
|
||
|
|
||
3 years ago
|
py_wheel(
|
||
|
name = "test_wheel",
|
||
2 years ago
|
testonly = True,
|
||
3 years ago
|
abi = "none",
|
||
|
distribution = "protobuftests",
|
||
2 years ago
|
extra_distinfo_files = {
|
||
|
"//:LICENSE": "LICENSE",
|
||
|
},
|
||
3 years ago
|
platform = "any",
|
||
|
python_tag = "py3",
|
||
2 years ago
|
strip_path_prefixes = [
|
||
|
"python/",
|
||
|
"src/",
|
||
|
],
|
||
2 years ago
|
target_compatible_with = select({
|
||
|
"@system_python//:none": ["@platforms//:incompatible"],
|
||
|
"//conditions:default": [],
|
||
|
}),
|
||
3 years ago
|
version = PROTOBUF_PYTHON_VERSION,
|
||
3 years ago
|
deps = [
|
||
|
"//python/pb_unit_tests:test_files",
|
||
|
"@com_google_protobuf//:python_common_test_protos",
|
||
|
"@com_google_protobuf//:python_specific_test_protos",
|
||
|
"@com_google_protobuf//:python_test_srcs",
|
||
2 years ago
|
"@com_google_protobuf//src/google/protobuf:testdata",
|
||
3 years ago
|
],
|
||
|
)
|
||
|
|
||
3 years ago
|
py_dist(
|
||
|
name = "dist",
|
||
|
binary_wheel = ":binary_wheel",
|
||
|
full_api_cpus = [
|
||
3 years ago
|
# TODO(b/231485326): fix win32 build
|
||
3 years ago
|
"win32",
|
||
3 years ago
|
"win64",
|
||
|
],
|
||
|
# Windows needs version-specific wheels until 3.10.
|
||
|
full_api_versions = [
|
||
|
"37",
|
||
|
"38",
|
||
|
"39",
|
||
|
],
|
||
|
# Limited API: these wheels will satisfy any Python version >= the
|
||
|
# given version.
|
||
|
#
|
||
|
# Technically the limited API doesn't have the functions we need until
|
||
|
# 3.10, but on Linux we can get away with using 3.7 (see ../python_api.h for
|
||
|
# details).
|
||
|
limited_api_wheels = {
|
||
3 years ago
|
# TODO(b/231485326): fix win32 build
|
||
3 years ago
|
"win32": "310",
|
||
3 years ago
|
"win64": "310",
|
||
|
"linux-x86_64": "37",
|
||
|
"linux-aarch_64": "37",
|
||
3 years ago
|
"osx-universal2": "37",
|
||
3 years ago
|
},
|
||
3 years ago
|
pure_python_wheel = ":pure_python_wheel",
|
||
3 years ago
|
tags = ["manual"],
|
||
|
)
|