diff mbox

[v2,05/24] python-numpy: new package

Message ID 1398208556-4195-6-git-send-email-s.martin49@gmail.com
State Accepted
Headers show

Commit Message

Samuel Martin April 22, 2014, 11:15 p.m. UTC
This patch add NumPy package for python.

Since Fortran support has been deprecated in Buildroot since the 2013.11
release, and because most of the external toolchains do not provide a
Fortran compiler, it is necessary to explicity disable Fortran compiler
to avoid catching the one from the host system if any.

We also need to fill a site.cfg file to tell NumPy build-system where
it should looking for BLAS and LAPACK libraries.

Some packages may include headers provided by python-numpy package.
Thus, python-numpy needs to be installed in the sysroot; so add and
enable its install-staging command.

Signed-off-by: Samuel Martin <s.martin49@gmail.com>

---
changes v1 -> v2:
- rebase
- automatic support of blas/lapack when clapack is enabled (ThomasP)
- split blas/lapack support in its own cset (ThomasP)
- merge python-numpy staging install cset within the python-numpy
  package integration (ThomasP)
---
 package/Config.in                    |  1 +
 package/python-numpy/Config.in       |  8 +++++++
 package/python-numpy/python-numpy.mk | 41 ++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 package/python-numpy/Config.in
 create mode 100644 package/python-numpy/python-numpy.mk

Comments

Yann E. MORIN May 3, 2014, 5:40 p.m. UTC | #1
Samuel, All,

On 2014-04-23 01:15 +0200, Samuel Martin spake thusly:
> This patch add NumPy package for python.
> 
> Since Fortran support has been deprecated in Buildroot since the 2013.11
> release, and because most of the external toolchains do not provide a
> Fortran compiler, it is necessary to explicity disable Fortran compiler
> to avoid catching the one from the host system if any.
> 
> We also need to fill a site.cfg file to tell NumPy build-system where
> it should looking for BLAS and LAPACK libraries.
> 
> Some packages may include headers provided by python-numpy package.
> Thus, python-numpy needs to be installed in the sysroot; so add and
> enable its install-staging command.
> 
> Signed-off-by: Samuel Martin <s.martin49@gmail.com>

[--SNIP--]
> diff --git a/package/python-numpy/Config.in b/package/python-numpy/Config.in
> new file mode 100644
> index 0000000..c80e5c4
> --- /dev/null
> +++ b/package/python-numpy/Config.in
> @@ -0,0 +1,8 @@
> +config BR2_PACKAGE_PYTHON_NUMPY
> +	bool "python-numpy"
> +	help
> +	  NumPy is the fundamental package for scientific computing with Python.
> +
> +	  Note that NumPy needs fenv.h fully supported by the C-library.

So, maybe we should:
    depends on uClibc && x86 || glibc

uClibc only really supports fenv.h for x86.

> +	  http://www.numpy.org/
> diff --git a/package/python-numpy/python-numpy.mk b/package/python-numpy/python-numpy.mk
> new file mode 100644
> index 0000000..e7c91c4
> --- /dev/null
> +++ b/package/python-numpy/python-numpy.mk
> @@ -0,0 +1,41 @@
> +################################################################################
> +#
> +# python-numpy
> +#
> +################################################################################
> +
> +PYTHON_NUMPY_VERSION = 1.8.0

We've got 1.8.1 out now. Maybe use it?

> +PYTHON_NUMPY_SOURCE = numpy-$(PYTHON_NUMPY_VERSION).tar.gz
> +PYTHON_NUMPY_SITE = http://downloads.sourceforge.net/numpy
> +PYTHON_NUMPY_LICENSE = BSD-3c
> +PYTHON_NUMPY_LICENSE_FILES = LICENSE.txt
> +PYTHON_NUMPY_SETUP_TYPE = distutils
> +
> +PYTHON_NUMPY_BUILD_OPT = --fcompiler=None
> +
> +define PYTHON_NUMPY_CONFIGURE_CMDS
> +	-rm -f $(@D)/site.cfg
> +	echo "[DEFAULT]" >> $(@D)/site.cfg
> +	echo "library_dirs = $(STAGING_DIR)/usr/lib" >> $(@D)/site.cfg
> +	echo "include_dirs = $(STAGING_DIR)/usr/include" >> $(@D)/site.cfg
> +	echo "libraries =" >> $(@D)/site.cfg
> +endef
> +
> +# Some package may include few headers from NumPy, so let's install it in the
> +# staging area.
> +PYTHON_NUMPY_INSTALL_STAGING = YES
> +
> +# This install staging commands is an adjusted and simplified version of the
> +# install target commands vampirized from the python-package infrastructure.

Why not add it to the python-infra, then?

Regards,
Yann E. MORIN.

