Skip to content

Commit cc379cd

Browse files
committed
Speed up Python and NumPy compilation process
Uses `-j` flag on target/host python as well as numpy to run compilation in parallel. In Python an optimum number of jobs is guessed if the flag is used alone. In NumPy it must be explicitly set.
1 parent b168978 commit cc379cd

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

pythonforandroid/python.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def build_arch(self, arch):
250250
py_version = self.major_minor_version_string
251251
if self.major_minor_version_string[0] == '3':
252252
py_version += 'm'
253-
shprint(sh.make, 'all',
253+
shprint(sh.make, 'all', '-j',
254254
'INSTSONAME=libpython{version}.so'.format(
255255
version=py_version), _env=env)
256256

@@ -420,7 +420,7 @@ def build_arch(self, arch):
420420
shprint(sh.cp, join('Modules', 'Setup.dist'),
421421
join(build_dir, 'Modules', 'Setup'))
422422

423-
result = shprint(sh.make, '-C', build_dir)
423+
result = shprint(sh.make, '-j', '-C', build_dir)
424424
else:
425425
info('Skipping {name} ({version}) build, as it has already '
426426
'been completed'.format(name=self.name, version=self.version))

pythonforandroid/recipes/numpy/__init__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pythonforandroid.recipe import CompiledComponentsPythonRecipe
2+
from multiprocessing import cpu_count
23
from os.path import join
34

45

@@ -7,7 +8,6 @@ class NumpyRecipe(CompiledComponentsPythonRecipe):
78
version = '1.15.1'
89
url = 'https://pypi.python.org/packages/source/n/numpy/numpy-{version}.zip'
910
site_packages_name = 'numpy'
10-
1111
depends = [('python2', 'python3', 'python3crystax')]
1212

1313
patches = [
@@ -18,6 +18,16 @@ class NumpyRecipe(CompiledComponentsPythonRecipe):
1818
join('patches', 'python-fixes.patch')
1919
]
2020

21+
def build_compiled_components(self, arch):
22+
setup_extra_args = ['-j', str(cpu_count())]
23+
super(NumpyRecipe, self).build_compiled_components(arch)
24+
setup_extra_args = []
25+
26+
def rebuild_compiled_components(self, arch, env):
27+
setup_extra_args = ['-j', str(cpu_count())]
28+
super(NumpyRecipe, self).rebuild_compiled_components(arch, env)
29+
setup_extra_args = []
30+
2131
def get_recipe_env(self, arch):
2232
env = super(NumpyRecipe, self).get_recipe_env(arch)
2333

@@ -44,8 +54,5 @@ def get_recipe_env(self, arch):
4454
env['LD'] += flags + ' -shared'
4555
return env
4656

47-
def prebuild_arch(self, arch):
48-
super(NumpyRecipe, self).prebuild_arch(arch)
49-
5057

5158
recipe = NumpyRecipe()

0 commit comments

Comments
 (0)