kivy-ios/kivy_ios/recipes/cryptography/__init__.py

55 lines
2.2 KiB
Python
Raw Permalink Normal View History

from os.path import join
2020-09-28 23:29:32 +02:00
from kivy_ios.toolchain import CythonRecipe, Recipe, shprint
from kivy_ios.context_managers import cd
import os
import sh
class CryptographyRecipe(CythonRecipe):
name = "cryptography"
2020-09-28 23:29:32 +02:00
version = "3.1.1"
url = "https://pypi.python.org/packages/source/c/cryptography/cryptography-{version}.tar.gz"
library = "libcryptography.a"
2020-09-28 23:29:32 +02:00
depends = ["host_setuptools3", "host_cffi", "cffi", "asn1crypto", "idna", "six"]
python_depends = ["setuptools"]
cythonize = True
pre_build_ext = True
def dest_dir(self):
return join(self.ctx.dist_dir, "root", "python3")
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)
2020-09-28 23:29:32 +02:00
target_python = Recipe.get_recipe('python3', self.ctx).get_build_dir(arch.arch)
env['LDFLAGS'] += ' -L' + target_python
2020-09-28 23:29:32 +02:00
env['PYTHON_ROOT'] = join(self.ctx.dist_dir, "root", "python3")
env["CC"] = "clang -Qunused-arguments -fcolor-diagnostics"
2020-09-28 23:29:32 +02:00
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python3.8' + \
' -I' + join(openssl_dir, 'include') + \
' -I' + join(self.ctx.dist_dir, "include", arch.arch, "libffi")
env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \
' -L' + openssl_dir + \
2020-09-28 23:29:32 +02:00
' -lpython3.8' + \
' -lssl' + \
' -lcrypto' + \
' -lffi' + \
' -lcffi'
return env
2020-09-28 23:29:32 +02:00
def install(self):
arch = list(self.filtered_archs)[0]
build_dir = self.get_build_dir(arch.arch)
os.chdir(build_dir)
hostpython = sh.Command(self.ctx.hostpython)
build_env = arch.get_env()
2020-09-28 23:29:32 +02:00
dest_dir = join(self.ctx.dist_dir, "root", "python3")
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.8', 'site-packages')
with cd(build_dir):
shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)
recipe = CryptographyRecipe()