2017-10-03 11:16:24 +02:00
|
|
|
from pythonforandroid.recipe import CompiledComponentsPythonRecipe, Recipe
|
|
|
|
from os.path import dirname, join
|
2018-10-07 16:59:03 +02:00
|
|
|
import os
|
2017-10-03 11:16:24 +02:00
|
|
|
|
|
|
|
class CryptographyRecipe(CompiledComponentsPythonRecipe):
|
|
|
|
name = 'cryptography'
|
2020-09-29 19:58:54 +02:00
|
|
|
version = '3.1.1'
|
2017-10-03 11:16:24 +02:00
|
|
|
url = 'https://github.com/pyca/cryptography/archive/{version}.tar.gz'
|
2021-08-21 11:30:12 +02:00
|
|
|
depends = [('python2', 'python3crystax'), 'openssl', 'six', 'setuptools', 'cffi']
|
2017-10-03 11:16:24 +02:00
|
|
|
call_hostpython_via_targetpython = False
|
2020-09-29 22:56:37 +02:00
|
|
|
patches = ['libpthread.patch']
|
2017-10-03 11:16:24 +02:00
|
|
|
|
|
|
|
def get_recipe_env(self, arch):
|
|
|
|
env = super(CryptographyRecipe, self).get_recipe_env(arch)
|
|
|
|
r = self.get_recipe('openssl', self.ctx)
|
|
|
|
openssl_dir = r.get_build_dir(arch.arch)
|
2018-10-07 16:59:03 +02:00
|
|
|
env['CFLAGS'] += ' -I' + join(openssl_dir, 'include') + ' -w'
|
2017-10-03 11:16:24 +02:00
|
|
|
# Set linker to use the correct gcc
|
|
|
|
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
|
2018-10-07 16:59:03 +02:00
|
|
|
env['LDFLAGS'] += ' -L' + openssl_dir + \
|
2017-10-03 11:16:24 +02:00
|
|
|
' -lssl' + r.version + \
|
|
|
|
' -lcrypto' + r.version
|
2018-10-07 16:59:03 +02:00
|
|
|
|
|
|
|
if self.ctx.ndk == 'crystax':
|
|
|
|
# only keeps major.minor (discards patch)
|
|
|
|
python_version = self.ctx.python_recipe.version[0:3]
|
|
|
|
ndk_dir_python = os.path.join(self.ctx.ndk_dir, 'sources/python/', python_version)
|
|
|
|
env['LDFLAGS'] += ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch))
|
2021-08-21 11:30:12 +02:00
|
|
|
env['LDFLAGS'] += ' -lpython{}'.format(python_version)
|
2018-10-07 16:59:03 +02:00
|
|
|
# until `pythonforandroid/archs.py` gets merged upstream:
|
|
|
|
# https://github.com/kivy/python-for-android/pull/1250/files#diff-569e13021e33ced8b54385f55b49cbe6
|
|
|
|
env['CFLAGS'] += ' -I{}/include/python/'.format(ndk_dir_python) + ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch))
|
|
|
|
|
|
|
|
|
2017-10-03 11:16:24 +02:00
|
|
|
return env
|
|
|
|
|
|
|
|
recipe = CryptographyRecipe()
|