David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 1 | # Protobuf Python runtime |
| 2 | # |
| 3 | # See also code generation logic under /src/google/protobuf/compiler/python. |
| 4 | # |
| 5 | # Most users should depend upon public aliases in the root: |
| 6 | # //:protobuf_python |
| 7 | # //:well_known_types_py_pb2 |
| 8 | |
| 9 | load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 10 | load("@rules_python//python:defs.bzl", "py_library") |
zhangskz | edb7ef9 | 2022-10-05 21:45:16 +0000 | [diff] [blame] | 11 | load("@pip_deps//:requirements.bzl", "requirement") |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 12 | load("//:protobuf.bzl", "internal_py_proto_library") |
Mike Kruskal | 9baae6a | 2022-12-14 21:51:34 -0800 | [diff] [blame] | 13 | load("//build_defs:arch_tests.bzl", "aarch64_test", "x86_64_test") |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 14 | load("//build_defs:cpp_opts.bzl", "COPTS") |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 15 | load("//conformance:defs.bzl", "conformance_test") |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 16 | load(":internal.bzl", "internal_copy_files", "internal_py_test") |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 17 | |
| 18 | py_library( |
| 19 | name = "protobuf_python", |
| 20 | data = select({ |
| 21 | "//conditions:default": [], |
| 22 | ":use_fast_cpp_protos": [ |
| 23 | ":google/protobuf/internal/_api_implementation.so", |
| 24 | ":google/protobuf/pyext/_message.so", |
| 25 | ], |
| 26 | }), |
| 27 | visibility = ["//:__pkg__"], |
| 28 | deps = [ |
| 29 | ":python_srcs", |
| 30 | ":well_known_types_py_pb2", |
| 31 | ], |
| 32 | ) |
| 33 | |
| 34 | config_setting( |
| 35 | name = "use_fast_cpp_protos", |
| 36 | values = { |
| 37 | "define": "use_fast_cpp_protos=true", |
| 38 | }, |
| 39 | ) |
| 40 | |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 41 | internal_py_proto_library( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 42 | name = "well_known_types_py_pb2", |
| 43 | srcs = [":copied_wkt_proto_files"], |
| 44 | include = ".", |
| 45 | default_runtime = "", |
| 46 | protoc = "//:protoc", |
| 47 | srcs_version = "PY2AND3", |
| 48 | visibility = [ |
| 49 | "//:__pkg__", |
| 50 | "@upb//:__subpackages__", |
| 51 | ], |
| 52 | ) |
| 53 | |
| 54 | internal_copy_files( |
| 55 | name = "copied_wkt_proto_files", |
| 56 | srcs = [ |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 57 | "//:well_known_type_protos", |
Mike Kruskal | ca4b063 | 2022-08-11 20:55:01 -0700 | [diff] [blame] | 58 | "//src/google/protobuf:descriptor_proto_srcs", |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 59 | ], |
| 60 | strip_prefix = "src", |
| 61 | ) |
| 62 | |
| 63 | cc_binary( |
| 64 | name = "google/protobuf/internal/_api_implementation.so", |
| 65 | srcs = ["google/protobuf/internal/api_implementation.cc"], |
| 66 | copts = COPTS + [ |
| 67 | "-DPYTHON_PROTO2_CPP_IMPL_V2", |
| 68 | ], |
| 69 | linkshared = 1, |
| 70 | linkstatic = 1, |
| 71 | tags = [ |
| 72 | # Exclude this target from wildcard expansion (//...) because it may |
| 73 | # not even be buildable. It will be built if it is needed according |
| 74 | # to :use_fast_cpp_protos. |
| 75 | # https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes |
| 76 | "manual", |
| 77 | ], |
| 78 | deps = select({ |
| 79 | "//conditions:default": [], |
| 80 | ":use_fast_cpp_protos": ["//external:python_headers"], |
| 81 | }), |
| 82 | ) |
| 83 | |
| 84 | config_setting( |
| 85 | name = "allow_oversize_protos", |
| 86 | values = { |
| 87 | "define": "allow_oversize_protos=true", |
| 88 | }, |
| 89 | ) |
| 90 | |
| 91 | cc_binary( |
| 92 | name = "google/protobuf/pyext/_message.so", |
| 93 | srcs = glob([ |
| 94 | "google/protobuf/pyext/*.cc", |
| 95 | "google/protobuf/pyext/*.h", |
| 96 | ]), |
| 97 | copts = COPTS + [ |
| 98 | "-DGOOGLE_PROTOBUF_HAS_ONEOF=1", |
| 99 | ] + select({ |
| 100 | "//conditions:default": [], |
| 101 | ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"], |
| 102 | }), |
| 103 | includes = ["."], |
| 104 | linkshared = 1, |
| 105 | linkstatic = 1, |
| 106 | tags = [ |
| 107 | # Exclude this target from wildcard expansion (//...) because it may |
| 108 | # not even be buildable. It will be built if it is needed according |
| 109 | # to :use_fast_cpp_protos. |
| 110 | # https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes |
| 111 | "manual", |
| 112 | ], |
| 113 | deps = [ |
| 114 | ":proto_api", |
| 115 | "//:protobuf", |
| 116 | ] + select({ |
| 117 | "//conditions:default": [], |
| 118 | ":use_fast_cpp_protos": ["//external:python_headers"], |
| 119 | }), |
| 120 | ) |
| 121 | |
Mike Kruskal | 9baae6a | 2022-12-14 21:51:34 -0800 | [diff] [blame] | 122 | aarch64_test( |
| 123 | name = "aarch64_test", |
| 124 | bazel_binaries = [ |
| 125 | "google/protobuf/internal/_api_implementation.so", |
| 126 | "google/protobuf/pyext/_message.so", |
| 127 | ], |
| 128 | ) |
| 129 | |
| 130 | x86_64_test( |
| 131 | name = "x86_64_test", |
| 132 | bazel_binaries = [ |
| 133 | "google/protobuf/internal/_api_implementation.so", |
| 134 | "google/protobuf/pyext/_message.so", |
| 135 | ], |
| 136 | ) |
| 137 | |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 138 | py_library( |
| 139 | name = "python_srcs", |
| 140 | srcs = glob( |
| 141 | [ |
| 142 | "google/protobuf/**/*.py", |
| 143 | ], |
| 144 | exclude = [ |
| 145 | "google/protobuf/internal/*_test.py", |
| 146 | "google/protobuf/internal/test_util.py", |
| 147 | "google/protobuf/internal/import_test_package/__init__.py", |
| 148 | ], |
| 149 | ), |
| 150 | imports = ["python"], |
| 151 | srcs_version = "PY2AND3", |
| 152 | visibility = [ |
| 153 | "//:__pkg__", |
| 154 | "@upb//:__subpackages__", |
| 155 | ], |
| 156 | ) |
| 157 | |
| 158 | py_library( |
| 159 | name = "python_test_srcs", |
| 160 | srcs = glob([ |
| 161 | "google/protobuf/internal/*_test.py", |
| 162 | ]) + [ |
| 163 | "google/protobuf/internal/test_util.py", |
| 164 | "google/protobuf/internal/import_test_package/__init__.py", |
| 165 | ], |
| 166 | imports = ["python"], |
| 167 | srcs_version = "PY3", |
| 168 | visibility = [ |
| 169 | "//:__pkg__", |
| 170 | "@upb//:__subpackages__", |
| 171 | ], |
| 172 | ) |
| 173 | |
| 174 | ################################################################################ |
| 175 | # Tests |
| 176 | ################################################################################ |
| 177 | |
| 178 | internal_copy_files( |
| 179 | name = "copied_test_proto_files", |
David L. Jones | 07303d6 | 2022-05-17 18:13:22 -0700 | [diff] [blame] | 180 | testonly = 1, |
| 181 | srcs = [ |
| 182 | "//:test_proto_srcs", |
| 183 | "//src/google/protobuf/util:test_proto_srcs", |
| 184 | ], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 185 | strip_prefix = "src", |
| 186 | ) |
| 187 | |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 188 | internal_copy_files( |
| 189 | name = "copied_test_messages_proto2_files", |
| 190 | testonly = 1, |
| 191 | srcs = [ |
| 192 | "//src/google/protobuf:test_messages_proto2.proto", |
| 193 | ], |
| 194 | strip_prefix = "src", |
| 195 | ) |
| 196 | |
| 197 | internal_copy_files( |
| 198 | name = "copied_test_messages_proto3_files", |
| 199 | testonly = 1, |
| 200 | srcs = [ |
| 201 | "//src/google/protobuf:test_messages_proto3.proto", |
| 202 | ], |
| 203 | strip_prefix = "src", |
| 204 | ) |
| 205 | |
| 206 | internal_py_proto_library( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 207 | name = "python_common_test_protos", |
David L. Jones | 07303d6 | 2022-05-17 18:13:22 -0700 | [diff] [blame] | 208 | testonly = 1, |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 209 | srcs = [":copied_test_proto_files"], |
| 210 | include = ".", |
| 211 | default_runtime = "", |
| 212 | protoc = "//:protoc", |
| 213 | srcs_version = "PY2AND3", |
| 214 | visibility = ["//:__pkg__"], |
| 215 | deps = [":well_known_types_py_pb2"], |
| 216 | ) |
| 217 | |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 218 | internal_py_proto_library( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 219 | name = "python_specific_test_protos", |
David L. Jones | 07303d6 | 2022-05-17 18:13:22 -0700 | [diff] [blame] | 220 | testonly = 1, |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 221 | srcs = glob([ |
| 222 | "google/protobuf/internal/*.proto", |
| 223 | "google/protobuf/internal/import_test_package/*.proto", |
| 224 | ]), |
| 225 | include = ".", |
| 226 | default_runtime = ":protobuf_python", |
| 227 | protoc = "//:protoc", |
| 228 | srcs_version = "PY2AND3", |
| 229 | visibility = ["//:__pkg__"], |
| 230 | deps = [":python_common_test_protos"], |
| 231 | ) |
| 232 | |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 233 | internal_py_proto_library( |
| 234 | name = "test_messages_proto2_py_proto", |
| 235 | testonly = 1, |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 236 | srcs = [":copied_test_messages_proto2_files"], |
| 237 | include = ".", |
| 238 | default_runtime = "//:protobuf_python", |
| 239 | protoc = "//:protoc", |
Mike Kruskal | ca4b063 | 2022-08-11 20:55:01 -0700 | [diff] [blame] | 240 | visibility = [ |
| 241 | "//conformance:__pkg__", |
| 242 | "//python:__subpackages__", |
| 243 | ], |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 244 | ) |
| 245 | |
| 246 | internal_py_proto_library( |
| 247 | name = "test_messages_proto3_py_proto", |
| 248 | testonly = 1, |
Mike Kruskal | ca4b063 | 2022-08-11 20:55:01 -0700 | [diff] [blame] | 249 | srcs = [":copied_test_messages_proto3_files"], |
| 250 | include = ".", |
| 251 | default_runtime = "//:protobuf_python", |
| 252 | protoc = "//:protoc", |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 253 | visibility = [ |
| 254 | "//conformance:__pkg__", |
| 255 | "//python:__subpackages__", |
| 256 | ], |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 257 | deps = [":well_known_types_py_pb2"], |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 258 | ) |
| 259 | |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 260 | py_library( |
| 261 | name = "python_test_lib", |
David L. Jones | 07303d6 | 2022-05-17 18:13:22 -0700 | [diff] [blame] | 262 | testonly = 1, |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 263 | srcs = [ |
| 264 | "google/protobuf/internal/import_test_package/__init__.py", |
| 265 | "google/protobuf/internal/test_util.py", |
| 266 | ], |
| 267 | imports = ["python"], |
| 268 | srcs_version = "PY2AND3", |
| 269 | deps = [ |
| 270 | ":protobuf_python", |
| 271 | ":python_common_test_protos", |
| 272 | ":python_specific_test_protos", |
| 273 | ], |
| 274 | ) |
| 275 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 276 | internal_py_test( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 277 | name = "descriptor_database_test", |
| 278 | srcs = ["google/protobuf/internal/descriptor_database_test.py"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 279 | ) |
| 280 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 281 | internal_py_test( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 282 | name = "descriptor_pool_test", |
| 283 | srcs = ["google/protobuf/internal/descriptor_pool_test.py"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 284 | ) |
| 285 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 286 | internal_py_test( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 287 | name = "descriptor_test", |
| 288 | srcs = ["google/protobuf/internal/descriptor_test.py"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 289 | ) |
| 290 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 291 | internal_py_test( |
Mike Kruskal | 23f1481 | 2022-10-10 21:05:53 -0700 | [diff] [blame] | 292 | name = "field_mask_test", |
| 293 | srcs = ["google/protobuf/internal/field_mask_test.py"], |
Mike Kruskal | 23f1481 | 2022-10-10 21:05:53 -0700 | [diff] [blame] | 294 | ) |
| 295 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 296 | internal_py_test( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 297 | name = "generator_test", |
| 298 | srcs = ["google/protobuf/internal/generator_test.py"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 299 | ) |
| 300 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 301 | internal_py_test( |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 302 | name = "import_test", |
| 303 | srcs = ["google/protobuf/internal/import_test.py"], |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 304 | ) |
| 305 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 306 | internal_py_test( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 307 | name = "json_format_test", |
| 308 | srcs = ["google/protobuf/internal/json_format_test.py"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 309 | ) |
| 310 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 311 | internal_py_test( |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 312 | name = "keywords_test", |
| 313 | srcs = ["google/protobuf/internal/keywords_test.py"], |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 314 | ) |
| 315 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 316 | internal_py_test( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 317 | name = "message_factory_test", |
| 318 | srcs = ["google/protobuf/internal/message_factory_test.py"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 319 | ) |
| 320 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 321 | internal_py_test( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 322 | name = "message_test", |
| 323 | srcs = ["google/protobuf/internal/message_test.py"], |
Xavier Bonaventura | c8ebeb1 | 2023-02-07 17:14:15 -0800 | [diff] [blame] | 324 | data = ["//src/google/protobuf:testdata"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 325 | ) |
| 326 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 327 | internal_py_test( |
zhangskz | edb7ef9 | 2022-10-05 21:45:16 +0000 | [diff] [blame] | 328 | name = "numpy_test", |
| 329 | srcs = ["google/protobuf/internal/numpy_test.py"], |
zhangskz | edb7ef9 | 2022-10-05 21:45:16 +0000 | [diff] [blame] | 330 | deps = [ |
zhangskz | edb7ef9 | 2022-10-05 21:45:16 +0000 | [diff] [blame] | 331 | requirement("numpy"), |
| 332 | ], |
| 333 | ) |
| 334 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 335 | internal_py_test( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 336 | name = "proto_builder_test", |
| 337 | srcs = ["google/protobuf/internal/proto_builder_test.py"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 338 | ) |
| 339 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 340 | internal_py_test( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 341 | name = "reflection_test", |
| 342 | srcs = ["google/protobuf/internal/reflection_test.py"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 343 | ) |
| 344 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 345 | internal_py_test( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 346 | name = "service_reflection_test", |
| 347 | srcs = ["google/protobuf/internal/service_reflection_test.py"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 348 | ) |
| 349 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 350 | internal_py_test( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 351 | name = "symbol_database_test", |
| 352 | srcs = ["google/protobuf/internal/symbol_database_test.py"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 353 | ) |
| 354 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 355 | internal_py_test( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 356 | name = "text_encoding_test", |
| 357 | srcs = ["google/protobuf/internal/text_encoding_test.py"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 358 | ) |
| 359 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 360 | internal_py_test( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 361 | name = "text_format_test", |
| 362 | srcs = ["google/protobuf/internal/text_format_test.py"], |
David L. Jones | 171a6b1 | 2022-05-18 13:45:22 -0700 | [diff] [blame] | 363 | data = ["//src/google/protobuf:testdata"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 364 | ) |
| 365 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 366 | internal_py_test( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 367 | name = "unknown_fields_test", |
| 368 | srcs = ["google/protobuf/internal/unknown_fields_test.py"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 369 | ) |
| 370 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 371 | internal_py_test( |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 372 | name = "well_known_types_test", |
| 373 | srcs = ["google/protobuf/internal/well_known_types_test.py"], |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 374 | ) |
| 375 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 376 | internal_py_test( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 377 | name = "wire_format_test", |
| 378 | srcs = ["google/protobuf/internal/wire_format_test.py"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 379 | ) |
| 380 | |
| 381 | cc_library( |
| 382 | name = "proto_api", |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 383 | hdrs = ["google/protobuf/proto_api.h"], |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 384 | visibility = ["//visibility:public"], |
| 385 | deps = [ |
| 386 | "//external:python_headers", |
| 387 | ], |
| 388 | ) |
| 389 | |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 390 | internal_py_test( |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 391 | name = "python_version", |
| 392 | srcs = ["python_version.py"], |
| 393 | ) |
| 394 | |
| 395 | conformance_test( |
| 396 | name = "conformance_test", |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 397 | env = {"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": "python"}, |
Mike Kruskal | ca4b063 | 2022-08-11 20:55:01 -0700 | [diff] [blame] | 398 | failure_list = "//conformance:failure_list_python.txt", |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 399 | target_compatible_with = select({ |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 400 | "@system_python//:none": ["@platforms//:incompatible"], |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 401 | ":use_fast_cpp_protos": ["@platforms//:incompatible"], |
| 402 | "//conditions:default": [], |
| 403 | }), |
Mike Kruskal | ca4b063 | 2022-08-11 20:55:01 -0700 | [diff] [blame] | 404 | testee = "//conformance:conformance_python", |
| 405 | text_format_failure_list = "//conformance:text_format_failure_list_python.txt", |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 406 | ) |
| 407 | |
| 408 | # Note: this requires --define=use_fast_cpp_protos=true |
| 409 | conformance_test( |
| 410 | name = "conformance_test_cpp", |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 411 | env = {"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": "cpp"}, |
Mike Kruskal | ca4b063 | 2022-08-11 20:55:01 -0700 | [diff] [blame] | 412 | failure_list = "//conformance:failure_list_python.txt", |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 413 | target_compatible_with = select({ |
Mike Kruskal | 3bc5049 | 2022-12-01 13:34:12 -0800 | [diff] [blame] | 414 | "@system_python//:none": ["@platforms//:incompatible"], |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 415 | ":use_fast_cpp_protos": [], |
| 416 | "//conditions:default": ["@platforms//:incompatible"], |
| 417 | }), |
Mike Kruskal | ca4b063 | 2022-08-11 20:55:01 -0700 | [diff] [blame] | 418 | testee = "//conformance:conformance_python", |
| 419 | text_format_failure_list = "//conformance:text_format_failure_list_python_cpp.txt", |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 420 | ) |
| 421 | |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 422 | ################################################################################ |
| 423 | # Distribution files |
| 424 | ################################################################################ |
| 425 | |
| 426 | pkg_files( |
Deanna Garcia | d0169ff | 2022-12-16 11:13:03 -0800 | [diff] [blame] | 427 | name = "python_source_files", |
| 428 | srcs = glob( |
| 429 | [ |
| 430 | "google/protobuf/**/*.py", |
| 431 | ], |
| 432 | exclude = [ |
| 433 | "google/protobuf/internal/*_test.py", |
| 434 | "google/protobuf/internal/test_util.py", |
| 435 | "google/protobuf/internal/import_test_package/__init__.py", |
| 436 | ], |
Deanna Garcia | c59cc4d | 2022-12-22 15:04:17 -0800 | [diff] [blame] | 437 | ) + [ |
| 438 | "README.md", |
| 439 | "google/__init__.py", |
| 440 | "setup.cfg", |
| 441 | "tox.ini", |
| 442 | ], |
Deanna Garcia | d0169ff | 2022-12-16 11:13:03 -0800 | [diff] [blame] | 443 | visibility = ["@upb//:__subpackages__"], |
| 444 | strip_prefix = "", |
| 445 | ) |
| 446 | |
| 447 | pkg_files( |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 448 | name = "dist_files", |
| 449 | srcs = glob([ |
| 450 | "google/**/*.proto", |
| 451 | "google/**/*.py", |
| 452 | "google/protobuf/internal/*.cc", |
| 453 | "google/protobuf/pyext/*.cc", |
| 454 | "google/protobuf/pyext/*.h", |
| 455 | ]) + [ |
| 456 | "BUILD.bazel", |
| 457 | "MANIFEST.in", |
| 458 | "README.md", |
| 459 | "google/protobuf/proto_api.h", |
| 460 | "google/protobuf/pyext/README", |
| 461 | "google/protobuf/python_protobuf.h", |
| 462 | "internal.bzl", |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 463 | "python_version.py", |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 464 | "release.sh", |
| 465 | "setup.cfg", |
| 466 | "setup.py", |
David L. Jones | b3cbea1 | 2022-05-12 19:48:58 -0700 | [diff] [blame] | 467 | "tox.ini", |
| 468 | ], |
| 469 | strip_prefix = strip_prefix.from_root(""), |
| 470 | visibility = ["//pkg:__pkg__"], |
| 471 | ) |