|
| 1 | +from pythonforandroid.toolchain import PythonRecipe, shprint, shutil, current_directory |
| 2 | +from os.path import join, exists |
| 3 | +import sh |
| 4 | + |
| 5 | +class M2CryptoRecipe(PythonRecipe): |
| 6 | + version = '0.23.0' |
| 7 | + url = 'https://pypi.python.org/packages/source/M/M2Crypto/M2Crypto-{version}.tar.gz' |
| 8 | + #md5sum = '89557730e245294a6cab06de8ad4fb42' |
| 9 | + depends = ['openssl', 'hostpython2', 'python2', 'setuptools'] |
| 10 | + site_packages_name = 'M2Crypto' |
| 11 | + call_hostpython_via_targetpython = False |
| 12 | + |
| 13 | + def build_arch(self, arch): |
| 14 | + env = self.get_recipe_env(arch) |
| 15 | + with current_directory(self.get_build_dir(arch.arch)): |
| 16 | + # Fix missing build dir |
| 17 | + shprint(sh.mkdir, '-p', 'build/lib.' + 'linux-x86_64' + '-2.7/M2Crypto') |
| 18 | + # Build M2Crypto |
| 19 | + hostpython = sh.Command(self.hostpython_location) |
| 20 | + shprint(hostpython, |
| 21 | + 'setup.py', |
| 22 | + 'build_ext', |
| 23 | + '-p' + arch.arch, |
| 24 | + '-c' + 'unix', |
| 25 | + '-o' + env['OPENSSL_BUILD_PATH'], |
| 26 | + '-L' + env['OPENSSL_BUILD_PATH'] |
| 27 | + , _env=env) |
| 28 | + # Install M2Crypto |
| 29 | + super(M2CryptoRecipe, self).build_arch(arch) |
| 30 | + |
| 31 | + def get_recipe_env(self, arch): |
| 32 | + env = super(M2CryptoRecipe, self).get_recipe_env(arch) |
| 33 | + env['OPENSSL_BUILD_PATH'] = self.get_recipe('openssl', self.ctx).get_build_dir(arch.arch) |
| 34 | + env['CFLAGS'] += ' -I' + join(self.ctx.get_python_install_dir(), 'include/python2.7') |
| 35 | + # Set linker to use the correct gcc |
| 36 | + env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions' |
| 37 | + env['LDFLAGS'] += ' -lpython2.7' |
| 38 | + return env |
| 39 | + |
| 40 | +recipe = M2CryptoRecipe() |
0 commit comments