Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions tur-pypi-312/python3.12-grpcio/absl-disable-android-log.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--- a/third_party/abseil-cpp/absl/log/internal/log_sink_set.cc
+++ b/third_party/abseil-cpp/absl/log/internal/log_sink_set.cc
@@ -19,7 +19,7 @@
#include <pthread.h>
#endif

-#ifdef __ANDROID__
+#if defined(__ANDROID__) && !defined(__TERMUX__)
#include <android/log.h>
#endif

@@ -116,7 +116,7 @@
}
};

-#if defined(__ANDROID__)
+#if defined(__ANDROID__) && !defined(__TERMUX__)
class AndroidLogSink final : public LogSink {
public:
~AndroidLogSink() override = default;
@@ -172,7 +172,7 @@
static absl::NoDestructor<StderrLogSink> stderr_log_sink;
AddLogSink(stderr_log_sink.get());
#endif
-#ifdef __ANDROID__
+#if defined(__ANDROID__) && !defined(__TERMUX__)
static absl::NoDestructor<AndroidLogSink> android_log_sink;
AddLogSink(android_log_sink.get());
#endif
47 changes: 47 additions & 0 deletions tur-pypi-312/python3.12-grpcio/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
TERMUX_PKG_HOMEPAGE=https://grpc.io/
TERMUX_PKG_DESCRIPTION="High performance, open source, general RPC framework that puts mobile and HTTP/2 first"
TERMUX_PKG_LICENSE="Apache-2.0"
TERMUX_PKG_MAINTAINER="@termux-user-repository"
TERMUX_PKG_SRCURL=git+https://github.com/grpc/grpc
TERMUX_PKG_VERSION="1.66.2"
TERMUX_PKG_DEPENDS="ca-certificates, libc++, openssl, python, zlib"
TERMUX_PKG_PYTHON_COMMON_DEPS="wheel, setuptools, 'Cython>=3.0.0'"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_UPDATE_TAG_TYPE="latest-release-tag"

TERMUX_PYTHON_VERSION=3.12
TERMUX_PYTHON_CROSSENV_PREFIX=$TERMUX_PKG_BUILDDIR/python${TERMUX_PYTHON_VERSION/./}-crossenv-prefix-$TERMUX_ARCH
TUR_AUTO_AUDIT_WHEEL=true
TUR_AUDIT_WHEEL_NO_LIBS=true

source $TERMUX_SCRIPTDIR/common-files/tur_build_wheel.sh

termux_step_pre_configure() {
rm CMakeLists.txt Makefile Rakefile

export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1
export GRPC_PYTHON_BUILD_WITH_CYTHON=1

mkdir -p $TERMUX_PKG_TMPDIR/_fake_bin
sed -e "s|@TERMUX_PREFIX@|${TERMUX_PREFIX}|g" \
-e "s|@COMPILER@|$(command -v ${CC})|g" \
"$TERMUX_PKG_BUILDER_DIR"/wrapper.py.in \
> $TERMUX_PKG_TMPDIR/_fake_bin/"$(basename ${CC})"
chmod +x $TERMUX_PKG_TMPDIR/_fake_bin/"$(basename ${CC})"
export PATH="$TERMUX_PKG_TMPDIR/_fake_bin:$PATH"
}

termux_step_post_massage() {
# Ensure no liblog.so is linked
local _cygrpc_so="$TERMUX_PYTHON_HOME/site-packages/grpc/_cython/cygrpc.cpython-${TERMUX_PYTHON_VERSION/./}.so"
if [ ! -e "$_cygrpc_so" ]; then
termux_error_exit "Package ${TERMUX_PKG_NAME} doesn't build properly."
fi
if readelf -d "$_cygrpc_so" | grep -q '(NEEDED).*\[liblog\.so'; then
termux_error_exit "Found liblog.so linked."
fi

tur_build_wheel
}
59 changes: 59 additions & 0 deletions tur-pypi-312/python3.12-grpcio/cares-disable-ares-android.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
--- a/third_party/cares/cares/src/lib/ares_android.c
+++ b/third_party/cares/cares/src/lib/ares_android.c
@@ -12,7 +12,7 @@
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
-#if defined(ANDROID) || defined(__ANDROID__)
+#if 0

#include <jni.h>

--- a/third_party/cares/cares/src/lib/ares_init.c
+++ b/third_party/cares/cares/src/lib/ares_init.c
@@ -47,7 +47,9 @@

#if defined(ANDROID) || defined(__ANDROID__)
#include <sys/system_properties.h>
+#if 0
#include "ares_android.h"
+#endif
/* From the Bionic sources */
#define DNS_PROP_NAME_PREFIX "net.dns"
#define MAX_DNS_PROPERTIES 8
@@ -1321,6 +1323,7 @@
char *domains;
size_t num_servers;

+#if 0
/* Use the Android connectivity manager to get a list
* of DNS servers. As of Android 8 (Oreo) net.dns#
* system properties are no longer available. Google claims this
@@ -1346,6 +1349,7 @@
set_search(channel, domains);
ares_free(domains);
}
+#endif

# ifdef HAVE___SYSTEM_PROPERTY_GET
/* Old way using the system property still in place as
--- a/third_party/cares/cares/src/lib/ares_library_init.c
+++ b/third_party/cares/cares/src/lib/ares_library_init.c
@@ -32,7 +32,7 @@

/* library-private global and unique instance vars */

-#if defined(ANDROID) || defined(__ANDROID__)
+#if 0
#include "ares_android.h"
#endif

@@ -141,7 +141,7 @@

/* NOTE: ARES_LIB_INIT_WIN32 flag no longer used */

-#if defined(ANDROID) || defined(__ANDROID__)
+#if 0
ares_library_cleanup_android();
#endif

17 changes: 17 additions & 0 deletions tur-pypi-312/python3.12-grpcio/cares-fix-path-etc-hosts.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- a/third_party/cares/cares/src/lib/ares_private.h
+++ b/third_party/cares/cares/src/lib/ares_private.h
@@ -92,11 +92,11 @@

#else

-#define PATH_RESOLV_CONF "/etc/resolv.conf"
+#define PATH_RESOLV_CONF "@TERMUX_PREFIX@/etc/resolv.conf"
#ifdef ETC_INET
-#define PATH_HOSTS "/etc/inet/hosts"
+#define PATH_HOSTS "@TERMUX_PREFIX@/etc/inet/hosts"
#else
-#define PATH_HOSTS "/etc/hosts"
+#define PATH_HOSTS "@TERMUX_PREFIX@/etc/hosts"
#endif

#endif
20 changes: 20 additions & 0 deletions tur-pypi-312/python3.12-grpcio/cares-hardcode-fallback-dns.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- a/third_party/cares/cares/src/lib/ares_init.c
+++ b/third_party/cares/cares/src/lib/ares_init.c
@@ -1351,7 +1351,7 @@
}
#endif

