@@ -2,122 +2,164 @@ 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+ )
615
7- _bazel_skylib_sha256 = "f24ab666394232f834f74d19e2ff142b0af17466ea0c69a3f4c276ee75f6efce"
16+ # Load com_google_googleapis first so we can choose which version will be used
17+ _googleapis_sha256 = "2638026851b9110c280d75338581a752a4271340"
18+ http_archive (
19+ name = "com_google_googleapis" ,
20+ strip_prefix = "googleapis-{}" .format (_googleapis_sha256 ),
21+ urls = ["https://github.com/googleapis/googleapis/archive/{0}.zip" .format (_googleapis_sha256 )],
22+ )
823
24+ # Load rules_gapic v1.0.0. We patch rules_gapic's .bzl files to inject the
25+ # explicit load for Starlark ProtoInfo from @rules_proto to maintain symbol
26+ # resolution under rules_proto / Protobuf 35.1.
27+ _rules_gapic_version = "1.0.0"
28+ _rules_gapic_sha256 = "c21e78a42f69898e7c3142fa837e3a637b1993d27c08a64723262611971d2b96"
29+ http_archive (
30+ name = "rules_gapic" ,
31+ sha256 = _rules_gapic_sha256 ,
32+ strip_prefix = "rules_gapic-{}" .format (_rules_gapic_version ),
33+ urls = [
34+ "https://github.com/googleapis/rules_gapic/archive/v{}.tar.gz" .format (_rules_gapic_version )
35+ ]
36+ )
37+
38+ # Load C++ rules matching modern Protobuf C++ requirements
39+ _rules_cc_version = "0.1.5"
40+ _rules_cc_sha256 = "b8b918a85f9144c01f6cfe0f45e4f2838c7413961a8ff23bc0c6cdf8bb07a3b6"
41+ http_archive (
42+ name = "rules_cc" ,
43+ sha256 = _rules_cc_sha256 ,
44+ strip_prefix = "rules_cc-{}" .format (_rules_cc_version ),
45+ urls = ["https://github.com/bazelbuild/rules_cc/releases/download/{0}/rules_cc-{0}.tar.gz" .format (_rules_cc_version )],
46+ )
47+
48+ # Load bazel_skylib required by Starlark rules
49+ _bazel_skylib_version = "1.9.0"
50+ _bazel_skylib_sha256 = "3b5b49006181f5f8ff626ef8ddceaa95e9bb8ad294f7b5d7b11ea9f7ddaf8c59"
951http_archive (
1052 name = "bazel_skylib" ,
1153 sha256 = _bazel_skylib_sha256 ,
1254 url = "https://github.com/bazelbuild/bazel-skylib/releases/download/{0}/bazel-skylib-{0}.tar.gz" .format (_bazel_skylib_version ),
1355)
1456
57+ # Load Abseil C++ matching Protobuf 35 C++ dependencies
58+ _com_google_absl_version = "20240722.1"
59+ _com_google_absl_sha256 = "40cee67604060a7c8794d931538cb55f4d444073e556980c88b6c49bb9b19bb7"
60+ http_archive (
61+ name = "com_google_absl" ,
62+ sha256 = _com_google_absl_sha256 ,
63+ strip_prefix = "abseil-cpp-{}" .format (_com_google_absl_version ),
64+ urls = [
65+ "https://github.com/abseil/abseil-cpp/releases/download/{0}/abseil-cpp-{0}.tar.gz" .format (_com_google_absl_version ),
66+ ],
67+ )
68+
69+ # Load Go rules required for GAPIC plugin building
1570_io_bazel_rules_go_version = "0.33.0"
71+ _io_bazel_rules_go_sha256 = "685052b498b6ddfe562ca7a97736741d87916fe536623afb7da2824c0211c369"
1672http_archive (
1773 name = "io_bazel_rules_go" ,
18- sha256 = "685052b498b6ddfe562ca7a97736741d87916fe536623afb7da2824c0211c369" ,
74+ sha256 = _io_bazel_rules_go_sha256 ,
1975 urls = [
2076 "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v{0}/rules_go-v{0}.zip" .format (_io_bazel_rules_go_version ),
2177 "https://github.com/bazelbuild/rules_go/releases/download/v{0}/rules_go-v{0}.zip" .format (_io_bazel_rules_go_version ),
2278 ],
2379)
2480
25- _rules_python_version = "0.26.0"
26-
27- _rules_python_sha256 = "9d04041ac92a0985e344235f5d946f71ac543f1b1565f2cdbc9a2aaee8adf55b"
28-
81+ # Upgraded to rules_python 1.1.0 for modern C-extension toolchain support.
82+ _rules_python_version = "1.1.0"
83+ _rules_python_sha256 = "9c6e26911a79fbf510a8f06d8eedb40f412023cf7fa6d1461def27116bff022c"
2984http_archive (
3085 name = "rules_python" ,
3186 sha256 = _rules_python_sha256 ,
3287 strip_prefix = "rules_python-{}" .format (_rules_python_version ),
33- url = "https://github.com/bazelbuild/rules_python/archive/{ }.tar.gz" .format (_rules_python_version ),
88+ url = "https://github.com/bazelbuild/rules_python/releases/download/{0}/rules_python-{0 }.tar.gz" .format (_rules_python_version ),
3489)
3590
36- load ("@rules_python//python:repositories.bzl" , "py_repositories" )
37-
91+ load ("@rules_python//python:repositories.bzl" , "py_repositories" , "python_register_multi_toolchains" )
3892py_repositories ()
3993
40- load ("@rules_python//python:pip.bzl" , "pip_parse" )
41-
94+ # Register multi-version hermetic Python toolchains (3.10 - 3.13) to ensure
95+ # Bazel can resolve both execution and C-header toolchains for any Python target.
96+ # Set ignore_root_user_error = True so toolchains unpack safely in Docker CI containers (EUID=0).
97+ python_register_multi_toolchains (
98+ name = "python" ,
99+ ignore_root_user_error = True ,
100+ python_versions = [
101+ "3.10" ,
102+ "3.11" ,
103+ "3.12" ,
104+ "3.13" ,
105+ ],
106+ )
42107
108+ load ("@rules_python//python:pip.bzl" , "pip_parse" )
43109pip_parse (
44110 name = "gapic_generator_python_pip_deps" ,
45- requirements_lock = "//:requirements.txt" ,
111+ requirements_lock = "//:requirements.txt" ,
46112)
47- load ("@gapic_generator_python_pip_deps//:requirements.bzl" , "install_deps" )
48113
114+ load ("@gapic_generator_python_pip_deps//:requirements.bzl" , "install_deps" )
49115install_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"
66116
117+ # Load gRPC v1.83.0 with temporary patch for legacy_channel.cc.
118+ # The fix is merged upstream (https://github.com/grpc/grpc/commit/816506e5c0434a42414af6955cc9eef0c562ff3a)
119+ # and this patch is temporary until released in a future gRPC release.
120+ _grpc_version = "1.83.0"
121+ _grpc_sha256 = "876ff5c9c26f364cd603531761268a5b58ccc1479afc78d6dab1d8e839da00c0"
67122http_archive (
68123 name = "com_github_grpc_grpc" ,
69124 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 ],
125+ strip_prefix = "grpc-{}" .format (_grpc_version ),
126+ urls = ["https://github.com/grpc/grpc/archive/v{}.zip" .format (_grpc_version )],
127+ patches = ["//third_party:grpc_legacy_channel.patch" ],
128+ patch_args = ["-p1" ],
84129)
85130load ("@com_github_grpc_grpc//bazel:grpc_deps.bzl" , "grpc_deps" )
86-
87131grpc_deps ()
88132
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" ,
133+ load (
134+ "//:repositories.bzl" ,
135+ "gapic_generator_python" ,
136+ "gapic_generator_register_toolchains" ,
94137)
138+ gapic_generator_python ()
139+ gapic_generator_register_toolchains ()
95140
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`
141+ # Add rules_java to resolve compatibility proxy errors
102142load ("@rules_java//java:rules_java_deps.bzl" , "rules_java_dependencies" )
103-
104143rules_java_dependencies ()
105144
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.
145+ # Load transitive proto dependencies and register proto toolchains
146+ load ("@com_google_protobuf//:protobuf_deps.bzl" , "protobuf_deps" )
147+ protobuf_deps ()
110148
111- load ("@build_bazel_rules_apple//apple:repositories.bzl" , "apple_rules_dependencies" )
149+ load ("@rules_proto//proto:repositories.bzl" , "rules_proto_dependencies" )
150+ rules_proto_dependencies ()
112151
152+ load ("@rules_proto//proto:toolchains.bzl" , "rules_proto_toolchains" )
153+ rules_proto_toolchains ()
154+
155+ # Load platform dependencies
156+ load ("@build_bazel_rules_apple//apple:repositories.bzl" , "apple_rules_dependencies" )
113157apple_rules_dependencies ()
114158
115159load ("@build_bazel_apple_support//lib:repositories.bzl" , "apple_support_dependencies" )
116-
117160apple_support_dependencies ()
118161
119162load ("@com_google_googleapis//:repository_rules.bzl" , "switched_rules_by_language" )
120-
121163switched_rules_by_language (
122164 name = "com_google_googleapis_imports" ,
123165 gapic = True ,
0 commit comments