Skip to content

Commit a245806

Browse files
committed
add scikit-learn recipe and dependencies
1 parent 4ecaa5f commit a245806

File tree

8 files changed

+159
-1
lines changed

8 files changed

+159
-1
lines changed

ci/constants.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class TargetPython(Enum):
2727
'sympy',
2828
'vlc',
2929
# need extra gfortran NDK system add-on
30-
'lapack', 'scipy',
30+
'lapack', 'scipy', 'scikit-learn',
3131
# Outdated and there's a chance that is now useless.
3232
'zope_interface',
3333
# Requires zope_interface, which is broken.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from pythonforandroid.recipe import PythonRecipe
2+
3+
4+
class ThisRecipe(PythonRecipe):
5+
org = 'joblib'
6+
name = 'joblib'
7+
version = '0.17.0'
8+
url = f'https://github.com/{org}/{name}/archive/{version}.zip'
9+
depends = ['setuptools']
10+
call_hostpython_via_targetpython = False
11+
patches = ['multiprocessing.patch']
12+
13+
14+
recipe = ThisRecipe()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
diff --git a/joblib/externals/loky/backend/__init__.py b/joblib/externals/loky/backend/__init__.py
2+
index a65ce0e..9efdb46 100644
3+
--- a/joblib/externals/loky/backend/__init__.py
4+
+++ b/joblib/externals/loky/backend/__init__.py
5+
@@ -10,7 +10,7 @@ if sys.version_info > (3, 4):
6+
return name
7+
8+
# monkey patch the name creation for multiprocessing
9+
- from multiprocessing import synchronize
10+
- synchronize.SemLock._make_name = staticmethod(_make_name)
11+
+ #from multiprocessing import synchronize
12+
+ #synchronize.SemLock._make_name = staticmethod(_make_name)
13+
14+
__all__ = ["get_context"]
15+
diff --git a/joblib/externals/loky/backend/queues.py b/joblib/externals/loky/backend/queues.py
16+
index 62735db..156e235 100644
17+
--- a/joblib/externals/loky/backend/queues.py
18+
+++ b/joblib/externals/loky/backend/queues.py
19+
@@ -9,6 +9,8 @@
20+
# * Add some custom reducers for the Queues/SimpleQueue to tweak the
21+
# pickling process. (overload Queue._feed/SimpleQueue.put)
22+
#
23+
+from queue import Queue, SimpleQueue, Full
24+
+'''
25+
import os
26+
import sys
27+
import errno
28+
@@ -245,3 +247,4 @@ class SimpleQueue(mp_SimpleQueue):
29+
else:
30+
with self._wlock:
31+
self._writer.send_bytes(obj)
32+
+'''
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
diff --git a/setup.py b/setup.py
2+
index 90162b6..946af48 100755
3+
--- a/setup.py
4+
+++ b/setup.py
5+
@@ -291,7 +291,7 @@ def setup_package():
6+
7+
check_package_status('numpy', NUMPY_MIN_VERSION)
8+
9+
- check_package_status('scipy', SCIPY_MIN_VERSION)
10+
+ #check_package_status('scipy', SCIPY_MIN_VERSION)
11+
12+
from numpy.distutils.core import setup
13+
14+
diff --git a/sklearn/_build_utils/pre_build_helpers.py b/sklearn/_build_utils/pre_build_helpers.py
15+
index bc3d832..fe1819e 100644
16+
--- a/sklearn/_build_utils/pre_build_helpers.py
17+
+++ b/sklearn/_build_utils/pre_build_helpers.py
18+
@@ -48,8 +48,10 @@ def compile_test_program(code, extra_preargs=[], extra_postargs=[]):
19+
20+
# Run test program
21+
# will raise a CalledProcessError if return code was non-zero
22+
- output = subprocess.check_output('./test_program')
23+
- output = output.decode(sys.stdout.encoding or 'utf-8').splitlines()
24+
+ assert os.path.exists('./test_program')
25+
+ output = ['nthreads=4'] * 4
26+
+ #output = subprocess.check_output('./test_program')
27+
+ #output = output.decode(sys.stdout.encoding or 'utf-8').splitlines()
28+
except Exception:
29+
raise
30+
finally:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from pythonforandroid.recipe import PythonRecipe
2+
3+
4+
class ThisRecipe(PythonRecipe):
5+
org = 'joblib'
6+
name = 'threadpoolctl'
7+
version = '2.1.0'
8+
url = f'https://github.com/{org}/{name}/archive/{version}.zip'
9+
depends = ['setuptools']
10+
call_hostpython_via_targetpython = False
11+
patches = ['docstring.patch', 'setuptools.patch']
12+
13+
14+
recipe = ThisRecipe()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/threadpoolctl.py b/threadpoolctl.py
2+
index b94d7a1..faf7a44 100644
3+
--- a/threadpoolctl.py
4+
+++ b/threadpoolctl.py
5+
@@ -98,7 +98,7 @@ _ALL_OPENMP_LIBRARIES = list(
6+
7+
def _format_docstring(*args, **kwargs):
8+
def decorator(o):
9+
- o.__doc__ = o.__doc__.format(*args, **kwargs)
10+
+ #o.__doc__ = o.__doc__.format(*args, **kwargs)
11+
return o
12+
13+
return decorator
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/setup.py b/setup.py
2+
new file mode 100755
3+
index 0000000..b18d2fd
4+
--- /dev/null
5+
+++ b/setup.py
6+
@@ -0,0 +1,9 @@
7+
+from setuptools import setup
8+
+import threadpoolctl
9+
+
10+
+if __name__ == '__main__':
11+
+ setup(name='threadpoolctl',
12+
+ version=threadpoolctl.__version__,
13+
+ py_modules = ['threadpoolctl'],
14+
+ python_requires='>=3.6',
15+
+ )

0 commit comments

Comments
 (0)