Skip to content

Commit 63f03f5

Browse files
committed
Modified CythonRecipe to work with crystax build
1 parent e6e4a6a commit 63f03f5

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

pythonforandroid/recipe.py

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -771,37 +771,54 @@ def build_arch(self, arch):
771771

772772
def build_cython_components(self, arch):
773773
info('Cythonizing anything necessary in {}'.format(self.name))
774+
774775
env = self.get_recipe_env(arch)
775-
# env['PYTHONHOME'] = self.ctx.get_python_install_dir()
776-
env['PYTHONPATH'] = '/usr/lib/python3.5/site-packages/:/usr/lib/python3.5'
776+
777+
if self.ctx.ndk_is_crystax:
778+
site_packages_dirs = sh.Command('python3.5')('-c', 'import site; print("\\n".join(site.getsitepackages()))').stdout.split('\n')
779+
# env['PYTHONPATH'] = '/usr/lib/python3.5/site-packages/:/usr/lib/python3.5'
780+
if 'PYTHONPATH' in env:
781+
env['PYTHONPATH'] = env + ':{}'.format(':'.join(site_packages_dirs))
782+
else:
783+
env['PYTHONPATH'] = ':'.join(site_packages_dirs)
784+
777785
with current_directory(self.get_build_dir(arch.arch)):
778786
# hostpython = sh.Command(self.ctx.hostpython)
779787
hostpython = sh.Command('python3.5')
780788
shprint(hostpython, '-c', 'import sys; print(sys.path)', _env=env)
781789
print('cwd is', realpath(curdir))
782790
info('Trying first build of {} to get cython files: this is '
783791
'expected to fail'.format(self.name))
792+
793+
manually_cythonise = False
784794
try:
785-
shprint(hostpython, 'setup.py', 'build_ext', _env=env,
795+
shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env,
786796
*self.setup_extra_args)
787797
except sh.ErrorReturnCode_1:
788798
print()
789799
info('{} first build failed (as expected)'.format(self.name))
800+
manually_cythonise = True
790801

791-
info('Running cython where appropriate')
792-
# shprint(sh.find, self.get_build_dir(arch.arch), '-iname', '*.pyx',
793-
# '-exec', self.ctx.cython, '{}', ';', _env=env)
794-
shprint(sh.find, self.get_build_dir(arch.arch), '-iname', '*.pyx',
795-
'-exec', self.ctx.cython, '{}', ';')
796-
info('ran cython')
802+
if manually_cythonise:
803+
info('Running cython where appropriate')
804+
if self.ctx.ndk_is_crystax:
805+
shprint(sh.find, self.get_build_dir(arch.arch), '-iname', '*.pyx',
806+
'-exec', self.ctx.cython, '{}', ';')
807+
else:
808+
shprint(sh.find, self.get_build_dir(arch.arch), '-iname', '*.pyx',
809+
'-exec', self.ctx.cython, '{}', ';', _env=env)
810+
info('ran cython')
797811

798-
shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env,
799-
_tail=20, _critical=True, *self.setup_extra_args)
812+
shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env,
813+
_tail=20, _critical=True, *self.setup_extra_args)
814+
else:
815+
info('First build appeared to complete correctly, skipping manual'
816+
'cythonising.')
800817

801-
# print('stripping')
802-
# build_lib = glob.glob('./build/lib*')
803-
# shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
804-
# env['STRIP'], '{}', ';', _env=env)
818+
print('stripping')
819+
build_lib = glob.glob('./build/lib*')
820+
shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
821+
env['STRIP'], '{}', ';', _env=env)
805822
print('stripped!?')
806823
# exit(1)
807824

pythonforandroid/recipes/python3crystax/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ def prebuild_arch(self, arch):
2828

2929
def build_arch(self, arch):
3030
info('Extracting CrystaX python3 from NDK package')
31-
# This is necessary (I think?) in order for the
32-
# cross-compilation to work
3331

3432
dirn = self.ctx.get_python_install_dir()
3533
ensure_dir(dirn)

0 commit comments

Comments
 (0)