Skip to content

Commit 83d33e5

Browse files
committed
TODO/WIP 🐛 Upgrade and fix gevent recipe, closes TODO-2805
The error was: ``` Traceback (most recent call last): File "/home/user/.local/share/python-for-android/build/other_builds/gevent/x86__ndk_target_24/gevent/setup.py", line 46, in <module> from _setuplibev import libev_configure_command File "/home/user/.local/share/python-for-android/build/other_builds/gevent/x86__ndk_target_24/gevent/_setuplibev.py", line 34, in <module> " && sh ./configure --host={} ".format(os.environ['TOOLCHAIN_PREFIX']), ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ File "<frozen os>", line 679, in __getitem__ KeyError: 'TOOLCHAIN_PREFIX' ```
1 parent ceed049 commit 83d33e5

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

pythonforandroid/recipes/gevent/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import re
22
from pythonforandroid.logger import info
3-
from pythonforandroid.recipe import CythonRecipe
3+
from pythonforandroid.recipe import PyProjectRecipe
44

55

6-
class GeventRecipe(CythonRecipe):
7-
version = '1.4.0'
8-
url = 'https://pypi.python.org/packages/source/g/gevent/gevent-{version}.tar.gz'
6+
class GeventRecipe(PyProjectRecipe):
7+
version = '24.11.1'
8+
url = 'https://github.com/gevent/gevent/archive/refs/tags/{version}.tar.gz'
99
depends = ['librt', 'setuptools']
1010
patches = ["cross_compiling.patch"]
1111

12-
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
12+
def get_recipe_env(self, arch, **kwargs):
1313
"""
1414
- Moves all -I<inc> -D<macro> from CFLAGS to CPPFLAGS environment.
1515
- Moves all -l<lib> from LDFLAGS to LIBS environment.
1616
- Copies all -l<lib> from LDLIBS to LIBS environment.
1717
- Fixes linker name (use cross compiler) and flags (appends LIBS)
1818
"""
19-
env = super().get_recipe_env(arch, with_flags_in_cc)
19+
env = super().get_recipe_env(arch, **kwargs)
2020
# CFLAGS may only be used to specify C compiler flags, for macro definitions use CPPFLAGS
2121
regex = re.compile(r'(?:\s|^)-[DI][\S]+')
2222
env['CPPFLAGS'] = ''.join(re.findall(regex, env['CFLAGS'])).strip()
@@ -28,6 +28,8 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
2828
env['LIBS'] += ' {}'.format(''.join(re.findall(regex, env['LDLIBS'])).strip())
2929
env['LDFLAGS'] = re.sub(regex, '', env['LDFLAGS'])
3030
info('Moved "{}" from LDFLAGS to LIBS.'.format(env['LIBS']))
31+
# set missing TOOLCHAIN_PREFIX, refs #2805
32+
env['TOOLCHAIN_PREFIX'] = arch.command_prefix
3133
return env
3234

3335

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
diff --git a/_setupares.py b/_setupares.py
2-
index dd184de6..bb16bebe 100644
2+
index c42fe369..cd8854df 100644
33
--- a/_setupares.py
44
+++ b/_setupares.py
5-
@@ -43,7 +43,7 @@ else:
5+
@@ -42,7 +42,7 @@ cflags = ('CFLAGS="%s"' % (cflags,)) if cflags else ''
66
ares_configure_command = ' '.join([
77
"(cd ", quoted_dep_abspath('c-ares'),
8-
" && if [ -r ares_build.h ]; then cp ares_build.h ares_build.h.orig; fi ",
9-
- " && sh ./configure --disable-dependency-tracking " + _m32 + "CONFIG_COMMANDS= ",
10-
+ " && sh ./configure --host={} --disable-dependency-tracking ".format(os.environ['TOOLCHAIN_PREFIX']) + _m32 + "CONFIG_COMMANDS= ",
11-
" && cp ares_config.h ares_build.h \"$OLDPWD\" ",
12-
" && cat ares_build.h ",
13-
" && if [ -r ares_build.h.orig ]; then mv ares_build.h.orig ares_build.h; fi)",
8+
" && if [ -r include/ares_build.h ]; then cp include/ares_build.h include/ares_build.h.orig; fi ",
9+
- " && sh ./configure --disable-dependency-tracking --disable-tests -C " + cflags,
10+
+ " && sh ./configure --host={} --disable-dependency-tracking --disable-tests -C ".format(os.environ['TOOLCHAIN_PREFIX']) + cflags,
11+
" && cp src/lib/ares_config.h include/ares_build.h \"$OLDPWD\" ",
12+
" && cat include/ares_build.h ",
13+
" && if [ -r include/ares_build.h.orig ]; then mv include/ares_build.h.orig include/ares_build.h; fi)",
1414
diff --git a/_setuplibev.py b/_setuplibev.py
15-
index 2a5841bf..b6433c94 100644
15+
index f05c2fe9..32f9bd81 100644
1616
--- a/_setuplibev.py
1717
+++ b/_setuplibev.py
18-
@@ -31,7 +31,7 @@ LIBEV_EMBED = should_embed('libev')
19-
# and the PyPy branch will clean it up.
18+
@@ -28,7 +28,7 @@ LIBEV_EMBED = should_embed('libev')
19+
# Configure libev in place
2020
libev_configure_command = ' '.join([
2121
"(cd ", quoted_dep_abspath('libev'),
22-
- " && sh ./configure ",
23-
+ " && sh ./configure --host={} ".format(os.environ['TOOLCHAIN_PREFIX']),
24-
" && cp config.h \"$OLDPWD\"",
22+
- " && sh ./configure -C > configure-output.txt",
23+
+ " && sh ./configure --host={} -C > configure-output.txt".format(os.environ['TOOLCHAIN_PREFIX']),
2524
")",
26-
'> configure-output.txt'
25+
])
26+

0 commit comments

Comments
 (0)