diff mbox series

[RFC,1/1] package/python-scipy: bump version to 1.9.0

Message ID 20220803093754.19637-1-guillaume.bressaix@gmail.com
State RFC
Headers show
Series [RFC,1/1] package/python-scipy: bump version to 1.9.0 | expand

Commit Message

Guillaume Bres Aug. 3, 2022, 9:37 a.m. UTC
Scipy is moving to a Meson build infrastructure.

Signed-off-by: Guillaume W. Bres <guillaume.bressaix@gmail.com>
---
I'm expecting meson to simplify things a lot for us.
But we're not there yet..

I'm referring to this page, which is the only one available at the moment,
on how to build the package with the new infra

https://scipy.github.io/devdocs/dev/contributor/meson.html

My current setup has pretty much everything figured out, but meson
does not locate the fortran cross-compiler. Could anyone help me?

output/build/python-scipy-v1.9.0/meson.build:41:0: ERROR: 'fortran' compiler binary not defined in cross or native file

cat output/build/python-scipy-v1.9.0/build/cross-compilation.conf
[binaries]
c = '/buildroot/output/host/bin/arm-buildroot-linux-gnueabihf-gcc'
cpp = '/buildroot/output/host/bin/arm-buildroot-linux-gnueabihf-g++'
ar = '/buildroot/output/host/bin/arm-buildroot-linux-gnueabihf-gcc-ar'
strip = '/buildroot/output/host/bin/arm-buildroot-linux-gnueabihf-strip'
cmake = '/usr/bin/cmake'
pkgconfig = '/buildroot/output/host/bin/pkgconf'
g-ir-compiler = '/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/bin/g-ir-compiler'
g-ir-scanner = '/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/bin/g-ir-scanner'

[built-in options]
c_args = ['-D_LARGEFILE_SOURCE', '-D_LARGEFILE64_SOURCE', '-D_FILE_OFFSET_BITS=64', '-Os', '-g0', '-D_FORTIFY_SOURCE=1']
c_link_args = []
cpp_args = ['-D_LARGEFILE_SOURCE', '-D_LARGEFILE64_SOURCE', '-D_FILE_OFFSET_BITS=64', '-Os', '-g0', '-D_FORTIFY_SOURCE=1']
cpp_link_args = []
wrap_mode = 'nodownload'
cmake_prefix_path = '/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/cmake'

[properties]
needs_exe_wrapper = true
sys_root = '/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot'
pkg_config_libdir = '/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/pkgconfig:/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/share/pkgconfig'
pkg_config_static = 'false'
cmake_toolchain_file = '/buildroot/output/host/share/buildroot/toolchainfile.cmake'
cmake_defaults = false

