diff --git a/.circleci/config.yml b/.circleci/config.yml index d7609ffe9..546aee3f5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,6 +16,12 @@ jobs: command: | make lint + - run: + name: dependencies + command: | + # Download BLAS/LAPACK + git clone https://github.com/adrianbg/CLAPACK-WA.git packages/scipy/CLAPACK-WA + - restore_cache: keys: - v1-emsdk-{{ checksum "emsdk/Makefile" }}-v11- diff --git a/Makefile b/Makefile index fa6c762f1..f88030b47 100644 --- a/Makefile +++ b/Makefile @@ -208,6 +208,8 @@ $(LZ4LIB): $(SIX_LIBS): $(CPYTHONLIB) make -C six +$(LAPACK): $(CPYTHONLIB) + emmake make -C packages/scipy/CLAPACK-WA $(CLAPACK): $(CPYTHONLIB) make -C CLAPACK diff --git a/packages/Makefile b/packages/Makefile index bee738225..4c4e03aea 100644 --- a/packages/Makefile +++ b/packages/Makefile @@ -1,9 +1,12 @@ PYODIDE_ROOT=$(abspath ..) include ../Makefile.envs -all: +all: deps ../bin/pyodide buildall . ../build \ --ldflags="$(SIDE_LDFLAGS)" --host=$(HOSTPYTHONROOT) --target=$(TARGETPYTHONROOT) +deps: + # Temporary workaround to install build dependencies + $(HOSTPYTHON) -m pip install Cython Tempita clean: rm -rf ./*/build diff --git a/packages/scipy/meta.yaml b/packages/scipy/meta.yaml index c94a7532f..bc6a4272c 100644 --- a/packages/scipy/meta.yaml +++ b/packages/scipy/meta.yaml @@ -1,13 +1,22 @@ package: name: scipy - version: 1.1.0 + version: 0.17.1 source: - url: https://files.pythonhosted.org/packages/07/76/7e844757b9f3bf5ab9f951ccd3e4a8eed91ab8720b0aac8c2adcc2fdae9f/scipy-1.1.0.tar.gz - sha256: 878352408424dffaa695ffedf2f9f92844e116686923ed9aa8626fc30d32cfd1 + # We can't use the version from PyPi as it includes Cythonized files + # generated with an older Cython that does not support Python 3.7 + # This requires, + # pip install Cython Tempita + # on the host for the build + url: https://github.com/scipy/scipy/archive/v0.17.1.tar.gz + sha256: bf22383d9e2526ffdc53a6c7d3d66dab45a86291ed35d8e281bd1a5d2c34187b + + patches: + - patches/disable_modules_with_blas.patch + - patches/fix-build-gcc5-a80460.patch build: - cflags: -ICLAPACK-WA/F2CLIBS/libf2c/ -Wno-implicit-function-declaration + cflags: -I../../CLAPACK-WA/F2CLIBS/libf2c/ -Wno-implicit-function-declaration cxxflags: requirements: diff --git a/packages/scipy/patches/disable_modules_with_blas.patch b/packages/scipy/patches/disable_modules_with_blas.patch new file mode 100644 index 000000000..874cb0ea0 --- /dev/null +++ b/packages/scipy/patches/disable_modules_with_blas.patch @@ -0,0 +1,338 @@ +diff --git a/scipy/interpolate/setup.py b/scipy/interpolate/setup.py +deleted file mode 100755 +index b42d3345c..000000000 +--- a/scipy/interpolate/setup.py ++++ /dev/null +@@ -1,49 +0,0 @@ +-#!/usr/bin/env python +-from __future__ import division, print_function, absolute_import +- +-from os.path import join +- +- +-def configuration(parent_package='',top_path=None): +- from numpy.distutils.misc_util import Configuration +- from numpy.distutils.system_info import get_info +- +- lapack_opt = get_info('lapack_opt', notfound_action=2) +- +- config = Configuration('interpolate', parent_package, top_path) +- +- fitpack_src = [join('fitpack', '*.f')] +- config.add_library('fitpack', sources=fitpack_src) +- +- config.add_extension('interpnd', +- sources=['interpnd.c']) +- +- config.add_extension('_ppoly', +- sources=['_ppoly.c'], +- **lapack_opt) +- +- config.add_extension('_fitpack', +- sources=['src/_fitpackmodule.c'], +- libraries=['fitpack'], +- depends=(['src/__fitpack.h','src/multipack.h'] +- + fitpack_src) +- ) +- +- config.add_extension('dfitpack', +- sources=['src/fitpack.pyf'], +- libraries=['fitpack'], +- depends=fitpack_src, +- ) +- +- config.add_extension('_interpolate', +- sources=['src/_interpolate.cpp'], +- include_dirs=['src'], +- depends=['src/interpolate.h']) +- +- config.add_data_dir('tests') +- +- return config +- +-if __name__ == '__main__': +- from numpy.distutils.core import setup +- setup(**configuration(top_path='').todict()) +diff --git a/scipy/linalg/setup.py b/scipy/linalg/setup.py +deleted file mode 100755 +index 2c9b9ba22..000000000 +--- a/scipy/linalg/setup.py ++++ /dev/null +@@ -1,173 +0,0 @@ +-#!/usr/bin/env python +-from __future__ import division, print_function, absolute_import +- +-import os +-from os.path import join +- +- +-def configuration(parent_package='', top_path=None): +- from distutils.sysconfig import get_python_inc +- from numpy.distutils.system_info import get_info, NotFoundError, numpy_info +- from numpy.distutils.misc_util import Configuration, get_numpy_include_dirs +- from scipy._build_utils import (get_sgemv_fix, get_g77_abi_wrappers, +- split_fortran_files) +- +- config = Configuration('linalg', parent_package, top_path) +- +- lapack_opt = get_info('lapack_opt') +- +- if not lapack_opt: +- raise NotFoundError('no lapack/blas resources found') +- +- atlas_version = ([v[3:-3] for k, v in lapack_opt.get('define_macros', []) +- if k == 'ATLAS_INFO']+[None])[0] +- if atlas_version: +- print(('ATLAS version: %s' % atlas_version)) +- +- # fblas: +- sources = ['fblas.pyf.src'] +- sources += get_g77_abi_wrappers(lapack_opt) +- sources += get_sgemv_fix(lapack_opt) +- +- config.add_extension('_fblas', +- sources=sources, +- depends=['fblas_l?.pyf.src'], +- extra_info=lapack_opt +- ) +- +- # flapack: +- sources = ['flapack.pyf.src'] +- sources += get_g77_abi_wrappers(lapack_opt) +- dep_pfx = join('src', 'lapack_deprecations') +- deprecated_lapack_routines = [join(dep_pfx, c + 'gegv.f') for c in 'cdsz'] +- sources += deprecated_lapack_routines +- +- config.add_extension('_flapack', +- sources=sources, +- depends=['flapack_user.pyf.src'], +- extra_info=lapack_opt +- ) +- +- if atlas_version is not None: +- # cblas: +- config.add_extension('_cblas', +- sources=['cblas.pyf.src'], +- depends=['cblas.pyf.src', 'cblas_l1.pyf.src'], +- extra_info=lapack_opt +- ) +- +- # clapack: +- config.add_extension('_clapack', +- sources=['clapack.pyf.src'], +- depends=['clapack.pyf.src'], +- extra_info=lapack_opt +- ) +- +- # _flinalg: +- config.add_extension('_flinalg', +- sources=[join('src', 'det.f'), join('src', 'lu.f')], +- extra_info=lapack_opt +- ) +- +- # _interpolative: +- routines_to_split = [ +- 'dfftb1', +- 'dfftf1', +- 'dffti1', +- 'dsint1', +- 'dzfft1', +- 'id_srand', +- 'idd_copyints', +- 'idd_id2svd0', +- 'idd_pairsamps', +- 'idd_permute', +- 'idd_permuter', +- 'idd_random_transf0', +- 'idd_random_transf0_inv', +- 'idd_random_transf_init0', +- 'idd_subselect', +- 'iddp_asvd0', +- 'iddp_rsvd0', +- 'iddr_asvd0', +- 'iddr_rsvd0', +- 'idz_estrank0', +- 'idz_id2svd0', +- 'idz_permute', +- 'idz_permuter', +- 'idz_random_transf0_inv', +- 'idz_random_transf_init0', +- 'idz_random_transf_init00', +- 'idz_realcomp', +- 'idz_realcomplex', +- 'idz_reco', +- 'idz_subselect', +- 'idzp_aid0', +- 'idzp_aid1', +- 'idzp_asvd0', +- 'idzp_rsvd0', +- 'idzr_asvd0', +- 'idzr_reco', +- 'idzr_rsvd0', +- 'zfftb1', +- 'zfftf1', +- 'zffti1', +- ] +- print('Splitting linalg.interpolative Fortran source files') +- dirname = os.path.split(os.path.abspath(__file__))[0] +- fnames = split_fortran_files(join(dirname, 'src', 'id_dist', 'src'), +- routines_to_split) +- fnames = [join('src', 'id_dist', 'src', f) for f in fnames] +- config.add_extension('_interpolative', fnames + ["interpolative.pyf"], +- extra_info=lapack_opt +- ) +- +- # _calc_lwork: +- config.add_extension('_calc_lwork', +- [join('src', 'calc_lwork.f')], +- extra_info=lapack_opt) +- +- # _solve_toeplitz: +- config.add_extension('_solve_toeplitz', +- sources=[('_solve_toeplitz.c')], +- include_dirs=[get_numpy_include_dirs()]) +- +- config.add_data_dir('tests') +- +- # Cython BLAS/LAPACK +- config.add_data_files('cython_blas.pxd') +- config.add_data_files('cython_lapack.pxd') +- +- sources = ['_blas_subroutine_wrappers.f', '_lapack_subroutine_wrappers.f'] +- sources += get_g77_abi_wrappers(lapack_opt) +- sources += get_sgemv_fix(lapack_opt) +- includes = numpy_info().get_include_dirs() + [get_python_inc()] +- config.add_library('fwrappers', sources=sources, include_dirs=includes) +- +- config.add_extension('cython_blas', +- sources=['cython_blas.c'], +- depends=['cython_blas.pyx', 'cython_blas.pxd', +- 'fortran_defs.h', '_blas_subroutines.h'], +- include_dirs=['.'], +- libraries=['fwrappers'], +- extra_info=lapack_opt) +- +- config.add_extension('cython_lapack', +- sources=['cython_lapack.c'], +- depends=['cython_lapack.pyx', 'cython_lapack.pxd', +- 'fortran_defs.h', '_lapack_subroutines.h'], +- include_dirs=['.'], +- libraries=['fwrappers'], +- extra_info=lapack_opt) +- +- config.add_extension('_decomp_update', +- sources=['_decomp_update.c']) +- +- return config +- +- +-if __name__ == '__main__': +- from numpy.distutils.core import setup +- from linalg_version import linalg_version +- +- setup(version=linalg_version, +- **configuration(top_path='').todict()) +diff --git a/scipy/sparse/linalg/eigen/arpack/setup.py b/scipy/sparse/linalg/eigen/arpack/setup.py +deleted file mode 100755 +index a8175a9d5..000000000 +--- a/scipy/sparse/linalg/eigen/arpack/setup.py ++++ /dev/null +@@ -1,44 +0,0 @@ +-#!/usr/bin/env python +-from __future__ import division, print_function, absolute_import +- +-from os.path import join +- +- +-def configuration(parent_package='',top_path=None): +- from numpy.distutils.system_info import get_info, NotFoundError +- from numpy.distutils.misc_util import Configuration +- from scipy._build_utils import get_g77_abi_wrappers, get_sgemv_fix +- +- config = Configuration('arpack',parent_package,top_path) +- +- lapack_opt = get_info('lapack_opt') +- +- if not lapack_opt: +- raise NotFoundError('no lapack/blas resources found') +- +- config = Configuration('arpack', parent_package, top_path) +- +- arpack_sources = [join('ARPACK','SRC', '*.f')] +- arpack_sources.extend([join('ARPACK','UTIL', '*.f')]) +- arpack_sources.extend([join('ARPACK','LAPACK', '*.f')]) +- +- arpack_sources += get_g77_abi_wrappers(lapack_opt) +- +- config.add_library('arpack_scipy', sources=arpack_sources, +- include_dirs=[join('ARPACK', 'SRC')]) +- +- ext_sources = ['arpack.pyf.src'] +- ext_sources += get_sgemv_fix(lapack_opt) +- config.add_extension('_arpack', +- sources=ext_sources, +- libraries=['arpack_scipy'], +- extra_info=lapack_opt, +- depends=arpack_sources, +- ) +- +- config.add_data_dir('tests') +- return config +- +-if __name__ == '__main__': +- from numpy.distutils.core import setup +- setup(**configuration(top_path='').todict()) +diff --git a/scipy/sparse/linalg/isolve/setup.py b/scipy/sparse/linalg/isolve/setup.py +deleted file mode 100755 +index becb9237a..000000000 +--- a/scipy/sparse/linalg/isolve/setup.py ++++ /dev/null +@@ -1,48 +0,0 @@ +-#!/usr/bin/env python +-from __future__ import division, print_function, absolute_import +- +-from os.path import join +- +- +-def configuration(parent_package='',top_path=None): +- from numpy.distutils.system_info import get_info, NotFoundError +- from numpy.distutils.misc_util import Configuration +- from scipy._build_utils import get_g77_abi_wrappers +- +- config = Configuration('isolve',parent_package,top_path) +- +- lapack_opt = get_info('lapack_opt') +- +- if not lapack_opt: +- raise NotFoundError('no lapack/blas resources found') +- +- # iterative methods +- methods = ['BiCGREVCOM.f.src', +- 'BiCGSTABREVCOM.f.src', +- 'CGREVCOM.f.src', +- 'CGSREVCOM.f.src', +-# 'ChebyREVCOM.f.src', +- 'GMRESREVCOM.f.src', +-# 'JacobiREVCOM.f.src', +- 'QMRREVCOM.f.src', +-# 'SORREVCOM.f.src' +- ] +- +- Util = ['STOPTEST2.f.src','getbreak.f.src'] +- sources = Util + methods + ['_iterative.pyf.src'] +- sources = [join('iterative', x) for x in sources] +- sources += get_g77_abi_wrappers(lapack_opt) +- +- config.add_extension('_iterative', +- sources=sources, +- extra_info=lapack_opt) +- +- config.add_data_dir('tests') +- +- return config +- +- +-if __name__ == '__main__': +- from numpy.distutils.core import setup +- +- setup(**configuration(top_path='').todict()) diff --git a/packages/scipy/patches/fix-build-gcc5-a80460.patch b/packages/scipy/patches/fix-build-gcc5-a80460.patch new file mode 100644 index 000000000..d97198c26 --- /dev/null +++ b/packages/scipy/patches/fix-build-gcc5-a80460.patch @@ -0,0 +1,54 @@ +commit a80460f1b45035d34575866e6394107396ac62e2 +Author: Michael Danilov +Date: Thu Apr 20 18:08:39 2017 +0200 + + Fix build with GCC5. + +diff --git a/scipy/odr/odrpack/d_lpkbls.f b/scipy/odr/odrpack/d_lpkbls.f +index 324b7a8a2..1e6624d63 100644 +--- a/scipy/odr/odrpack/d_lpkbls.f ++++ b/scipy/odr/odrpack/d_lpkbls.f +@@ -136,8 +136,8 @@ C***FIRST EXECUTABLE STATEMENT DAXPY + + + IF(N.LE.0.OR.DA.EQ.0.D0) RETURN +- IF (INCX.EQ.INCY) IF(INCX.lt.1) GOTO 5 +- IF (INCX.EQ.INCY) IF(INCX.eq.1) GOTO 20 ++ IF (INCX.EQ.INCY .AND. INCX.lt.1) GOTO 5 ++ IF (INCX.EQ.INCY .AND. INCX.eq.1) GOTO 20 + GOTO 60 + 5 CONTINUE + +@@ -483,8 +483,8 @@ C***FIRST EXECUTABLE STATEMENT DCOPY + + + IF(N.LE.0)RETURN +- IF (INCX.EQ.INCY) IF(INCX.lt.1) GOTO 5 +- IF (INCX.EQ.INCY) IF(INCX.eq.1) GOTO 20 ++ IF (INCX.EQ.INCY .AND. INCX.lt.1) GOTO 5 ++ IF (INCX.EQ.INCY .AND. INCX.eq.1) GOTO 20 + GOTO 60 + 5 CONTINUE + +@@ -589,8 +589,8 @@ C***FIRST EXECUTABLE STATEMENT DDOT + + DDOT = 0.D0 + IF(N.LE.0)RETURN +- IF (INCX.EQ.INCY) IF(INCX.lt.1) GOTO 5 +- IF (INCX.EQ.INCY) IF(INCX.eq.1) GOTO 20 ++ IF (INCX.EQ.INCY .AND. INCX.lt.1) GOTO 5 ++ IF (INCX.EQ.INCY .AND. INCX.eq.1) GOTO 20 + GOTO 60 + 5 CONTINUE + +@@ -1772,8 +1772,8 @@ C***FIRST EXECUTABLE STATEMENT DSWAP + + + IF(N.LE.0)RETURN +- IF (INCX.EQ.INCY) IF(INCX.lt.1) GOTO 5 +- IF (INCX.EQ.INCY) IF(INCX.eq.1) GOTO 20 ++ IF (INCX.EQ.INCY .AND. INCX.lt.1) GOTO 5 ++ IF (INCX.EQ.INCY .AND. INCX.eq.1) GOTO 20 + GOTO 60 + 5 CONTINUE +