Skip to content

Commit d1d358e

Browse files
committed
Fix grpcio OpenSSL discovery for Android via OPENSSL_ROOT_DIR
grpcio hardcodes /usr/include/openssl for system OpenSSL. Patch setup.py to read OPENSSL_ROOT_DIR env var and set it in the recipe to point to the cross-compiled OpenSSL in site-packages/opt.
1 parent dadd962 commit d1d358e

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

recipes/grpcio/meta.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ build:
88
GRPC_PYTHON_BUILD_SYSTEM_OPENSSL: '1'
99
GRPC_PYTHON_BUILD_SYSTEM_ZLIB: '1'
1010
PLATFORM: android
11-
CFLAGS: '-U__ANDROID_API__ -D__ANDROID_API__={{ sdk_version }} -Wno-reserved-user-defined-literal -I{platlib}/opt/include'
11+
OPENSSL_ROOT_DIR: '{platlib}/opt'
12+
CFLAGS: '-U__ANDROID_API__ -D__ANDROID_API__={{ sdk_version }} -Wno-reserved-user-defined-literal'
1213
LDFLAGS: '-llog -L{platlib}/opt/lib'
1314
# {% else %}
1415
CXXFLAGS: -std=c++14 -Wno-c++11-narrowing
Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
diff --git a/setup.py b/setup.py
2-
index 48bfefe..ff21bc5 100644
32
--- a/setup.py
43
+++ b/setup.py
54
@@ -58,12 +58,14 @@ CARES_INCLUDE = (
@@ -18,22 +17,13 @@ index 48bfefe..ff21bc5 100644
1817
if "openbsd" in sys.platform:
1918
CARES_INCLUDE += (os.path.join("third_party", "cares", "config_openbsd"),)
2019
RE2_INCLUDE = (os.path.join("third_party", "re2"),)
21-
@@ -329,15 +331,16 @@ EXTENSION_INCLUDE_DIRECTORIES = (
22-
+ ADDRESS_SORTING_INCLUDE
23-
+ CARES_INCLUDE
24-
+ RE2_INCLUDE
25-
- + SSL_INCLUDE
26-
+ UPB_INCLUDE
27-
+ UPB_GRPC_GENERATED_INCLUDE
28-
+ UPBDEFS_GRPC_GENERATED_INCLUDE
29-
+ UTF8_RANGE_INCLUDE
30-
+ XXHASH_INCLUDE
31-
- + ZLIB_INCLUDE
32-
)
33-
34-
+if "android" not in sys.platform:
35-
+ EXTENSION_INCLUDE_DIRECTORIES += SSL_INCLUDE + ZLIB_INCLUDE
36-
+
37-
EXTENSION_LIBRARIES = ()
38-
if "linux" in sys.platform:
39-
EXTENSION_LIBRARIES += ("rt",)
20+
@@ -304,7 +306,9 @@ if BUILD_WITH_SYSTEM_OPENSSL:
21+
)
22+
CORE_C_FILES = filter(lambda x: "src/boringssl" not in x, CORE_C_FILES)
23+
- SSL_INCLUDE = (os.path.join("/usr", "include", "openssl"),)
24+
+ # Use cross-compiled OpenSSL headers when OPENSSL_ROOT_DIR is set
25+
+ _ssl_prefix = os.environ.get("OPENSSL_ROOT_DIR", "/usr")
26+
+ SSL_INCLUDE = (os.path.join(_ssl_prefix, "include"),)
27+
28+
if BUILD_WITH_SYSTEM_ZLIB:
29+
CORE_C_FILES = filter(lambda x: "third_party/zlib" not in x, CORE_C_FILES)

0 commit comments

Comments
 (0)