@@ -2,122 +2,157 @@ workspace(name = "gapic_generator_python")
22
33load ("@bazel_tools//tools/build_defs/repo:http.bzl" , "http_archive" )
44
5- _bazel_skylib_version = "1.4.0"
5+ # Load Protobuf 35.1 first to ensure Bazel uses Protobuf 35.1 over older
6+ # transitive versions pulled in by downstream rules (e.g. gRPC or rules_gapic).
7+ _protobuf_version = "35.1"
8+ _protobuf_sha256 = "bf89df2fa0088de9c9890fbfba0076263a36c2f84847a7b54e7e32effd6201c7"
9+ http_archive (
10+ name = "com_google_protobuf" ,
11+ sha256 = _protobuf_sha256 ,
12+ strip_prefix = "protobuf-{}" .format (_protobuf_version ),
13+ urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v{0}/protobuf-{0}.zip" .format (_protobuf_version )],
14+ )
15+
16+ # Load rules_gapic v1.0.0. We patch rules_gapic's .bzl files to inject the
17+ # explicit load for Starlark ProtoInfo from @rules_proto to maintain symbol
18+ # resolution under rules_proto / Protobuf 35.1.
19+ _rules_gapic_version = "1.0.0"
20+ _rules_gapic_sha256 = "c21e78a42f69898e7c3142fa837e3a637b1993d27c08a64723262611971d2b96"
21+ http_archive (
22+ name = "rules_gapic" ,
23+ sha256 = _rules_gapic_sha256 ,
24+ strip_prefix = "rules_gapic-{}" .format (_rules_gapic_version ),
25+ urls = [
26+ "https://github.com/googleapis/rules_gapic/archive/v{}.tar.gz" .format (_rules_gapic_version )
27+ ]
28+ )
629
7- _bazel_skylib_sha256 = "f24ab666394232f834f74d19e2ff142b0af17466ea0c69a3f4c276ee75f6efce"
30+ # Load C++ rules matching modern Protobuf C++ requirements
31+ _rules_cc_version = "0.1.5"
32+ _rules_cc_sha256 = "b8b918a85f9144c01f6cfe0f45e4f2838c7413961a8ff23bc0c6cdf8bb07a3b6"
33+ http_archive (
34+ name = "rules_cc" ,
35+ sha256 = _rules_cc_sha256 ,
36+ strip_prefix = "rules_cc-{}" .format (_rules_cc_version ),
37+ urls = ["https://github.com/bazelbuild/rules_cc/releases/download/{0}/rules_cc-{0}.tar.gz" .format (_rules_cc_version )],
38+ )
839
40+ # Load bazel_skylib required by Starlark rules
41+ _bazel_skylib_version = "1.9.0"
42+ _bazel_skylib_sha256 = "3b5b49006181f5f8ff626ef8ddceaa95e9bb8ad294f7b5d7b11ea9f7ddaf8c59"
943http_archive (
1044 name = "bazel_skylib" ,
1145 sha256 = _bazel_skylib_sha256 ,
1246 url = "https://github.com/bazelbuild/bazel-skylib/releases/download/{0}/bazel-skylib-{0}.tar.gz" .format (_bazel_skylib_version ),
1347)
1448
49+ # Load Abseil C++ matching Protobuf 35 C++ dependencies
50+ _com_google_absl_version = "20240722.1"
51+ _com_google_absl_sha256 = "40cee67604060a7c8794d931538cb55f4d444073e556980c88b6c49bb9b19bb7"
52+ http_archive (
53+ name = "com_google_absl" ,
54+ sha256 = _com_google_absl_sha256 ,
55+ strip_prefix = "abseil-cpp-{}" .format (_com_google_absl_version ),
56+ urls = [
57+ "https://github.com/abseil/abseil-cpp/releases/download/{0}/abseil-cpp-{0}.tar.gz" .format (_com_google_absl_version ),
58+ ],
59+ )
60+
61+ # Load Go rules required for GAPIC plugin building
1562_io_bazel_rules_go_version = "0.33.0"
63+ _io_bazel_rules_go_sha256 = "685052b498b6ddfe562ca7a97736741d87916fe536623afb7da2824c0211c369"
1664http_archive (
1765 name = "io_bazel_rules_go" ,
18- sha256 = "685052b498b6ddfe562ca7a97736741d87916fe536623afb7da2824c0211c369" ,
66+ sha256 = _io_bazel_rules_go_sha256 ,
1967 urls = [
2068 "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v{0}/rules_go-v{0}.zip" .format (_io_bazel_rules_go_version ),
2169 "https://github.com/bazelbuild/rules_go/releases/download/v{0}/rules_go-v{0}.zip" .format (_io_bazel_rules_go_version ),
2270 ],
2371)
2472
25- _rules_python_version = "0.26.0"
26-
27- _rules_python_sha256 = "9d04041ac92a0985e344235f5d946f71ac543f1b1565f2cdbc9a2aaee8adf55b"
28-
73+ # Upgraded to rules_python 1.1.0 for modern C-extension toolchain support.
74+ _rules_python_version = "1.1.0"
75+ _rules_python_sha256 = "9c6e26911a79fbf510a8f06d8eedb40f412023cf7fa6d1461def27116bff022c"
2976http_archive (
3077 name = "rules_python" ,
3178 sha256 = _rules_python_sha256 ,
3279 strip_prefix = "rules_python-{}" .format (_rules_python_version ),
33- url = "https://github.com/bazelbuild/rules_python/archive/{ }.tar.gz" .format (_rules_python_version ),
80+ url = "https://github.com/bazelbuild/rules_python/releases/download/{0}/rules_python-{0 }.tar.gz" .format (_rules_python_version ),
3481)
3582
36- load ("@rules_python//python:repositories.bzl" , "py_repositories" )
37-
83+ load ("@rules_python//python:repositories.bzl" , "py_repositories" , "python_register_multi_toolchains" )
3884py_repositories ()
3985
40- load ("@rules_python//python:pip.bzl" , "pip_parse" )
41-
86+ # Register multi-version hermetic Python toolchains (3.10 - 3.13) to ensure
87+ # Bazel can resolve both execution and C-header toolchains for any Python target.
88+ # Set ignore_root_user_error = True so toolchains unpack safely in Docker CI containers (EUID=0).
89+ python_register_multi_toolchains (
90+ name = "python" ,
91+ ignore_root_user_error = True ,
92+ python_versions = [
93+ "3.10" ,
94+ "3.11" ,
95+ "3.12" ,
96+ "3.13" ,
97+ ],
98+ )
4299
100+ load ("@rules_python//python:pip.bzl" , "pip_parse" )
43101pip_parse (
44102 name = "gapic_generator_python_pip_deps" ,
45- requirements_lock = "//:requirements.txt" ,
103+ requirements_lock = "//:requirements.txt" ,
46104)
47- load ("@gapic_generator_python_pip_deps//:requirements.bzl" , "install_deps" )
48105
106+ load ("@gapic_generator_python_pip_deps//:requirements.bzl" , "install_deps" )
49107install_deps ()
50- #
51- # Import gapic-generator-python specific dependencies
52- #
53- load (
54- "//:repositories.bzl" ,
55- "gapic_generator_python" ,
56- "gapic_generator_register_toolchains" ,
57- )
58-
59- gapic_generator_python ()
60-
61- gapic_generator_register_toolchains ()
62-
63- _grpc_version = "1.71.0"
64-
65- _grpc_sha256 = "9313c3f8f4dd3341597f152d506a50caf571fe40f886e24ea9078891990df285"
66108
109+ # Load gRPC v1.83.0 with temporary patch for legacy_channel.cc.
110+ # The fix is merged upstream (https://github.com/grpc/grpc/commit/816506e5c0434a42414af6955cc9eef0c562ff3a)
111+ # and this patch is temporary until released in a future gRPC release.
112+ _grpc_version = "1.83.0"
113+ _grpc_sha256 = "876ff5c9c26f364cd603531761268a5b58ccc1479afc78d6dab1d8e839da00c0"
67114http_archive (
68115 name = "com_github_grpc_grpc" ,
69116 sha256 = _grpc_sha256 ,
70- strip_prefix = "grpc-%s" % _grpc_version ,
71- urls = ["https://github.com/grpc/grpc/archive/v%s.zip" % _grpc_version ],
72- )
73- # instantiated in grpc_deps().
74-
75- _protobuf_version = "30.2"
76-
77- _protobuf_sha256 = "07a43d88fe5a38e434c7f94129cad56a4c43a51f99336074d0799c2f7d4e44c5"
78-
79- http_archive (
80- name = "com_google_protobuf" ,
81- sha256 = _protobuf_sha256 ,
82- strip_prefix = "protobuf-%s" % _protobuf_version ,
83- urls = ["https://github.com/protocolbuffers/protobuf/archive/v%s.tar.gz" % _protobuf_version ],
117+ strip_prefix = "grpc-{}" .format (_grpc_version ),
118+ urls = ["https://github.com/grpc/grpc/archive/v{}.zip" .format (_grpc_version )],
119+ patch_cmds = [
120+ "python3 -c \" f='src/core/lib/surface/legacy_channel.cc'; c=open(f).read(); open(f,'w').write(c.replace('args.arena_init_function = arena_init_function;', 'if (arena_init_function.has_value()) { args.arena_init_function.emplace(*arena_init_function); }')) if 'args.arena_init_function = arena_init_function;' in c else None\" "
121+ ],
84122)
85123load ("@com_github_grpc_grpc//bazel:grpc_deps.bzl" , "grpc_deps" )
86-
87124grpc_deps ()
88125
89- http_archive (
90- name = "rules_cc" ,
91- urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.1.1/rules_cc-0.1.1.tar.gz" ],
92- sha256 = "712d77868b3152dd618c4d64faaddefcc5965f90f5de6e6dd1d5ddcd0be82d42" ,
93- strip_prefix = "rules_cc-0.1.1" ,
126+ load (
127+ "//:repositories.bzl" ,
128+ "gapic_generator_python" ,
129+ "gapic_generator_register_toolchains" ,
94130)
131+ gapic_generator_python ()
132+ gapic_generator_register_toolchains ()
95133
96- load ("@com_google_protobuf//:protobuf_deps.bzl" , "protobuf_deps" , "PROTOBUF_MAVEN_ARTIFACTS" )
97- # This is actually already done within grpc_deps but calling this for Bazel convention.
98- protobuf_deps ()
99-
100- # Add rules_java to resolve the following error
101- # `The repository '@compatibility_proxy' could not be resolved: Repository '@compatibility_proxy' is not defined`
134+ # Add rules_java to resolve compatibility proxy errors
102135load ("@rules_java//java:rules_java_deps.bzl" , "rules_java_dependencies" )
103-
104136rules_java_dependencies ()
105137
106- # gRPC enforces a specific version of Go toolchain which conflicts with our build.
107- # All the relevant parts of grpc_extra_deps() are imported in this WORKSPACE file
108- # explicitly, that is why we do not call grpc_extra_deps() here and call
109- # apple_rules_dependencies and apple_support_dependencies macros explicitly.
138+ # Load transitive proto dependencies and register proto toolchains
139+ load ("@com_google_protobuf//:protobuf_deps.bzl" , "protobuf_deps" )
140+ protobuf_deps ()
141+
142+ load ("@rules_proto//proto:repositories.bzl" , "rules_proto_dependencies" )
143+ rules_proto_dependencies ()
110144
111- load ("@build_bazel_rules_apple//apple:repositories.bzl" , "apple_rules_dependencies" )
145+ load ("@rules_proto//proto:toolchains.bzl" , "rules_proto_toolchains" )
146+ rules_proto_toolchains ()
112147
148+ # Load platform dependencies
149+ load ("@build_bazel_rules_apple//apple:repositories.bzl" , "apple_rules_dependencies" )
113150apple_rules_dependencies ()
114151
115152load ("@build_bazel_apple_support//lib:repositories.bzl" , "apple_support_dependencies" )
116-
117153apple_support_dependencies ()
118154
119155load ("@com_google_googleapis//:repository_rules.bzl" , "switched_rules_by_language" )
120-
121156switched_rules_by_language (
122157 name = "com_google_googleapis_imports" ,
123158 gapic = True ,
0 commit comments