|
| 1 | +from pythonforandroid.recipe import CompiledComponentsPythonRecipe, Recipe |
| 2 | +from multiprocessing import cpu_count |
| 3 | + |
| 4 | + |
| 5 | +class ThisRecipe(CompiledComponentsPythonRecipe): |
| 6 | + |
| 7 | + site_packages_name = 'scikit-learn' |
| 8 | + version = '0.23.2' |
| 9 | + url = f'https://github.com/{site_packages_name}/{site_packages_name}/archive/{version}.zip' |
| 10 | + depends = ['setuptools', 'scipy', 'joblib', 'threadpoolctl'] |
| 11 | + call_hostpython_via_targetpython = False |
| 12 | + need_stl_shared = True |
| 13 | + patches = ['cross-compile.patch'] |
| 14 | + |
| 15 | + def build_compiled_components(self, arch): |
| 16 | + self.setup_extra_args = ['-j', str(cpu_count())] |
| 17 | + super().build_compiled_components(arch) |
| 18 | + self.setup_extra_args = [] |
| 19 | + |
| 20 | + def rebuild_compiled_components(self, arch, env): |
| 21 | + self.setup_extra_args = ['-j', str(cpu_count())] |
| 22 | + super().rebuild_compiled_components(arch, env) |
| 23 | + self.setup_extra_args = [] |
| 24 | + |
| 25 | + def strip_ccache(self, env): |
| 26 | + for key, value in env.items(): |
| 27 | + parts = value.split(' ') |
| 28 | + if 'ccache' in parts[0]: |
| 29 | + env[key] = ' '.join(parts[1:]) |
| 30 | + |
| 31 | + def get_recipe_env(self, arch): |
| 32 | + env = super().get_recipe_env(arch) |
| 33 | + self.strip_ccache(env) |
| 34 | + scipy_build_dir = Recipe.get_recipe('scipy', self.ctx).get_build_dir(arch.arch) |
| 35 | + env['PYTHONPATH'] += f':{scipy_build_dir}' |
| 36 | + env['CXX'] += f' -Wl,-l{self.stl_lib_name}' |
| 37 | + return env |
| 38 | + |
| 39 | + |
| 40 | +recipe = ThisRecipe() |
0 commit comments