Blame grpc-1.37.0-python-grpcio-use-system-abseil.patch

ce88e01
diff -Naur grpc-1.37.0-original/setup.py grpc-1.37.0/setup.py
ce88e01
--- grpc-1.37.0-original/setup.py	2021-04-06 18:48:56.000000000 -0400
ce88e01
+++ grpc-1.37.0/setup.py	2021-04-08 15:34:35.182802019 -0400
ce88e01
@@ -28,6 +28,7 @@
ce88e01
 from distutils import util
ce88e01
 import os
ce88e01
 import os.path
ce88e01
+import pathlib
ce88e01
 import pkg_resources
ce88e01
 import platform
ce88e01
 import re
ce88e01
@@ -154,6 +155,11 @@
ce88e01
 # runtime, the shared library must be installed
ce88e01
 BUILD_WITH_SYSTEM_RE2 = _env_bool_value('GRPC_PYTHON_BUILD_SYSTEM_RE2', 'False')
ce88e01
 
ce88e01
+# Export this variable to use the system installation of abseil. You need to
ce88e01
+# have the header files installed (in /usr/include/absl) and during
ce88e01
+# runtime, the shared library must be installed
ce88e01
+BUILD_WITH_SYSTEM_ABSL = os.environ.get('GRPC_PYTHON_BUILD_SYSTEM_ABSL', False)
ce88e01
+
ce88e01
 # Export this variable to force building the python extension with a statically linked libstdc++.
ce88e01
 # At least on linux, this is normally not needed as we can build manylinux-compatible wheels on linux just fine
ce88e01
 # without statically linking libstdc++ (which leads to a slight increase in the wheel size).
ce88e01
@@ -296,6 +302,10 @@
ce88e01
     CORE_C_FILES = filter(lambda x: 'third_party/re2' not in x, CORE_C_FILES)
ce88e01
     RE2_INCLUDE = (os.path.join('/usr', 'include', 're2'),)
ce88e01
 
ce88e01
+if BUILD_WITH_SYSTEM_ABSL:
ce88e01
+    CORE_C_FILES = filter(lambda x: 'third_party/abseil-cpp' not in x, CORE_C_FILES)
ce88e01
+    ABSL_INCLUDE = (os.path.join('/usr', 'include'),)
ce88e01
+
ce88e01
 EXTENSION_INCLUDE_DIRECTORIES = ((PYTHON_STEM,) + CORE_INCLUDE + ABSL_INCLUDE +
ce88e01
                                  ADDRESS_SORTING_INCLUDE + CARES_INCLUDE +
ce88e01
                                  RE2_INCLUDE + SSL_INCLUDE + UPB_INCLUDE +
ce88e01
@@ -325,6 +335,10 @@
ce88e01
     EXTENSION_LIBRARIES += ('cares',)
ce88e01
 if BUILD_WITH_SYSTEM_RE2:
ce88e01
     EXTENSION_LIBRARIES += ('re2',)
ce88e01
+if BUILD_WITH_SYSTEM_ABSL:
ce88e01
+    EXTENSION_LIBRARIES += tuple(
ce88e01
+        lib.stem[3:] for lib in pathlib.Path('/usr').glob('lib*/libabsl_*.so')
ce88e01
+    )
ce88e01
 
ce88e01
 DEFINE_MACROS = (('_WIN32_WINNT', 0x600),)
ce88e01
 asm_files = []