2017-08-13 03:24:00 +02:00
|
|
|
# coding=utf-8
|
|
|
|
|
|
|
|
from pythonforandroid.recipe import CythonRecipe, Recipe
|
|
|
|
from os.path import join
|
|
|
|
from pythonforandroid.util import current_directory
|
|
|
|
import sh
|
|
|
|
from pythonforandroid.logger import shprint
|
|
|
|
import glob
|
|
|
|
|
|
|
|
|
|
|
|
class PyZMQRecipe(CythonRecipe):
|
|
|
|
name = 'pyzmq'
|
2022-12-02 21:15:34 +01:00
|
|
|
version = '20.0.0'
|
|
|
|
url = 'https://github.com/zeromq/pyzmq/archive/v{version}.zip'
|
2017-08-13 03:24:00 +02:00
|
|
|
site_packages_name = 'zmq'
|
2022-12-02 21:15:34 +01:00
|
|
|
depends = ['setuptools', 'libzmq']
|
2017-08-13 03:24:00 +02:00
|
|
|
cython_args = ['-Izmq/utils',
|
|
|
|
'-Izmq/backend/cython',
|
|
|
|
'-Izmq/devices']
|
|
|
|
|
|
|
|
def get_recipe_env(self, arch=None):
|
2022-12-02 21:15:34 +01:00
|
|
|
env = super().get_recipe_env(arch)
|
2017-08-13 03:24:00 +02:00
|
|
|
# TODO: fix hardcoded path
|
|
|
|
# This is required to prevent issue with _io.so import.
|
|
|
|
# hostpython = self.get_recipe('hostpython2', self.ctx)
|
|
|
|
# env['PYTHONPATH'] = (
|
|
|
|
# join(hostpython.get_build_dir(arch.arch), 'build',
|
|
|
|
# 'lib.linux-x86_64-2.7') + ':' + env.get('PYTHONPATH', '')
|
|
|
|
# )
|
|
|
|
# env["LDSHARED"] = env["CC"] + ' -shared'
|
|
|
|
return env
|
|
|
|
|
|
|
|
def build_cython_components(self, arch):
|
|
|
|
libzmq_recipe = Recipe.get_recipe('libzmq', self.ctx)
|
|
|
|
libzmq_prefix = join(libzmq_recipe.get_build_dir(arch.arch), "install")
|
|
|
|
self.setup_extra_args = ["--zmq={}".format(libzmq_prefix)]
|
|
|
|
self.build_cmd = "configure"
|
|
|
|
|
|
|
|
env = self.get_recipe_env(arch)
|
|
|
|
setup_cfg = join(self.get_build_dir(arch.arch), "setup.cfg")
|
|
|
|
with open(setup_cfg, "wb") as fd:
|
|
|
|
fd.write("""
|
|
|
|
[global]
|
|
|
|
zmq_prefix = {}
|
|
|
|
skip_check_zmq = True
|
2022-12-02 21:15:34 +01:00
|
|
|
""".format(libzmq_prefix).encode())
|
2017-08-13 03:24:00 +02:00
|
|
|
|
2022-12-02 21:15:34 +01:00
|
|
|
return super().build_cython_components(arch)
|
2017-08-13 03:24:00 +02:00
|
|
|
|
|
|
|
with current_directory(self.get_build_dir(arch.arch)):
|
|
|
|
hostpython = sh.Command(self.hostpython_location)
|
|
|
|
shprint(hostpython, 'setup.py', 'configure', '-v', _env=env)
|
|
|
|
shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env)
|
|
|
|
build_dir = glob.glob('build/lib.*')[0]
|
|
|
|
shprint(sh.find, build_dir, '-name', '"*.o"', '-exec',
|
|
|
|
env['STRIP'], '{}', ';', _env=env)
|
|
|
|
|
2019-03-30 21:58:45 +01:00
|
|
|
|
2017-08-13 03:24:00 +02:00
|
|
|
recipe = PyZMQRecipe()
|