Skip to content

Commit 0d35f86

Browse files
author
Jonas Thiem
committed
Call Cython via python -m Cython rather than system-wide binary
- call Cython via `python -m Cython` to avoid picking one not matching the current python version (which can happen if just calling `Cython`) - this should fix #1885
1 parent 308df31 commit 0d35f86

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

pythonforandroid/build.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@
2727
RECOMMENDED_NDK_API, RECOMMENDED_TARGET_API)
2828

2929

30-
def get_cython_path():
31-
for cython_fn in ("cython", "cython3", "cython2", "cython-2.7"):
32-
cython = sh.which(cython_fn)
33-
if cython:
34-
return cython
35-
raise BuildInterruptingException('No cython binary found.')
36-
37-
3830
def get_ndk_platform_dir(ndk_dir, ndk_api, arch):
3931
ndk_platform_dir_exists = True
4032
platform_dir = arch.platform_dir
@@ -111,7 +103,6 @@ class Context(object):
111103
use_setup_py = False
112104

113105
ccache = None # whether to use ccache
114-
cython = None # the cython interpreter name
115106

116107
ndk_platform = None # the ndk platform directory
117108

@@ -374,7 +365,6 @@ def prepare_build_environment(self,
374365
if not self.ccache:
375366
info('ccache is missing, the build will not be optimized in the '
376367
'future.')
377-
self.cython = get_cython_path()
378368

379369
# This would need to be changed if supporting multiarch APKs
380370
arch = self.archs[0]

pythonforandroid/recipe.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,8 +1024,12 @@ def cythonize_file(self, env, build_dir, filename):
10241024
del cyenv['PYTHONPATH']
10251025
if 'PYTHONNOUSERSITE' in cyenv:
10261026
cyenv.pop('PYTHONNOUSERSITE')
1027-
cython_command = sh.Command(self.ctx.cython)
1028-
shprint(cython_command, filename, *self.cython_args, _env=cyenv)
1027+
cython_command = sh.Command(
1028+
"python" +
1029+
self.ctx.python_recipe.major_minor_version_string.split(".")[0]
1030+
)
1031+
shprint(cython_command, "-m", "Cython",
1032+
filename, *self.cython_args, _env=cyenv)
10291033

10301034
def cythonize_build(self, env, build_dir="."):
10311035
if not self.cythonize:

tests/test_toolchain.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ def test_create(self):
6868
) as m_get_toolchain_versions, mock.patch(
6969
'pythonforandroid.build.get_ndk_platform_dir'
7070
) as m_get_ndk_platform_dir, mock.patch(
71-
'pythonforandroid.build.get_cython_path'
72-
) as m_get_cython_path, mock.patch(
7371
'pythonforandroid.toolchain.build_recipes'
7472
) as m_build_recipes, mock.patch(
7573
'pythonforandroid.bootstraps.service_only.'
@@ -84,7 +82,6 @@ def test_create(self):
8482
mock.call('/tmp/android-sdk')]
8583
assert m_get_toolchain_versions.call_args_list == [
8684
mock.call('/tmp/android-ndk', mock.ANY)]
87-
assert m_get_cython_path.call_args_list == [mock.call()]
8885
build_order = [
8986
'hostpython3', 'libffi', 'openssl', 'sqlite3', 'python3',
9087
'genericndkbuild', 'setuptools', 'six', 'pyjnius', 'android',

0 commit comments

Comments
 (0)