@@ -12,6 +12,7 @@ load("//:protobuf.bzl", "internal_py_proto_library")
1212load ("//build_defs:arch_tests.bzl" , "aarch64_test" , "x86_64_test" )
1313load ("//build_defs:cpp_opts.bzl" , "COPTS" )
1414load ("//conformance:defs.bzl" , "conformance_test" )
15+ load ("//src/google/protobuf/editions:defaults.bzl" , "compile_edition_defaults" , "embed_edition_defaults" )
1516load (":internal.bzl" , "internal_copy_files" , "internal_py_test" )
1617
1718def build_targets (name ):
@@ -143,8 +144,23 @@ def build_targets(name):
143144 ],
144145 )
145146
146- py_library (
147- name = "python_srcs" ,
147+ compile_edition_defaults (
148+ name = "python_edition_defaults" ,
149+ srcs = ["//:descriptor_proto" ],
150+ maximum_edition = "2023" ,
151+ minimum_edition = "PROTO2" ,
152+ )
153+
154+ embed_edition_defaults (
155+ name = "embedded_python_edition_defaults_generate" ,
156+ defaults = "python_edition_defaults" ,
157+ output = "google/protobuf/internal/python_edition_defaults.py" ,
158+ placeholder = "DEFAULTS_VALUE" ,
159+ template = "google/protobuf/internal/python_edition_defaults.py.template" ,
160+ )
161+
162+ native .filegroup (
163+ name = "python_src_files" ,
148164 srcs = native .glob (
149165 [
150166 "google/protobuf/**/*.py" ,
@@ -154,7 +170,12 @@ def build_targets(name):
154170 "google/protobuf/internal/test_util.py" ,
155171 "google/protobuf/internal/import_test_package/__init__.py" ,
156172 ],
157- ),
173+ ) + ["google/protobuf/internal/python_edition_defaults.py" ],
174+ )
175+
176+ py_library (
177+ name = "python_srcs" ,
178+ srcs = [":python_src_files" ],
158179 imports = ["python" ],
159180 srcs_version = "PY2AND3" ,
160181 visibility = [
@@ -196,19 +217,13 @@ def build_targets(name):
196217 )
197218
198219 internal_copy_files (
199- name = "copied_test_messages_proto2_files " ,
220+ name = "copied_conformance_test_files " ,
200221 testonly = 1 ,
201222 srcs = [
202223 "//src/google/protobuf:test_messages_proto2.proto" ,
203- ],
204- strip_prefix = "src" ,
205- )
206-
207- internal_copy_files (
208- name = "copied_test_messages_proto3_files" ,
209- testonly = 1 ,
210- srcs = [
211224 "//src/google/protobuf:test_messages_proto3.proto" ,
225+ "//src/google/protobuf/editions:golden/test_messages_proto2_editions.proto" ,
226+ "//src/google/protobuf/editions:golden/test_messages_proto3_editions.proto" ,
212227 ],
213228 strip_prefix = "src" ,
214229 )
@@ -241,22 +256,9 @@ def build_targets(name):
241256 )
242257
243258 internal_py_proto_library (
244- name = "test_messages_proto2_py_proto" ,
245- testonly = 1 ,
246- srcs = [":copied_test_messages_proto2_files" ],
247- include = "." ,
248- default_runtime = "//:protobuf_python" ,
249- protoc = "//:protoc" ,
250- visibility = [
251- "//conformance:__pkg__" ,
252- "//python:__subpackages__" ,
253- ],
254- )
255-
256- internal_py_proto_library (
257- name = "test_messages_proto3_py_proto" ,
259+ name = "conformance_test_py_proto" ,
258260 testonly = 1 ,
259- srcs = [":copied_test_messages_proto3_files " ],
261+ srcs = [":copied_conformance_test_files " ],
260262 include = "." ,
261263 default_runtime = "//:protobuf_python" ,
262264 protoc = "//:protoc" ,
@@ -404,6 +406,7 @@ def build_targets(name):
404406 ":use_fast_cpp_protos" : ["@platforms//:incompatible" ],
405407 "//conditions:default" : [],
406408 }),
409+ maximum_edition = "2023" ,
407410 testee = "//conformance:conformance_python" ,
408411 text_format_failure_list = "//conformance:text_format_failure_list_python.txt" ,
409412 )
@@ -418,6 +421,7 @@ def build_targets(name):
418421 ":use_fast_cpp_protos" : [],
419422 "//conditions:default" : ["@platforms//:incompatible" ],
420423 }),
424+ maximum_edition = "2023" ,
421425 testee = "//conformance:conformance_python" ,
422426 text_format_failure_list = "//conformance:text_format_failure_list_python_cpp.txt" ,
423427 )
@@ -428,16 +432,8 @@ def build_targets(name):
428432
429433 pkg_files (
430434 name = "python_source_files" ,
431- srcs = native .glob (
432- [
433- "google/protobuf/**/*.py" ,
434- ],
435- exclude = [
436- "google/protobuf/internal/*_test.py" ,
437- "google/protobuf/internal/test_util.py" ,
438- "google/protobuf/internal/import_test_package/__init__.py" ,
439- ],
440- ) + [
435+ srcs = [
436+ ":python_src_files" ,
441437 "README.md" ,
442438 "google/__init__.py" ,
443439 "setup.cfg" ,
0 commit comments