1- From 980d72c700f10ed22db92a51c6a3f925e0325f62 Mon Sep 17 00:00:00 2001
1+ From de307ec15e9179105ed903a50e206088dd890fa0 Mon Sep 17 00:00:00 2001
22From: "H. Vetinari" <h.vetinari@gmx.com>
33Date: Tue, 4 Mar 2025 08:53:30 +1100
44Subject: [PATCH 11/15] build grpcio-tools from source
55
66---
7- tools/distrib/python/grpcio_tools/setup.py | 43 ++++++++++++++++------
8- 1 file changed, 31 insertions(+), 12 deletions(-)
7+ tools/distrib/python/grpcio_tools/setup.py | 47 ++++++++++++++++------
8+ 1 file changed, 35 insertions(+), 12 deletions(-)
99
1010diff --git a/tools/distrib/python/grpcio_tools/setup.py b/tools/distrib/python/grpcio_tools/setup.py
11- index fb6c416c96..033a2fe304 100644
11+ index fb6c416c96..c761c3670e 100644
1212--- a/tools/distrib/python/grpcio_tools/setup.py
1313+++ b/tools/distrib/python/grpcio_tools/setup.py
1414@@ -15,6 +15,7 @@
@@ -54,7 +54,7 @@ index fb6c416c96..033a2fe304 100644
5454
5555 GRPC_PYTHON_TOOLS_PACKAGE = "grpc_tools"
5656 GRPC_PYTHON_PROTO_RESOURCES_NAME = "_proto"
57- @@ -293,16 +293,34 @@ def package_data():
57+ @@ -293,16 +293,38 @@ def package_data():
5858 return {GRPC_PYTHON_TOOLS_PACKAGE: proto_files}
5959
6060
@@ -81,7 +81,11 @@ index fb6c416c96..033a2fe304 100644
8181 else:
8282 plugin_sources = [os.path.join("grpc_tools", "_protoc_compiler.cpp")]
8383
84- + grpc_root = os.environ["SRC_DIR"]
84+ + # setuptools requires relative paths; calculate it
85+ + src_dir = pathlib.Path(os.environ["SRC_DIR"]).resolve()
86+ + setup_dir = pathlib.Path(__file__).resolve().parent
87+ + # cannot use pathlib's Path.relative_to to go _out_; see https://github.com/python/cpython/issues/88244
88+ + grpc_root = pathlib.Path(os.path.relpath(src_dir, setup_dir)).as_posix()
8589 plugin_sources += [
8690 os.path.join("grpc_tools", "main.cc"),
8791- os.path.join("grpc_root", "src", "compiler", "python_generator.cc"),
@@ -91,7 +95,7 @@ index fb6c416c96..033a2fe304 100644
9195 ] + CC_FILES
9296
9397 plugin_ext = Extension(
94- @@ -310,10 +328 ,11 @@ def extension_modules():
98+ @@ -310,10 +332 ,11 @@ def extension_modules():
9599 sources=plugin_sources,
96100 include_dirs=[
97101 ".",
0 commit comments