Skip to content

Commit 9485875

Browse files
committed
Fix openssl dependant recipe: cryptography+cffi
Since the recent openssl upgrade this recipe stopped to work. Here we adapt the recipe to the new build circumstances and we also fix the cffi recipe because it is a direct dependency of cryptography and had the wrong flags for the new python2 build system.
1 parent 8493d5e commit 9485875

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

pythonforandroid/recipes/cffi/__init__.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ def get_hostrecipe_env(self, arch=None):
2727

2828
def get_recipe_env(self, arch=None):
2929
env = super(CffiRecipe, self).get_recipe_env(arch)
30-
# sets linker to use the correct gcc (cross compiler)
31-
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
3230
libffi = self.get_recipe('libffi', self.ctx)
3331
includes = libffi.get_include_dirs(arch)
3432
env['CFLAGS'] = ' -I'.join([env.get('CFLAGS', '')] + includes)
33+
env['CFLAGS'] += ' -I{}'.format(self.ctx.python_recipe.include_root(arch.arch))
3534
env['LDFLAGS'] = (env.get('CFLAGS', '') + ' -L' +
3635
self.ctx.get_libs_dir(arch.arch))
3736
env['LDFLAGS'] += ' -L{}'.format(os.path.join(self.ctx.bootstrap.build_dir, 'libs', arch.arch))
@@ -44,15 +43,10 @@ def get_recipe_env(self, arch=None):
4443
self.ctx.get_site_packages_dir(),
4544
env['BUILDLIB_PATH'],
4645
])
47-
if self.ctx.ndk == 'crystax':
48-
# only keeps major.minor (discards patch)
49-
python_version = self.ctx.python_recipe.version[0:3]
50-
ndk_dir_python = os.path.join(self.ctx.ndk_dir, 'sources/python/', python_version)
51-
env['LDFLAGS'] += ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch))
52-
env['LDFLAGS'] += ' -lpython{}m'.format(python_version)
53-
# until `pythonforandroid/archs.py` gets merged upstream:
54-
# https://github.com/kivy/python-for-android/pull/1250/files#diff-569e13021e33ced8b54385f55b49cbe6
55-
env['CFLAGS'] += ' -I{}/include/python/'.format(ndk_dir_python)
46+
env['LDFLAGS'] += ' -L{}'.format(self.ctx.python_recipe.link_root(arch.arch))
47+
env['LDFLAGS'] += ' -lpython{}'.format(self.ctx.python_recipe.major_minor_version_string)
48+
if 'python3' in self.ctx.python_recipe.name:
49+
env['LDFLAGS'] += 'm'
5650
return env
5751

5852

pythonforandroid/recipes/cryptography/__init__.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
from pythonforandroid.recipe import CompiledComponentsPythonRecipe
2-
from os.path import join
1+
from pythonforandroid.recipe import CompiledComponentsPythonRecipe, Recipe
32

43

54
class CryptographyRecipe(CompiledComponentsPythonRecipe):
65
name = 'cryptography'
76
version = '2.3.1'
87
url = 'https://github.com/pyca/cryptography/archive/{version}.tar.gz'
9-
depends = [('python2', 'python3crystax'), 'openssl', 'idna', 'asn1crypto', 'six', 'setuptools', 'enum34', 'ipaddress', 'cffi']
8+
depends = [('python2', 'python3crystax'), 'openssl', 'idna', 'asn1crypto',
9+
'six', 'setuptools', 'enum34', 'ipaddress', 'cffi']
1010
call_hostpython_via_targetpython = False
1111

1212
def get_recipe_env(self, arch):
1313
env = super(CryptographyRecipe, self).get_recipe_env(arch)
14-
r = self.get_recipe('openssl', self.ctx)
15-
openssl_dir = r.get_build_dir(arch.arch)
16-
# Set linker to use the correct gcc
17-
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
18-
env['CFLAGS'] += ' -I' + join(openssl_dir, 'include')
19-
env['LDFLAGS'] += ' -L' + openssl_dir + \
20-
' -lssl' + r.version + \
21-
' -lcrypto' + r.version
14+
15+
openssl_recipe = Recipe.get_recipe('openssl', self.ctx)
16+
env['CFLAGS'] += openssl_recipe.include_flags(arch)
17+
env['LDFLAGS'] += openssl_recipe.link_flags(arch)
2218

2319
return env
2420

0 commit comments

Comments
 (0)