Skip to content

Commit f079030

Browse files
authored
new package: python3.12-grpcio (#146)
1 parent 76ea4e7 commit f079030

11 files changed

+338
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--- a/third_party/abseil-cpp/absl/log/internal/log_sink_set.cc
2+
+++ b/third_party/abseil-cpp/absl/log/internal/log_sink_set.cc
3+
@@ -19,7 +19,7 @@
4+
#include <pthread.h>
5+
#endif
6+
7+
-#ifdef __ANDROID__
8+
+#if defined(__ANDROID__) && !defined(__TERMUX__)
9+
#include <android/log.h>
10+
#endif
11+
12+
@@ -116,7 +116,7 @@
13+
}
14+
};
15+
16+
-#if defined(__ANDROID__)
17+
+#if defined(__ANDROID__) && !defined(__TERMUX__)
18+
class AndroidLogSink final : public LogSink {
19+
public:
20+
~AndroidLogSink() override = default;
21+
@@ -172,7 +172,7 @@
22+
static absl::NoDestructor<StderrLogSink> stderr_log_sink;
23+
AddLogSink(stderr_log_sink.get());
24+
#endif
25+
-#ifdef __ANDROID__
26+
+#if defined(__ANDROID__) && !defined(__TERMUX__)
27+
static absl::NoDestructor<AndroidLogSink> android_log_sink;
28+
AddLogSink(android_log_sink.get());
29+
#endif
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
TERMUX_PKG_HOMEPAGE=https://grpc.io/
2+
TERMUX_PKG_DESCRIPTION="High performance, open source, general RPC framework that puts mobile and HTTP/2 first"
3+
TERMUX_PKG_LICENSE="Apache-2.0"
4+
TERMUX_PKG_MAINTAINER="@termux-user-repository"
5+
TERMUX_PKG_SRCURL=git+https://github.com/grpc/grpc
6+
TERMUX_PKG_VERSION="1.66.2"
7+
TERMUX_PKG_DEPENDS="ca-certificates, libc++, openssl, python, zlib"
8+
TERMUX_PKG_PYTHON_COMMON_DEPS="wheel, setuptools, 'Cython>=3.0.0'"
9+
TERMUX_PKG_BUILD_IN_SRC=true
10+
TERMUX_PKG_AUTO_UPDATE=true
11+
TERMUX_PKG_UPDATE_TAG_TYPE="latest-release-tag"
12+
13+
TERMUX_PYTHON_VERSION=3.12
14+
TERMUX_PYTHON_CROSSENV_PREFIX=$TERMUX_PKG_BUILDDIR/python${TERMUX_PYTHON_VERSION/./}-crossenv-prefix-$TERMUX_ARCH
15+
TUR_AUTO_AUDIT_WHEEL=true
16+
TUR_AUDIT_WHEEL_NO_LIBS=true
17+
18+
source $TERMUX_SCRIPTDIR/common-files/tur_build_wheel.sh
19+
20+
termux_step_pre_configure() {
21+
rm CMakeLists.txt Makefile Rakefile
22+
23+
export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
24+
export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1
25+
export GRPC_PYTHON_BUILD_WITH_CYTHON=1
26+
27+
mkdir -p $TERMUX_PKG_TMPDIR/_fake_bin
28+
sed -e "s|@TERMUX_PREFIX@|${TERMUX_PREFIX}|g" \
29+
-e "s|@COMPILER@|$(command -v ${CC})|g" \
30+
"$TERMUX_PKG_BUILDER_DIR"/wrapper.py.in \
31+
> $TERMUX_PKG_TMPDIR/_fake_bin/"$(basename ${CC})"
32+
chmod +x $TERMUX_PKG_TMPDIR/_fake_bin/"$(basename ${CC})"
33+
export PATH="$TERMUX_PKG_TMPDIR/_fake_bin:$PATH"
34+
}
35+
36+
termux_step_post_massage() {
37+
# Ensure no liblog.so is linked
38+
local _cygrpc_so="$TERMUX_PYTHON_HOME/site-packages/grpc/_cython/cygrpc.cpython-${TERMUX_PYTHON_VERSION/./}.so"
39+
if [ ! -e "$_cygrpc_so" ]; then
40+
termux_error_exit "Package ${TERMUX_PKG_NAME} doesn't build properly."
41+
fi
42+
if readelf -d "$_cygrpc_so" | grep -q '(NEEDED).*\[liblog\.so'; then
43+
termux_error_exit "Found liblog.so linked."
44+
fi
45+
46+
tur_build_wheel
47+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
--- a/third_party/cares/cares/src/lib/ares_android.c
2+
+++ b/third_party/cares/cares/src/lib/ares_android.c
3+
@@ -12,7 +12,7 @@
4+
* this software for any purpose. It is provided "as is"
5+
* without express or implied warranty.
6+
*/
7+
-#if defined(ANDROID) || defined(__ANDROID__)
8+
+#if 0
9+
10+
#include <jni.h>
11+
12+
--- a/third_party/cares/cares/src/lib/ares_init.c
13+
+++ b/third_party/cares/cares/src/lib/ares_init.c
14+
@@ -47,7 +47,9 @@
15+
16+
#if defined(ANDROID) || defined(__ANDROID__)
17+
#include <sys/system_properties.h>
18+
+#if 0
19+
#include "ares_android.h"
20+
+#endif
21+
/* From the Bionic sources */
22+
#define DNS_PROP_NAME_PREFIX "net.dns"
23+
#define MAX_DNS_PROPERTIES 8
24+
@@ -1321,6 +1323,7 @@
25+
char *domains;
26+
size_t num_servers;
27+
28+
+#if 0
29+
/* Use the Android connectivity manager to get a list
30+
* of DNS servers. As of Android 8 (Oreo) net.dns#
31+
* system properties are no longer available. Google claims this
32+
@@ -1346,6 +1349,7 @@
33+
set_search(channel, domains);
34+
ares_free(domains);
35+
}
36+
+#endif
37+
38+
# ifdef HAVE___SYSTEM_PROPERTY_GET
39+
/* Old way using the system property still in place as
40+
--- a/third_party/cares/cares/src/lib/ares_library_init.c
41+
+++ b/third_party/cares/cares/src/lib/ares_library_init.c
42+
@@ -32,7 +32,7 @@
43+
44+
/* library-private global and unique instance vars */
45+
46+
-#if defined(ANDROID) || defined(__ANDROID__)
47+
+#if 0
48+
#include "ares_android.h"
49+
#endif
50+
51+
@@ -141,7 +141,7 @@
52+
53+
/* NOTE: ARES_LIB_INIT_WIN32 flag no longer used */
54+
55+
-#if defined(ANDROID) || defined(__ANDROID__)
56+
+#if 0
57+
ares_library_cleanup_android();
58+
#endif
59+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--- a/third_party/cares/cares/src/lib/ares_private.h
2+
+++ b/third_party/cares/cares/src/lib/ares_private.h
3+
@@ -92,11 +92,11 @@
4+
5+
#else
6+
7+
-#define PATH_RESOLV_CONF "/etc/resolv.conf"
8+
+#define PATH_RESOLV_CONF "@TERMUX_PREFIX@/etc/resolv.conf"
9+
#ifdef ETC_INET
10+
-#define PATH_HOSTS "/etc/inet/hosts"
11+
+#define PATH_HOSTS "@TERMUX_PREFIX@/etc/inet/hosts"
12+
#else
13+
-#define PATH_HOSTS "/etc/hosts"
14+
+#define PATH_HOSTS "@TERMUX_PREFIX@/etc/hosts"
15+
#endif
16+
17+
#endif
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--- a/third_party/cares/cares/src/lib/ares_init.c
2+
+++ b/third_party/cares/cares/src/lib/ares_init.c
3+
@@ -1351,7 +1351,7 @@
4+
}
5+
#endif
6+
7+
-# ifdef HAVE___SYSTEM_PROPERTY_GET
8+
+# if 0
9+
/* Old way using the system property still in place as
10+
* a fallback. Older android versions can still use this.
11+
* it's possible for older apps not not have added the new
12+
@@ -1377,6 +1377,8 @@
13+
}
14+
}
15+
# endif /* HAVE___SYSTEM_PROPERTY_GET */
16+
+ config_nameserver(&servers, &nservers, "8.8.4.4");
17+
+ status = ARES_EOF;
18+
#elif defined(CARES_USE_LIBRESOLV)
19+
struct __res_state res;
20+
int result;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--- a/third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/common.cc
2+
+++ b/third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/common.cc
3+
@@ -124,7 +124,7 @@
4+
5+
namespace internal {
6+
7+
-#if defined(__ANDROID__)
8+
+#if defined(__ANDROID__) && !defined(__TERMUX__)
9+
inline void DefaultLogHandler(LogLevel level, const char* filename, int line,
10+
const string& message) {
11+
if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) {
12+
--- a/third_party/protobuf/third_party/abseil-cpp/absl/log/internal/log_sink_set.cc
13+
+++ b/third_party/protobuf/third_party/abseil-cpp/absl/log/internal/log_sink_set.cc
14+
@@ -19,7 +19,7 @@
15+
#include <pthread.h>
16+
#endif
17+
18+
-#ifdef __ANDROID__
19+
+#if defined(__ANDROID__) && !defined(__TERMUX__)
20+
#include <android/log.h>
21+
#endif
22+
23+
@@ -116,7 +116,7 @@
24+
}
25+
};
26+
27+
-#if defined(__ANDROID__)
28+
+#if defined(__ANDROID__) && !defined(__TERMUX__)
29+
class AndroidLogSink final : public LogSink {
30+
public:
31+
~AndroidLogSink() override = default;
32+
@@ -172,7 +172,7 @@
33+
static absl::NoDestructor<StderrLogSink> stderr_log_sink;
34+
AddLogSink(stderr_log_sink.get());
35+
#endif
36+
-#ifdef __ANDROID__
37+
+#if defined(__ANDROID__) && !defined(__TERMUX__)
38+
static absl::NoDestructor<AndroidLogSink> android_log_sink;
39+
AddLogSink(android_log_sink.get());
40+
#endif
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--- a/setup.py
2+
+++ b/setup.py
3+
@@ -63,7 +63,7 @@
4+
if "freebsd" in sys.platform:
5+
CARES_INCLUDE += (os.path.join("third_party", "cares", "config_freebsd"),)
6+
if "linux" in sys.platform:
7+
- CARES_INCLUDE += (os.path.join("third_party", "cares", "config_linux"),)
8+
+ CARES_INCLUDE += (os.path.join("third_party", "cares", "config_android"),)
9+
if "openbsd" in sys.platform:
10+
CARES_INCLUDE += (os.path.join("third_party", "cares", "config_openbsd"),)
11+
RE2_INCLUDE = (os.path.join("third_party", "re2"),)
12+
@@ -314,25 +314,25 @@
13+
lambda x: "third_party/boringssl" not in x, CORE_C_FILES
14+
)
15+
CORE_C_FILES = filter(lambda x: "src/boringssl" not in x, CORE_C_FILES)
16+
- SSL_INCLUDE = (os.path.join("/usr", "include", "openssl"),)
17+
+ SSL_INCLUDE = (os.path.join("@TERMUX_PREFIX@", "include", "openssl"),)
18+
19+
if BUILD_WITH_SYSTEM_ZLIB:
20+
CORE_C_FILES = filter(lambda x: "third_party/zlib" not in x, CORE_C_FILES)
21+
- ZLIB_INCLUDE = (os.path.join("/usr", "include"),)
22+
+ ZLIB_INCLUDE = (os.path.join("@TERMUX_PREFIX@", "include"),)
23+
24+
if BUILD_WITH_SYSTEM_CARES:
25+
CORE_C_FILES = filter(lambda x: "third_party/cares" not in x, CORE_C_FILES)
26+
- CARES_INCLUDE = (os.path.join("/usr", "include"),)
27+
+ CARES_INCLUDE = (os.path.join("@TERMUX_PREFIX@", "include"),)
28+
29+
if BUILD_WITH_SYSTEM_RE2:
30+
CORE_C_FILES = filter(lambda x: "third_party/re2" not in x, CORE_C_FILES)
31+
- RE2_INCLUDE = (os.path.join("/usr", "include", "re2"),)
32+
+ RE2_INCLUDE = (os.path.join("@TERMUX_PREFIX@", "include", "re2"),)
33+
34+
if BUILD_WITH_SYSTEM_ABSL:
35+
CORE_C_FILES = filter(
36+
lambda x: "third_party/abseil-cpp" not in x, CORE_C_FILES
37+
)
38+
- ABSL_INCLUDE = (os.path.join("/usr", "include"),)
39+
+ ABSL_INCLUDE = (os.path.join("@TERMUX_PREFIX@", "include"),)
40+
41+
EXTENSION_INCLUDE_DIRECTORIES = (
42+
(PYTHON_STEM,)
43+
@@ -375,7 +375,7 @@
44+
if BUILD_WITH_SYSTEM_ABSL:
45+
EXTENSION_LIBRARIES += tuple(
46+
lib.stem[3:]
47+
- for lib in sorted(pathlib.Path("/usr").glob("lib*/libabsl_*.so"))
48+
+ for lib in sorted(pathlib.Path("@TERMUX_PREFIX@").glob("lib*/libabsl_*.so"))
49+
)
50+
51+
DEFINE_MACROS = (("_WIN32_WINNT", 0x600),)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--- a/src/core/lib/security/security_connector/load_system_roots_supported.cc
2+
+++ b/src/core/lib/security/security_connector/load_system_roots_supported.cc
3+
@@ -52,12 +52,12 @@
4+
5+
#if defined(GPR_LINUX) || defined(GPR_ANDROID)
6+
const char* kCertFiles[] = {
7+
- "/etc/ssl/certs/ca-certificates.crt", "/etc/pki/tls/certs/ca-bundle.crt",
8+
- "/etc/ssl/ca-bundle.pem", "/etc/pki/tls/cacert.pem",
9+
- "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"};
10+
+ "@TERMUX_PREFIX@/etc/ssl/certs/ca-certificates.crt", "@TERMUX_PREFIX@/etc/pki/tls/certs/ca-bundle.crt",
11+
+ "@TERMUX_PREFIX@/etc/ssl/ca-bundle.pem", "@TERMUX_PREFIX@/etc/pki/tls/cacert.pem",
12+
+ "@TERMUX_PREFIX@/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"};
13+
const char* kCertDirectories[] = {
14+
- "/etc/ssl/certs", "/system/etc/security/cacerts", "/usr/local/share/certs",
15+
- "/etc/pki/tls/certs", "/etc/openssl/certs"};
16+
+ "@TERMUX_PREFIX@/etc/ssl/certs", "@TERMUX_PREFIX@/share/certs",
17+
+ "@TERMUX_PREFIX@/etc/pki/tls/certs", "@TERMUX_PREFIX@/etc/openssl/certs"};
18+
#elif defined(GPR_FREEBSD) // endif GPR_LINUX || GPR_ANDROID
19+
const char* kCertFiles[] = {"/etc/ssl/cert.pem",
20+
"/usr/local/share/certs/ca-root-nss.crt"};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--- a/src/core/lib/security/security_connector/ssl_utils.cc
2+
+++ b/src/core/lib/security/security_connector/ssl_utils.cc
3+
@@ -45,9 +45,9 @@
4+
static const char* installed_roots_path = GRPC_ROOT_PEM_PATH;
5+
#elif defined(INSTALL_PREFIX)
6+
static const char* installed_roots_path =
7+
- INSTALL_PREFIX "/usr/share/grpc/roots.pem";
8+
+ INSTALL_PREFIX "$TERMUX_PREFIX@/share/grpc/roots.pem";
9+
#else
10+
-static const char* installed_roots_path = "/usr/share/grpc/roots.pem";
11+
+static const char* installed_roots_path = "@TERMUX_PREFIX@/share/grpc/roots.pem";
12+
#endif
13+
14+
#ifndef TSI_OPENSSL_ALPN_SUPPORT
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a/src/core/util/posix/tmpfile.cc
2+
+++ b/src/core/util/posix/tmpfile.cc
3+
@@ -39,7 +39,7 @@
4+
5+
if (tmp_filename != nullptr) *tmp_filename = nullptr;
6+
7+
- gpr_asprintf(&filename_template, "/tmp/%s_XXXXXX", prefix);
8+
+ gpr_asprintf(&filename_template, "@TERMUX_PREFIX@/tmp/%s_XXXXXX", prefix);
9+
CHECK_NE(filename_template, nullptr);
10+
11+
fd = mkstemp(filename_template);

0 commit comments

Comments
 (0)