Skip to content

Commit b9341ef

Browse files
committed
Migrate to PyProjectRecipe
1 parent f0e6876 commit b9341ef

File tree

2 files changed

+26
-28
lines changed

2 files changed

+26
-28
lines changed
Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,28 @@
1-
import glob
2-
from logging import info
1+
from pythonforandroid.recipe import PyProjectRecipe, Recipe
32

4-
import sh
5-
from pythonforandroid.logger import shprint
6-
from pythonforandroid.recipe import CppCompiledComponentsPythonRecipe
7-
from pythonforandroid.util import current_directory
83

9-
10-
class GrpcioRecipe(CppCompiledComponentsPythonRecipe):
4+
class GrpcioRecipe(PyProjectRecipe):
115
version = '1.64.0'
126
url = 'https://files.pythonhosted.org/packages/source/g/grpcio/grpcio-{version}.tar.gz'
137
depends = ["setuptools", "librt", "libpthread"]
148
patches = ["comment-getserverbyport-r-args.patch", "remove-android-log-write.patch"]
159

1610
def get_recipe_env(self, arch, **kwargs):
1711
env = super().get_recipe_env(arch, **kwargs)
18-
env['NDKPLATFORM'] = "NOTNONE"
19-
env['GRPC_PYTHON_BUILD_WITH_CYTHON'] = '1'
12+
env["NDKPLATFORM"] = "NOTNONE"
13+
env["GRPC_PYTHON_BUILD_SYSTEM_OPENSSL"] = "1"
14+
env["GRPC_PYTHON_BUILD_SYSTEM_ZLIB"] = "1"
15+
env["ZLIB_INCLUDE"] = self.ctx.ndk.sysroot_include_dir
16+
# replace -I with a space
17+
openssl_recipe = Recipe.get_recipe('openssl', self.ctx)
18+
env["SSL_INCLUDE"] = openssl_recipe.include_flags(arch).strip().replace("-I", "")
2019
env["CFLAGS"] += " -U__ANDROID_API__"
2120
env["CFLAGS"] += " -D__ANDROID_API__={}".format(self.ctx.ndk_api)
22-
2321
# turn off c++11 warning error of "invalid suffix on literal"
2422
env["CFLAGS"] += " -Wno-reserved-user-defined-literal"
25-
env['PLATFORM'] = 'android'
23+
env["PLATFORM"] = "android"
2624
env["LDFLAGS"] += " -llog -landroid"
2725
return env
2826

29-
def build_compiled_components(self, arch):
30-
info('Building compiled components in {}'.format(self.name))
31-
32-
env = self.get_recipe_env(arch)
33-
hostpython = sh.Command(self.hostpython_location)
34-
with current_directory(self.get_build_dir(arch.arch)):
35-
if self.install_in_hostpython:
36-
shprint(hostpython, 'setup.py', 'clean', '--all', _env=env)
37-
shprint(hostpython, 'setup.py', self.build_cmd, '-v',
38-
_env=env, *self.setup_extra_args)
39-
40-
# grpcio creates a build directory and names it `pyb`
41-
build_dir = glob.glob('pyb/lib.*')[0]
42-
shprint(sh.find, build_dir, '-name', '"*.o"', '-exec',
43-
env['STRIP'], '{}', ';', _env=env)
44-
4527

4628
recipe = GrpcioRecipe()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--- a/setup.py 2024-05-31 11:20:56.824695569 +0100
2+
+++ b/setup.py 2024-05-31 23:13:40.324392463 +0100
3+
@@ -299,11 +299,11 @@
4+
lambda x: "third_party/boringssl" not in x, CORE_C_FILES
5+
)
6+
CORE_C_FILES = filter(lambda x: "src/boringssl" not in x, CORE_C_FILES)
7+
- SSL_INCLUDE = (os.path.join("/usr", "include", "openssl"),)
8+
+ SSL_INCLUDE = tuple(os.environ["SSL_INCLUDE"].split(" "))
9+
10+
if BUILD_WITH_SYSTEM_ZLIB:
11+
CORE_C_FILES = filter(lambda x: "third_party/zlib" not in x, CORE_C_FILES)
12+
- ZLIB_INCLUDE = (os.path.join("/usr", "include"),)
13+
+ ZLIB_INCLUDE = tuple(os.environ["ZLIB_INCLUDE"].split(" "))
14+
15+
if BUILD_WITH_SYSTEM_CARES:
16+
CORE_C_FILES = filter(lambda x: "third_party/cares" not in x, CORE_C_FILES)

0 commit comments

Comments
 (0)