> +# Note that the append '--prefix=...' parameter overrides the one set by the
> +# python-package infrastructure in the PYTHON_NUMPY_INSTALL_OPT variable.
> +define PYTHON_NUMPY_INSTALL_STAGING_CMDS
> +	(cd $(PYTHON_NUMPY_BUILDDIR)/; \
> +		$(PYTHON_NUMPY_BASE_ENV) $(PYTHON_NUMPY_ENV) \
> +		$(HOST_DIR)/usr/bin/python setup.py install \
> +		$(PYTHON_NUMPY_BASE_INSTALL_OPT) \
> +		$(PYTHON_NUMPY_INSTALL_OPT) --prefix=$(STAGING_DIR)/usr)
> +endef
> +
> +$(eval $(python-package))
> -- 
> 1.9.2
> 
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Thomas Petazzoni July 16, 2014, 8:30 p.m. UTC | #2
Dear Samuel Martin,

On Wed, 23 Apr 2014 01:15:37 +0200, Samuel Martin wrote:
> This patch add NumPy package for python.
> 
> Since Fortran support has been deprecated in Buildroot since the 2013.11
> release, and because most of the external toolchains do not provide a
> Fortran compiler, it is necessary to explicity disable Fortran compiler
> to avoid catching the one from the host system if any.
> 
> We also need to fill a site.cfg file to tell NumPy build-system where
> it should looking for BLAS and LAPACK libraries.
> 
> Some packages may include headers provided by python-numpy package.
> Thus, python-numpy needs to be installed in the sysroot; so add and
> enable its install-staging command.
> 
> Signed-off-by: Samuel Martin <s.martin49@gmail.com>

Thanks, applied, after changing the patch to use the python package
infrastructure for staging installation, and adding the necessary
dependencies to take into account the fenv.h requirement.

Thanks,

Thomas
diff mbox

Patch

diff --git a/package/Config.in b/package/Config.in
index 9c91844..7d8ca95 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -455,6 +455,7 @@  source "package/python-meld3/Config.in"
 source "package/python-msgpack/Config.in"
 source "package/python-netifaces/Config.in"
 source "package/python-nfc/Config.in"
+source "package/python-numpy/Config.in"
 source "package/python-posix-ipc/Config.in"
 source "package/python-protobuf/Config.in"
 source "package/python-pyasn/Config.in"
diff --git a/package/python-numpy/Config.in b/package/python-numpy/Config.in
new file mode 100644
index 0000000..c80e5c4
--- /dev/null
+++ b/package/python-numpy/Config.in
@@ -0,0 +1,8 @@ 
+config BR2_PACKAGE_PYTHON_NUMPY
+	bool "python-numpy"
+	help
+	  NumPy is the fundamental package for scientific computing with Python.
+
+	  Note that NumPy needs fenv.h fully supported by the C-library.
+
+	  http://www.numpy.org/
diff --git a/package/python-numpy/python-numpy.mk b/package/python-numpy/python-numpy.mk
new file mode 100644
index 0000000..e7c91c4
--- /dev/null
+++ b/package/python-numpy/python-numpy.mk
@@ -0,0 +1,41 @@ 
+################################################################################
+#
+# python-numpy
+#
+################################################################################
+
+PYTHON_NUMPY_VERSION = 1.8.0
+PYTHON_NUMPY_SOURCE = numpy-$(PYTHON_NUMPY_VERSION).tar.gz
+PYTHON_NUMPY_SITE = http://downloads.sourceforge.net/numpy
+PYTHON_NUMPY_LICENSE = BSD-3c
+PYTHON_NUMPY_LICENSE_FILES = LICENSE.txt
+PYTHON_NUMPY_SETUP_TYPE = distutils
+
+PYTHON_NUMPY_BUILD_OPT = --fcompiler=None
+
+define PYTHON_NUMPY_CONFIGURE_CMDS
+	-rm -f $(@D)/site.cfg
+	echo "[DEFAULT]" >> $(@D)/site.cfg
+	echo "library_dirs = $(STAGING_DIR)/usr/lib" >> $(@D)/site.cfg
+	echo "include_dirs = $(STAGING_DIR)/usr/include" >> $(@D)/site.cfg
+	echo "libraries =" >> $(@D)/site.cfg
+endef
+
+# Some package may include few headers from NumPy, so let's install it in the
+# staging area.
+PYTHON_NUMPY_INSTALL_STAGING = YES
+
+# This install staging commands is an adjusted and simplified version of the
+# install target commands vampirized from the python-package infrastructure.
+#
+# Note that the append '--prefix=...' parameter overrides the one set by the
+# python-package infrastructure in the PYTHON_NUMPY_INSTALL_OPT variable.
+define PYTHON_NUMPY_INSTALL_STAGING_CMDS
+	(cd $(PYTHON_NUMPY_BUILDDIR)/; \
+		$(PYTHON_NUMPY_BASE_ENV) $(PYTHON_NUMPY_ENV) \
+		$(HOST_DIR)/usr/bin/python setup.py install \
+		$(PYTHON_NUMPY_BASE_INSTALL_OPT) \
+		$(PYTHON_NUMPY_INSTALL_OPT) --prefix=$(STAGING_DIR)/usr)
+endef
+
+$(eval $(python-package))