diff mbox series

[v1,6/7] package/python-scikitlearn: new package

Message ID 20220816143943.16142-6-guillaume.bressaix@gmail.com
State Changes Requested
Headers show
Series [v1,1/7] package/python-joblib: new package | expand

Commit Message

Guillaume Bres Aug. 16, 2022, 2:39 p.m. UTC
Signed-off-by: Guillaume W. Bres <guillaume.bressaix@gmail.com>
---
python-scikitlearn needs scipy both as build time and runtime dependency
---
 DEVELOPERS                                    |  1 +
 package/Config.in                             |  1 +
 package/python-scikitlearn/Config.in          | 24 +++++++++++++++++++
 .../python-scikitlearn.hash                   |  4 ++++
 .../python-scikitlearn/python-scikitlearn.mk  | 21 ++++++++++++++++
 5 files changed, 51 insertions(+)
 create mode 100644 package/python-scikitlearn/Config.in
 create mode 100644 package/python-scikitlearn/python-scikitlearn.hash
 create mode 100644 package/python-scikitlearn/python-scikitlearn.mk

Comments

Thomas Petazzoni Aug. 17, 2022, 10:54 a.m. UTC | #1
Hello Guillaume,

On Tue, 16 Aug 2022 16:39:42 +0200
"Guillaume W. Bres" <guillaume.bressaix@gmail.com> wrote:

> +PYTHON_SCIKITLEARN_VERSION = 1.1.1
> +PYTHON_SCIKITLEARN_SITE = $(call github,scikit-learn,scikit-learn,$(PYTHON_SCIKITLEARN_VERSION))
> +PYTHON_SCIKITLEARN_LICENSE = BSD-3-Clause
> +PYTHON_SCIKITLEARN_LICENSE_FILES = COPYING
> +PYTHON_SCIKITLEARN_SETUP_TYPE = setuptools
> +PYTHON_SCIKITLEARN_DEPENDENCIES = \
> +	host-python-cython \
> +	host-python-scipy \

Are you sure it needs host-python-scipy? What error do you get if you
don't have host-python-scipy?

From a quick glance at scikitlearn's setup.py script (at
https://github.com/scikit-learn/scikit-learn/blob/main/setup.py#L303),
I have the impression it only tries to import numpy and scipy at
build-time to verify that their version is correct.

Though it's true than then it does import numpy/scipy stuff:

        # These commands require the setup from numpy.distutils because they
        # may use numpy.distutils compiler classes.
        from numpy.distutils.core import setup

        # Monkeypatches CCompiler.spawn to prevent random wheel build errors on Windows
        # The build errors on Windows was because msvccompiler spawn was not threadsafe
        # This fixed can be removed when we build with numpy >= 1.22.2 on Windows.
        # https://github.com/pypa/distutils/issues/5
        # https://github.com/scikit-learn/scikit-learn/issues/22310
        # https://github.com/numpy/numpy/pull/20640
        from numpy.distutils.ccompiler import replace_method
        from distutils.ccompiler import CCompiler
        from sklearn.externals._numpy_compiler_patch import CCompiler_spawn

But the below part is to avoid build errors on Windows. Can you try to
patch this out?

> +	python-joblib \
> +	python-threadpoolctl

Are you sure these are needed at build-time? You marked them as
run-time dependencies in your Config.in file.

Thomas
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 21a35cf9d1..049f9fe186 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1194,6 +1194,7 @@  F:	package/python-gast/
 F:	package/python-joblib/
 F:	package/python-pybind/
 F:	package/python-pythran/
+F:	package/python-scikitlearn/
 F:	package/python-scipy/
 F:	package/python-threadpoolctl/
 F:	package/reaver/
diff --git a/package/Config.in b/package/Config.in
index 876d7309eb..a2ee4f73e5 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1236,6 +1236,7 @@  menu "External python modules"
 	source "package/python-scandir/Config.in"
 	source "package/python-scapy/Config.in"
 	source "package/python-schedule/Config.in"
+	source "package/python-scikitlearn/Config.in"
 	source "package/python-scipy/Config.in"
 	source "package/python-sdnotify/Config.in"
 	source "package/python-secretstorage/Config.in"
diff --git a/package/python-scikitlearn/Config.in b/package/python-scikitlearn/Config.in
new file mode 100644
index 0000000000..1fabdf92fe
--- /dev/null
+++ b/package/python-scikitlearn/Config.in
@@ -0,0 +1,24 @@ 
+config BR2_PACKAGE_PYTHON_SCIKITLEARN
+	bool "python-scikitlearn"
+	depends on BR2_TOOLCHAIN_HAS_FORTRAN # python-scipy
+	depends on BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTS # python-scipy
+	depends on BR2_PACKAGE_PYTHON_NUMPY_ARCH_SUPPORTS # python-numpy
+	depends on BR2_TOOLCHAIN_USES_GLIBC || BR2_TOOLCHAIN_USES_MUSL # python-numpy
+	select BR2_PACKAGE_PYTHON_NUMPY
+	select BR2_PACKAGE_PYTHON_SCIPY # runtime
+	select BR2_PACKAGE_PYTHON_JOBLIB # runtime
+	select BR2_PACKAGE_PYTHON_THREADPOOLCTL # runtime
+	help
+	  Scikit-Learn is a Python module for machine learning
+	  built on top of Python-Scipy.
+
+	  https://scikit-learn.org/
+
+comment "python-scikitlearn needs a toolchain with fortran"
+	  depends on !BR2_TOOLCHAIN_HAS_FORTRAN
+
+comment "python-scikitlearn needs lib openblas"
+	  depends on !BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTS
+
+comment "python-scikitlearn needs python-numpy"
+	depends on !BR2_PACKAGE_PYTHON_NUMPY_ARCH_SUPPORTS
diff --git a/package/python-scikitlearn/python-scikitlearn.hash b/package/python-scikitlearn/python-scikitlearn.hash
new file mode 100644
index 0000000000..e8c712761a
--- /dev/null
+++ b/package/python-scikitlearn/python-scikitlearn.hash
@@ -0,0 +1,4 @@ 
+# Locally calculated
+sha256  568e621b9e1479b9ab952a9241db5af2ba3ab4f69d44b8aba3dd7648825e8e5a  python-scikitlearn-1.1.1.tar.gz
+# License files, locally calculated
+sha256  bc2e5553b31344779335ddadac8de6f9d12da6f4ce46e22a8e2820951a1d5458  COPYING
diff --git a/package/python-scikitlearn/python-scikitlearn.mk b/package/python-scikitlearn/python-scikitlearn.mk
new file mode 100644
index 0000000000..00cdcd9ac7
--- /dev/null
+++ b/package/python-scikitlearn/python-scikitlearn.mk
@@ -0,0 +1,21 @@ 
+################################################################################
+#
+# python-scikitlearn
+#
+################################################################################
+
+PYTHON_SCIKITLEARN_VERSION = 1.1.1
+PYTHON_SCIKITLEARN_SITE = $(call github,scikit-learn,scikit-learn,$(PYTHON_SCIKITLEARN_VERSION))
+PYTHON_SCIKITLEARN_LICENSE = BSD-3-Clause
+PYTHON_SCIKITLEARN_LICENSE_FILES = COPYING
+PYTHON_SCIKITLEARN_SETUP_TYPE = setuptools
+PYTHON_SCIKITLEARN_DEPENDENCIES = \
+	host-python-cython \
+	host-python-scipy \
+	python-joblib \
+	python-threadpoolctl
+
+# disable test execution when cross compiling
+PYTHON_SCIKITLEARN_ENV = PYTHON_CROSSENV=1
+
+$(eval $(python-package))