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