[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'cortex-a7'
endian = 'little

With my current setup, I am able to
- fetch the git submoule like in the 1st tutorial
- initiate the meson configure step
- meson figures out pretty much everything correctly (gcc, etc..)
- meson fails to locate "fortran" the gfortran cross-compiler.
I have tried PYTHON_SCIPY_NINJA_ENV and PYTHON_SCIPY_CONF_ENV,
but none of these have any effect.

See this page for meson benefits, dependencies and general discussions
https://labs.quansight.org/blog/2021/07/moving-scipy-to-meson
---
 package/python-scipy/python-scipy.hash |  2 +-
 package/python-scipy/python-scipy.mk   | 35 ++++++++------------------
 2 files changed, 12 insertions(+), 25 deletions(-)

Comments

Nicolas Cavallari Aug. 3, 2022, 2:55 p.m. UTC | #1
On 03/08/2022 11:37, Guillaume W. Bres wrote:
> Scipy is moving to a Meson build infrastructure.
> 
> Signed-off-by: Guillaume W. Bres <guillaume.bressaix@gmail.com>
> ---
> I'm expecting meson to simplify things a lot for us.
> But we're not there yet..
> 
> I'm referring to this page, which is the only one available at the moment,
> on how to build the package with the new infra
> 
> https://scipy.github.io/devdocs/dev/contributor/meson.html
> 
> My current setup has pretty much everything figured out, but meson
> does not locate the fortran cross-compiler. Could anyone help me?
> 
> output/build/python-scipy-v1.9.0/meson.build:41:0: ERROR: 'fortran' compiler binary not defined in cross or native file
 >
> [...]
> 
> With my current setup, I am able to
> - fetch the git submoule like in the 1st tutorial
> - initiate the meson configure step
> - meson figures out pretty much everything correctly (gcc, etc..)
> - meson fails to locate "fortran" the gfortran cross-compiler.
> I have tried PYTHON_SCIPY_NINJA_ENV and PYTHON_SCIPY_CONF_ENV,
> but none of these have any effect.

The correct solution would probably be to add proper fortran support to
support/misc/cross-compilation.conf.in and package/pkg-meson.mk.

Alternatively, peeking at the meson source code (mesonbuild/env*.py), 
the environment variable is probably called FC.

Try:

PYTHON_SCIPY_CONF_ENV += FC=$(TARGET_FC)
Thomas Petazzoni Aug. 3, 2022, 4:29 p.m. UTC | #2
Hello,

On Wed,  3 Aug 2022 11:37:54 +0200
"Guillaume W. Bres" <guillaume.bressaix@gmail.com> wrote:

> My current setup has pretty much everything figured out, but meson
> does not locate the fortran cross-compiler. Could anyone help me?
> 
> output/build/python-scipy-v1.9.0/meson.build:41:0: ERROR: 'fortran' compiler binary not defined in cross or native file

Try this:

diff --git a/package/pkg-meson.mk b/package/pkg-meson.mk
index 156b005fdd..a9bbb130a0 100644
--- a/package/pkg-meson.mk
+++ b/package/pkg-meson.mk
@@ -76,6 +76,7 @@ define PKG_MESON_CROSSCONFIG_SED
         -e "s%@TARGET_CC@%$(TARGET_CC)%g" \
         -e "s%@TARGET_CXX@%$(TARGET_CXX)%g" \
         -e "s%@TARGET_AR@%$(TARGET_AR)%g" \
+        -e "s%@TARGET_FC@%$(TARGET_FC)%g" \
         -e "s%@TARGET_STRIP@%$(TARGET_STRIP)%g" \
         -e "s%@TARGET_ARCH@%$(PKG_MESON_TARGET_CPU_FAMILY)%g" \
         -e "s%@TARGET_CPU@%$(GCC_TARGET_CPU)%g" \
@@ -83,6 +84,7 @@ define PKG_MESON_CROSSCONFIG_SED
         -e "s%@TARGET_CFLAGS@%$(call make-sq-comma-list,$($(strip $(1))))%g" \
         -e "s%@TARGET_LDFLAGS@%$(call make-sq-comma-list,$($(strip $(3))))%g" \
         -e "s%@TARGET_CXXFLAGS@%$(call make-sq-comma-list,$($(strip $(2))))%g" \
+        -e "s%@TARGET_FCFLAGS@%$(call make-sq-comma-list,$($(strip $(2))))%g" \
         -e "s%@BR2_CMAKE@%$(BR2_CMAKE)%g" \
         -e "s%@PKGCONF_HOST_BINARY@%$(HOST_DIR)/bin/pkgconf%g" \
         -e "s%@HOST_DIR@%$(HOST_DIR)%g" \
diff --git a/support/misc/cross-compilation.conf.in b/support/misc/cross-compilation.conf.in
index 235e5a8495..7053df472b 100644
--- a/support/misc/cross-compilation.conf.in
+++ b/support/misc/cross-compilation.conf.in
@@ -9,6 +9,7 @@ cpp = '@TARGET_CXX@'
 ar = '@TARGET_AR@'
 strip = '@TARGET_STRIP@'
 cmake = '@BR2_CMAKE@'
+fortran = '@TARGET_FC@'
 pkgconfig = '@PKGCONF_HOST_BINARY@'
 g-ir-compiler = '@STAGING_DIR@/usr/bin/g-ir-compiler'
 g-ir-scanner = '@STAGING_DIR@/usr/bin/g-ir-scanner'
@@ -18,6 +19,8 @@ c_args = [@TARGET_CFLAGS@]
 c_link_args = [@TARGET_LDFLAGS@]
 cpp_args = [@TARGET_CXXFLAGS@]
 cpp_link_args = [@TARGET_LDFLAGS@]
+fortran_args = [@TARGET_FCFLAGS@]
+fortran_link_args = [@TARGET_LDFLAGS@]
 wrap_mode = 'nodownload'
 cmake_prefix_path = '@STAGING_DIR@/usr/lib/cmake'
 
It solves the fortran not found issue, and it now finds the Fortran
compiler:

Fortran compiler for the host machine: /home/thomas/buildroot/buildroot/output/host/bin/aarch64-linux-gfortran (gcc 10.3.0 "GNU Fortran (Buildroot toolchains.bootlin.com-2021.11-1) 10.3.0")
Fortran linker for the host machine: /home/thomas/buildroot/buildroot/output/host/bin/aarch64-linux-gfortran ld.bfd 2.36.1

However, it still fails later with:

output/build/python-scipy-v1.9.0/scipy/meson.build:70:0: ERROR: Include dir /home/thomas/buildroot/buildroot/output/host/aarch64-buildroot-linux-gnu/include does not exist.

An error that I have not investigated.

> -PYTHON_SCIPY_VERSION = 1.8.1
> -PYTHON_SCIPY_SOURCE = scipy-$(PYTHON_SCIPY_VERSION).tar.xz
> -PYTHON_SCIPY_SITE = https://github.com/scipy/scipy/releases/download/v$(PYTHON_SCIPY_VERSION)
> +PYTHON_SCIPY_VERSION = v1.9.0
> +PYTHON_SCIPY_SITE_METHOD = git
> +PYTHON_SCIPY_SITE = https://github.com/scipy/scipy.git
> +PYTHON_SCIPY_GIT_SUBMODULES = YES

Why not keep the tarball download? They have a tarball of the 1.9.0
release at
https://github.com/scipy/scipy/releases/download/v1.9.0/scipy-1.9.0.tar.gz

Thanks!

Thomas
diff mbox series

Patch

diff --git a/package/python-scipy/python-scipy.hash b/package/python-scipy/python-scipy.hash
index 0274679c43..704581639f 100644
--- a/package/python-scipy/python-scipy.hash
+++ b/package/python-scipy/python-scipy.hash
@@ -1,5 +1,5 @@ 
 # Locally generated
-sha256  0140dd24d14ce194fdb3df496c2190f0896ca84ac98bf5d69c3b3fb7bde1a1e9  scipy-1.8.1.tar.xz
+sha256  6d06380a5e93e254de693d763cd7c1f888b217a78f39cad438769aa353ded8a9  python-scipy-v1.9.0-br1.tar.gz
 sha256  96599f8ec69a2cc609265eed13fc75090aacb28742260e55ce623788a33da19c  LICENSE.txt
 sha256  37e64a498894ac7c3b070023e3689e954a8ecf8a23b90968d09a455f1b4f7b35  scipy/linalg/src/lapack_deprecations/LICENSE
 sha256  606209a000716c5f66e33e180ce08434b96ed17db4975ab9723c6b5fbcc89609  scipy/ndimage/LICENSE.txt
diff --git a/package/python-scipy/python-scipy.mk b/package/python-scipy/python-scipy.mk
index b5006a2e15..810f58482f 100644
--- a/package/python-scipy/python-scipy.mk
+++ b/package/python-scipy/python-scipy.mk
@@ -4,9 +4,10 @@ 
 #
 ################################################################################
 
-PYTHON_SCIPY_VERSION = 1.8.1
-PYTHON_SCIPY_SOURCE = scipy-$(PYTHON_SCIPY_VERSION).tar.xz
-PYTHON_SCIPY_SITE = https://github.com/scipy/scipy/releases/download/v$(PYTHON_SCIPY_VERSION)
+PYTHON_SCIPY_VERSION = v1.9.0
+PYTHON_SCIPY_SITE_METHOD = git
+PYTHON_SCIPY_SITE = https://github.com/scipy/scipy.git
+PYTHON_SCIPY_GIT_SUBMODULES = YES
 PYTHON_SCIPY_LICENSE = \
 	BSD-3-Clause, \
 	BSD-2-Clause, \
@@ -23,6 +24,7 @@  PYTHON_SCIPY_LICENSE_FILES = \
 	scipy/sparse/linalg/_eigen/arpack/ARPACK/COPYING \
 	scipy/spatial/qhull_src/COPYING.txt
 PYTHON_SCIPY_DEPENDENCIES += \
+	host-pkgconf \
 	host-python-numpy \
 	host-python-pythran \
 	zlib \
@@ -31,26 +33,11 @@  PYTHON_SCIPY_DEPENDENCIES += \
 	python-pybind
 PYTHON_SCIPY_INSTALL_STAGING = YES
 
-PYTHON_SCIPY_SETUP_TYPE = setuptools
-PYTHON_SCIPY_BUILD_OPTS = config_fc --fcompiler=gnu95
+PYTHON_SCIPY_CONF_ENV += \
+	PYTHONPATH=$(PYTHON3_PATH) \
+	fortran="$(TARGET_FC)"
 
-PYTHON_SCIPY_LDFLAGS = $(TARGET_LDFLAGS) -shared \
-	-L$(PYTHON3_PATH)/site-packages/numpy/core/lib
-# -lnpyrandom localization
-PYTHON_SCIPY_LDFLAGS += \
-	-L$(STAGING_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages/numpy/random/lib
+PYTHON_SCIPY_CONF_OPTS = \
+	-Dlapack=lapack
 
-PYTHON_SCIPY_ENV = \
-	F90=$(TARGET_FC) \
-	LDFLAGS="$(PYTHON_SCIPY_LDFLAGS)"
-
-# Provide system configuration options to numpy distutils extensions, telling
-# to find all include files and libraries in staging directory.
-define PYTHON_SCIPY_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
-endef
-
-$(eval $(python-package))
+$(eval $(meson-package))