Skip to content

Gevent Crystax/Python3 support #1251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2018
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
18 changes: 18 additions & 0 deletions pythonforandroid/recipes/gevent/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from pythonforandroid.toolchain import CompiledComponentsPythonRecipe


Expand All @@ -7,4 +8,21 @@ class GeventRecipe(CompiledComponentsPythonRecipe):
depends = [('python2', 'python3crystax'), 'greenlet']
patches = ["gevent.patch"]

def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super(GeventRecipe, self).get_recipe_env(arch, with_flags_in_cc)
# sets linker to use the correct gcc (cross compiler)
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise the default host linker was picked up rather than the ARM cross compiler.

# CFLAGS may only be used to specify C compiler flags, for macro definitions use CPPFLAGS
env['CPPFLAGS'] = env['CFLAGS'] + ' -I{}/sources/python/3.5/include/python/'.format(self.ctx.ndk_dir)
env['CFLAGS'] = ''
# LDFLAGS may only be used to specify linker flags, for libraries use LIBS
env['LDFLAGS'] = env['LDFLAGS'].replace('-lm', '').replace('-lcrystax', '')
env['LDFLAGS'] += ' -L{}'.format(os.path.join(self.ctx.bootstrap.build_dir, 'libs', arch.arch))
env['LIBS'] = ' -lm'
if self.ctx.ndk == 'crystax':
env['LIBS'] += ' -lcrystax -lpython{}m'.format(self.ctx.python_recipe.version[0:3])
env['LDSHARED'] += env['LIBS']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that we don't get run time cannot locate symbol errors.

return env


recipe = GeventRecipe()
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/gevent/gevent.patch
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ diff -Naur gevent-1.1.1/setup.py gevent-1.1.1_diff/setup.py
ares_configure_command = ' '.join(["(cd ", _quoted_abspath('c-ares/'),
" && if [ -r ares_build.h ]; then cp ares_build.h ares_build.h.orig; fi ",
- " && /bin/sh ./configure " + _m32 + "CONFIG_COMMANDS= CONFIG_FILES= ",
+ " && /bin/sh ./configure --host={} ".format(os.environ['TOOLCHAIN_PREFIX']) + "CFLAGS= LDFLAGS= CONFIG_COMMANDS= CONFIG_FILES= ",
+ " && /bin/sh ./configure --host={} ".format(os.environ['TOOLCHAIN_PREFIX']) + "CONFIG_COMMANDS= CONFIG_FILES= ",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sanitizing CFLAGS and LDFLAGS is now handled in get_recipe_env().

" && cp ares_config.h ares_build.h \"$OLDPWD\" ",
" && mv ares_build.h.orig ares_build.h)",
"> configure-output.txt"])