-# ifdef HAVE___SYSTEM_PROPERTY_GET
+# if 0
/* Old way using the system property still in place as
* a fallback. Older android versions can still use this.
* it's possible for older apps not not have added the new
@@ -1377,6 +1377,8 @@
}
}
# endif /* HAVE___SYSTEM_PROPERTY_GET */
+ config_nameserver(&servers, &nservers, "8.8.4.4");
+ status = ARES_EOF;
#elif defined(CARES_USE_LIBRESOLV)
struct __res_state res;
int result;
40 changes: 40 additions & 0 deletions tur-pypi-312/python3.12-grpcio/protobuf-disable-android-log.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--- a/third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/common.cc
+++ b/third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/common.cc
@@ -124,7 +124,7 @@

namespace internal {

-#if defined(__ANDROID__)
+#if defined(__ANDROID__) && !defined(__TERMUX__)
inline void DefaultLogHandler(LogLevel level, const char* filename, int line,
const string& message) {
if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) {
--- a/third_party/protobuf/third_party/abseil-cpp/absl/log/internal/log_sink_set.cc
+++ b/third_party/protobuf/third_party/abseil-cpp/absl/log/internal/log_sink_set.cc
@@ -19,7 +19,7 @@
#include <pthread.h>
#endif

-#ifdef __ANDROID__
+#if defined(__ANDROID__) && !defined(__TERMUX__)
#include <android/log.h>
#endif

@@ -116,7 +116,7 @@
}
};

