Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up Python and NumPy compilation process #1651

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pythonforandroid/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'''

from os.path import dirname, exists, join
from multiprocessing import cpu_count
from shutil import copy2
from os import environ
import subprocess
Expand Down Expand Up @@ -250,7 +251,7 @@ def build_arch(self, arch):
py_version = self.major_minor_version_string
if self.major_minor_version_string[0] == '3':
py_version += 'm'
shprint(sh.make, 'all',
shprint(sh.make, 'all', '-j', str(cpu_count()),
'INSTSONAME=libpython{version}.so'.format(
version=py_version), _env=env)

Expand Down Expand Up @@ -420,7 +421,7 @@ def build_arch(self, arch):
shprint(sh.cp, join('Modules', 'Setup.dist'),
join(build_dir, 'Modules', 'Setup'))

result = shprint(sh.make, '-C', build_dir)
result = shprint(sh.make, '-j', str(cpu_count()), '-C', build_dir)
else:
info('Skipping {name} ({version}) build, as it has already '
'been completed'.format(name=self.name, version=self.version))
Expand Down
15 changes: 11 additions & 4 deletions pythonforandroid/recipes/numpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pythonforandroid.recipe import CompiledComponentsPythonRecipe
from multiprocessing import cpu_count
from os.path import join


Expand All @@ -7,7 +8,6 @@ class NumpyRecipe(CompiledComponentsPythonRecipe):
version = '1.15.1'
url = 'https://pypi.python.org/packages/source/n/numpy/numpy-{version}.zip'
site_packages_name = 'numpy'

depends = [('python2', 'python3', 'python3crystax')]

patches = [
Expand All @@ -18,6 +18,16 @@ class NumpyRecipe(CompiledComponentsPythonRecipe):
join('patches', 'python-fixes.patch')
]

def build_compiled_components(self, arch):
self.setup_extra_args = ['-j', str(cpu_count())]
super(NumpyRecipe, self).build_compiled_components(arch)
self.setup_extra_args = []

def rebuild_compiled_components(self, arch, env):
self.setup_extra_args = ['-j', str(cpu_count())]
super(NumpyRecipe, self).rebuild_compiled_components(arch, env)
self.setup_extra_args = []

def get_recipe_env(self, arch):
env = super(NumpyRecipe, self).get_recipe_env(arch)

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

def prebuild_arch(self, arch):
super(NumpyRecipe, self).prebuild_arch(arch)


recipe = NumpyRecipe()