2019-03-30 21:58:45 +01:00
|
|
|
from pythonforandroid.recipe import CompiledComponentsPythonRecipe
|
|
|
|
from pythonforandroid.toolchain import current_directory
|
|
|
|
from pythonforandroid.logger import shprint, info
|
|
|
|
import glob
|
2017-08-13 03:24:00 +02:00
|
|
|
import sh
|
|
|
|
|
2019-03-30 21:58:45 +01:00
|
|
|
|
|
|
|
class M2CryptoRecipe(CompiledComponentsPythonRecipe):
|
|
|
|
version = '0.30.1'
|
2017-08-13 03:24:00 +02:00
|
|
|
url = 'https://pypi.python.org/packages/source/M/M2Crypto/M2Crypto-{version}.tar.gz'
|
2019-03-30 21:58:45 +01:00
|
|
|
depends = ['openssl', 'setuptools']
|
2017-08-13 03:24:00 +02:00
|
|
|
site_packages_name = 'M2Crypto'
|
|
|
|
call_hostpython_via_targetpython = False
|
|
|
|
|
2019-03-30 21:58:45 +01:00
|
|
|
def build_compiled_components(self, arch):
|
|
|
|
info('Building compiled components in {}'.format(self.name))
|
|
|
|
|
2017-08-13 03:24:00 +02:00
|
|
|
env = self.get_recipe_env(arch)
|
|
|
|
with current_directory(self.get_build_dir(arch.arch)):
|
|
|
|
# Build M2Crypto
|
|
|
|
hostpython = sh.Command(self.hostpython_location)
|
2019-03-30 21:58:45 +01:00
|
|
|
if self.install_in_hostpython:
|
|
|
|
shprint(hostpython, 'setup.py', 'clean', '--all', _env=env)
|
|
|
|
shprint(hostpython, 'setup.py', self.build_cmd,
|
2017-08-13 03:24:00 +02:00
|
|
|
'-p' + arch.arch,
|
|
|
|
'-c' + 'unix',
|
2019-03-30 21:58:45 +01:00
|
|
|
'-o' + env['OPENSSL_BUILD_PATH'],
|
|
|
|
'-L' + env['OPENSSL_BUILD_PATH'],
|
|
|
|
_env=env, *self.setup_extra_args)
|
|
|
|
build_dir = glob.glob('build/lib.*')[0]
|
|
|
|
shprint(sh.find, build_dir, '-name', '"*.o"', '-exec',
|
|
|
|
env['STRIP'], '{}', ';', _env=env)
|
2017-08-13 03:24:00 +02:00
|
|
|
|
|
|
|
def get_recipe_env(self, arch):
|
|
|
|
env = super(M2CryptoRecipe, self).get_recipe_env(arch)
|
2019-03-30 21:58:45 +01:00
|
|
|
env['OPENSSL_BUILD_PATH'] = self.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
|
2017-08-13 03:24:00 +02:00
|
|
|
return env
|
|
|
|
|
2019-03-30 21:58:45 +01:00
|
|
|
|
2017-08-13 03:24:00 +02:00
|
|
|
recipe = M2CryptoRecipe()
|