-#if defined(__ANDROID__)
+#if defined(__ANDROID__) && !defined(__TERMUX__)
class AndroidLogSink final : public LogSink {
public:
~AndroidLogSink() override = default;
@@ -172,7 +172,7 @@
static absl::NoDestructor<StderrLogSink> stderr_log_sink;
AddLogSink(stderr_log_sink.get());
#endif
-#ifdef __ANDROID__
+#if defined(__ANDROID__) && !defined(__TERMUX__)
static absl::NoDestructor<AndroidLogSink> android_log_sink;
AddLogSink(android_log_sink.get());
#endif
51 changes: 51 additions & 0 deletions tur-pypi-312/python3.12-grpcio/setup.py.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
--- a/setup.py
+++ b/setup.py
@@ -63,7 +63,7 @@
if "freebsd" in sys.platform:
CARES_INCLUDE += (os.path.join("third_party", "cares", "config_freebsd"),)
if "linux" in sys.platform:
- CARES_INCLUDE += (os.path.join("third_party", "cares", "config_linux"),)
+ CARES_INCLUDE += (os.path.join("third_party", "cares", "config_android"),)
if "openbsd" in sys.platform:
CARES_INCLUDE += (os.path.join("third_party", "cares", "config_openbsd"),)
RE2_INCLUDE = (os.path.join("third_party", "re2"),)
@@ -314,25 +314,25 @@
lambda x: "third_party/boringssl" not in x, CORE_C_FILES
)
CORE_C_FILES = filter(lambda x: "src/boringssl" not in x, CORE_C_FILES)
- SSL_INCLUDE = (os.path.join("/usr", "include", "openssl"),)
+ SSL_INCLUDE = (os.path.join("@TERMUX_PREFIX@", "include", "openssl"),)

if BUILD_WITH_SYSTEM_ZLIB:
CORE_C_FILES = filter(lambda x: "third_party/zlib" not in x, CORE_C_FILES)
- ZLIB_INCLUDE = (os.path.join("/usr", "include"),)
+ ZLIB_INCLUDE = (os.path.join("@TERMUX_PREFIX@", "include"),)

if BUILD_WITH_SYSTEM_CARES:
CORE_C_FILES = filter(lambda x: "third_party/cares" not in x, CORE_C_FILES)
- CARES_INCLUDE = (os.path.join("/usr", "include"),)
+ CARES_INCLUDE = (os.path.join("@TERMUX_PREFIX@", "include"),)

if BUILD_WITH_SYSTEM_RE2:
CORE_C_FILES = filter(lambda x: "third_party/re2" not in x, CORE_C_FILES)
- RE2_INCLUDE = (os.path.join("/usr", "include", "re2"),)
+ RE2_INCLUDE = (os.path.join("@TERMUX_PREFIX@", "include", "re2"),)

if BUILD_WITH_SYSTEM_ABSL:
CORE_C_FILES = filter(
lambda x: "third_party/abseil-cpp" not in x, CORE_C_FILES
)
- ABSL_INCLUDE = (os.path.join("/usr", "include"),)
+ ABSL_INCLUDE = (os.path.join("@TERMUX_PREFIX@", "include"),)

