Skip to content

Commit ac76dee

Browse files
authored
Merge pull request #1545 from opacam/python-core-cryptography-cffi
[CORE UPDATE - PART IV] Fix cryptography+cffi
2 parents 81a8bf6 + 84b01f0 commit ac76dee

File tree

6 files changed

+32
-32
lines changed

6 files changed

+32
-32
lines changed

pythonforandroid/recipes/cffi/__init__.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class CffiRecipe(CompiledComponentsPythonRecipe):
1010
version = '1.11.5'
1111
url = 'https://pypi.python.org/packages/source/c/cffi/cffi-{version}.tar.gz'
1212

13-
depends = [('python2', 'python3crystax'), 'setuptools', 'pycparser', 'libffi']
13+
depends = ['setuptools', 'pycparser', 'libffi']
1414

1515
patches = ['disable-pkg-config.patch']
1616

@@ -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: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
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'
7-
version = '2.3.1'
6+
version = '2.4.2'
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 = ['openssl', 'idna', 'asn1crypto', 'six', 'setuptools',
9+
'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_dirs_flags(arch)
18+
env['LIBS'] = openssl_recipe.link_libs_flags()
2219

2320
return env
2421

pythonforandroid/recipes/enum34/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,19 @@
44
class Enum34Recipe(PythonRecipe):
55
version = '1.1.3'
66
url = 'https://pypi.python.org/packages/source/e/enum34/enum34-{version}.tar.gz'
7-
depends = [('python2', 'python3crystax'), 'setuptools']
7+
depends = ['setuptools']
88
site_packages_name = 'enum'
99
call_hostpython_via_targetpython = False
1010

11+
def should_build(self, arch):
12+
if 'python3' in self.ctx.python_recipe.name:
13+
# Since python 3.6 the enum34 library is no longer compatible with
14+
# the standard library and it will cause errors, so we disable it
15+
# in favour of the internal module, but we still add python3 to
16+
# attribute `depends` because otherwise we will not be able to
17+
# build the cryptography recipe.
18+
return False
19+
return super(Enum34Recipe, self).should_build(arch)
20+
1121

1222
recipe = Enum34Recipe()

pythonforandroid/recipes/idna/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
class IdnaRecipe(PythonRecipe):
55
name = 'idna'
6-
version = '2.6'
6+
version = '2.8'
77
url = 'https://github.com/kjd/idna/archive/v{version}.tar.gz'
88

9-
depends = [('python2', 'python3crystax'), 'setuptools']
9+
depends = ['setuptools']
1010

1111
call_hostpython_via_targetpython = False
1212

pythonforandroid/recipes/ipaddress/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33

44
class IpaddressRecipe(PythonRecipe):
55
name = 'ipaddress'
6-
version = '1.0.16'
7-
url = 'https://pypi.python.org/packages/source/i/ipaddress/ipaddress-{version}.tar.gz'
8-
9-
depends = [('python2', 'python3crystax')]
6+
version = '1.0.22'
7+
url = 'https://github.com/phihag/ipaddress/archive/v{version}.tar.gz'
8+
depends = ['setuptools']
109

1110

1211
recipe = IpaddressRecipe()

pythonforandroid/recipes/pycparser/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class PycparserRecipe(PythonRecipe):
66
version = '2.14'
77
url = 'https://pypi.python.org/packages/source/p/pycparser/pycparser-{version}.tar.gz'
88

9-
depends = [('python2', 'python3crystax'), 'setuptools']
9+
depends = ['setuptools']
1010

1111
call_hostpython_via_targetpython = False
1212

0 commit comments

Comments
 (0)