Skip to content

Commit

Permalink
Add patch for gRPC Python support
Browse files Browse the repository at this point in the history
  • Loading branch information
mering committed Jan 20, 2024
1 parent f101c07 commit f645f18
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 1 deletion.
16 changes: 16 additions & 0 deletions modules/grpc/1.56.3/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,19 @@ use_repo(
grpc_extra_deps_ext = use_extension("//bazel:grpc_extra_deps.bzl", "grpc_extra_deps_ext")

use_repo(grpc_extra_deps_ext, "com_google_googleapis_imports")

bazel_dep(name = "rules_python", version = "0.28.0")
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
python_version = "3.8",
)
use_repo(python, local_config_python = "python_3_8")
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "grpc_python_dependencies",
python_version = "3.8",
requirements_lock = "//:requirements.bazel.txt",
)
use_repo(pip, "grpc_python_dependencies")
grpc_python_deps_ext = use_extension("//bazel:grpc_python_deps.bzl", "grpc_python_deps_ext")
use_repo(grpc_python_deps_ext, "cython")
102 changes: 102 additions & 0 deletions modules/grpc/1.56.3/patches/python.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
diff --git a/MODULE.bazel b/MODULE.bazel
index caf4f829d4..bc2548f366 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -34,3 +34,19 @@ use_repo(
grpc_extra_deps_ext = use_extension("//bazel:grpc_extra_deps.bzl", "grpc_extra_deps_ext")

use_repo(grpc_extra_deps_ext, "com_google_googleapis_imports")
+
+bazel_dep(name = "rules_python", version = "0.28.0")
+python = use_extension("@rules_python//python/extensions:python.bzl", "python")
+python.toolchain(
+ python_version = "3.8",
+)
+use_repo(python, local_config_python = "python_3_8")
+pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
+pip.parse(
+ hub_name = "grpc_python_dependencies",
+ python_version = "3.8",
+ requirements_lock = "//:requirements.bazel.txt",
+)
+use_repo(pip, "grpc_python_dependencies")
+grpc_python_deps_ext = use_extension("//bazel:grpc_python_deps.bzl", "grpc_python_deps_ext")
+use_repo(grpc_python_deps_ext, "cython")
diff --git a/bazel/grpc_python_deps.bzl b/bazel/grpc_python_deps.bzl
index 39893eef6e..172933e062 100644
--- a/bazel/grpc_python_deps.bzl
+++ b/bazel/grpc_python_deps.bzl
@@ -16,6 +16,18 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@com_github_grpc_grpc//third_party/py:python_configure.bzl", "python_configure")

+# buildifier: disable=unnamed-macro
+def cython():
+ http_archive(
+ name = "cython",
+ build_file = "@com_github_grpc_grpc//third_party:cython.BUILD",
+ sha256 = "a2da56cc22be823acf49741b9aa3aa116d4f07fa8e8b35a3cb08b8447b37c607",
+ strip_prefix = "cython-0.29.35",
+ urls = [
+ "https://github.com/cython/cython/archive/0.29.35.tar.gz",
+ ],
+ )
+
# buildifier: disable=unnamed-macro
def grpc_python_deps():
"""Loads dependencies for gRPC Python."""
@@ -36,12 +48,6 @@ def grpc_python_deps():
)

if "cython" not in native.existing_rules():
- http_archive(
- name = "cython",
- build_file = "@com_github_grpc_grpc//third_party:cython.BUILD",
- sha256 = "a2da56cc22be823acf49741b9aa3aa116d4f07fa8e8b35a3cb08b8447b37c607",
- strip_prefix = "cython-0.29.35",
- urls = [
- "https://github.com/cython/cython/archive/0.29.35.tar.gz",
- ],
- )
+ cython()
+
+grpc_python_deps_ext = module_extension(implementation = lambda ctx: cython())
diff --git a/requirements.bazel.txt b/requirements.bazel.txt
index f2dbfd7af8..ea81395c14 100644
--- a/requirements.bazel.txt
+++ b/requirements.bazel.txt
@@ -1,17 +1,25 @@
# GRPC Python setup requirements
+cachetools==4.2.4
+certifi==2017.4.17
+chardet==3.0.4
coverage==4.5.4
cython==0.29.21
-protobuf>=3.5.0.post1, < 4.0dev
-wheel==0.36.2
+gevent==22.8.0
google-auth==1.24.0
+googleapis-common-protos==1.5.5
+greenlet==1.1.3.post0
+grpcio==1.56.2
+idna==2.7
oauth2client==4.1.0
+protobuf>=3.5.0.post1, < 4.0dev
+pyasn1==0.5.1
+pyasn1-modules==0.3.0
requests==2.25.1
+rsa==4.9
+setuptools==69.0.3
+six==1.16.0
urllib3==1.26.5
-chardet==3.0.4
-certifi==2017.4.17
-idna==2.7
-googleapis-common-protos==1.5.5
-gevent==22.08.0
-zope.event==4.5.0
-setuptools==44.1.1
+wheel==0.36.2
xds-protos==0.0.11
+zope-event==4.5.0
+zope-interface==6.1
3 changes: 2 additions & 1 deletion modules/grpc/1.56.3/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"integrity": "sha256-hOMadwF5EbLxZH7K2wFyZx2WBJ6prVEJ8CtHF8DwNwI=",
"strip_prefix": "grpc-1.56.3",
"patches": {
"adopt_bzlmod.patch": "sha256-6z89v9iwJ0/OtRo53mne5MWTwCO0s00TJ8onoMtVwwU="
"adopt_bzlmod.patch": "sha256-6z89v9iwJ0/OtRo53mne5MWTwCO0s00TJ8onoMtVwwU=",
"python.patch": "sha256-IrZoAR9wQVJ2yDCIxYc5ffD76kjqTrsYHqUST8s3TLg="
},
"patch_strip": 1
}

0 comments on commit f645f18

Please sign in to comment.