EXTENSION_INCLUDE_DIRECTORIES = (
(PYTHON_STEM,)
@@ -375,7 +375,7 @@
if BUILD_WITH_SYSTEM_ABSL:
EXTENSION_LIBRARIES += tuple(
lib.stem[3:]
- for lib in sorted(pathlib.Path("/usr").glob("lib*/libabsl_*.so"))
+ for lib in sorted(pathlib.Path("@TERMUX_PREFIX@").glob("lib*/libabsl_*.so"))
)

DEFINE_MACROS = (("_WIN32_WINNT", 0x600),)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- a/src/core/lib/security/security_connector/load_system_roots_supported.cc
+++ b/src/core/lib/security/security_connector/load_system_roots_supported.cc
@@ -52,12 +52,12 @@

#if defined(GPR_LINUX) || defined(GPR_ANDROID)
const char* kCertFiles[] = {
- "/etc/ssl/certs/ca-certificates.crt", "/etc/pki/tls/certs/ca-bundle.crt",
- "/etc/ssl/ca-bundle.pem", "/etc/pki/tls/cacert.pem",
- "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"};
+ "@TERMUX_PREFIX@/etc/ssl/certs/ca-certificates.crt", "@TERMUX_PREFIX@/etc/pki/tls/certs/ca-bundle.crt",
+ "@TERMUX_PREFIX@/etc/ssl/ca-bundle.pem", "@TERMUX_PREFIX@/etc/pki/tls/cacert.pem",
+ "@TERMUX_PREFIX@/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"};
const char* kCertDirectories[] = {
- "/etc/ssl/certs", "/system/etc/security/cacerts", "/usr/local/share/certs",
- "/etc/pki/tls/certs", "/etc/openssl/certs"};
+ "@TERMUX_PREFIX@/etc/ssl/certs", "@TERMUX_PREFIX@/share/certs",
+ "@TERMUX_PREFIX@/etc/pki/tls/certs", "@TERMUX_PREFIX@/etc/openssl/certs"};
#elif defined(GPR_FREEBSD) // endif GPR_LINUX || GPR_ANDROID
const char* kCertFiles[] = {"/etc/ssl/cert.pem",
"/usr/local/share/certs/ca-root-nss.crt"};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- a/src/core/lib/security/security_connector/ssl_utils.cc
+++ b/src/core/lib/security/security_connector/ssl_utils.cc
@@ -45,9 +45,9 @@
static const char* installed_roots_path = GRPC_ROOT_PEM_PATH;
#elif defined(INSTALL_PREFIX)
static const char* installed_roots_path =
- INSTALL_PREFIX "/usr/share/grpc/roots.pem";
+ INSTALL_PREFIX "$TERMUX_PREFIX@/share/grpc/roots.pem";
#else
-static const char* installed_roots_path = "/usr/share/grpc/roots.pem";
+static const char* installed_roots_path = "@TERMUX_PREFIX@/share/grpc/roots.pem";
#endif

#ifndef TSI_OPENSSL_ALPN_SUPPORT
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/src/core/util/posix/tmpfile.cc
+++ b/src/core/util/posix/tmpfile.cc
@@ -39,7 +39,7 @@

if (tmp_filename != nullptr) *tmp_filename = nullptr;

- gpr_asprintf(&filename_template, "/tmp/%s_XXXXXX", prefix);
+ gpr_asprintf(&filename_template, "@TERMUX_PREFIX@/tmp/%s_XXXXXX", prefix);
CHECK_NE(filename_template, nullptr);

fd = mkstemp(filename_template);
30 changes: 30 additions & 0 deletions tur-pypi-312/python3.12-grpcio/wrapper.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/python3
import os
import subprocess
import sys
import typing

COMPLIER_PATH = "@COMPILER@"
TERMUX_PREFIX = "@TERMUX_PREFIX@"

def main(argv: typing.List[str]):
cwd = os.getcwd()
# Move `-I@TERMUX_PREFIX@/include` to the last include param
argv_new = []
argv_last = []
for arg in argv[1:]:
if arg.startswith("-I@TERMUX_PREFIX@"):
argv_last.append(arg)
else:
argv_new.append(arg)
ind = -1
for i, arg in enumerate(argv_new):
if arg.startswith("-I"):
ind = i
if ind != -1:
argv_new = argv_new[:ind + 1] + argv_last + argv_new[ind + 1:]
args = [COMPLIER_PATH] + argv_new
subprocess.check_call(args, env=os.environ, cwd=cwd, text=True)

if __name__ == '__main__':
main(sys.argv)