From 5309d21371297ae805300275b0fac456b860d65e Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 3 Jan 2022 14:07:13 -0800 Subject: [PATCH] Update to Scipy 1.7.3 (#2065) --- Makefile.envs | 1 + docs/project/changelog.md | 12 +- packages/CLAPACK/meta.yaml | 8 +- packages/scikit-learn/meta.yaml | 8 +- ...n_blas.pyx-with-include-path-pointin.patch | 33 + packages/scikit-learn/test_scikit-learn.py | 60 +- packages/scipy/info.md | 95 ++ packages/scipy/meta.yaml | 141 ++- .../add-lapack_extras-to-flapack.patch | 25 + .../scipy/patches/add-missing-extern.patch | 12 - ...t-xerrwv-message-arg-from-int-to-str.patch | 30 + .../patches/disable-blas-detection.patch | 24 + .../patches/disable_scipy_stats_mvn.patch | 39 - packages/scipy/patches/fix-blas.patch | 89 -- .../scipy/patches/fix-build-gcc5-a80460.patch | 54 - .../patches/fix-fortran-files-minpack.patch | 253 ++++ ...implicit-cast-args-from-newer-lapack.patch | 317 +++++ .../scipy/patches/fix-typo-flapack-pyf.patch | 20 - packages/scipy/patches/force_malloc.patch | 94 -- packages/scipy/patches/gemm_-no-const.patch | 87 ++ .../patches/make-int-return-values.patch | 1121 +++-------------- .../remove-cuncsd-dorcsd-sorcsd-zuncsd.patch | 35 + ...emove-mvnun-not-fortran-77-compliant.patch | 199 +++ .../patches/rename-_page_trend_test.patch | 34 + .../sasum-returns-double-not-float.patch | 25 + .../patches/skip-fortran-fails-to-link.patch | 156 +-- .../skip_ellip_harm_2_pyx_ctypes.patch | 60 - packages/scipy/test_scipy.py | 67 +- packages/threadpoolctl/meta.yaml | 7 + pyodide-build/pyodide_build/_f2c_fixes.py | 424 ++++--- pyodide-build/pyodide_build/pywasmcross.py | 15 +- .../pyodide_build/tests/test_f2c_fixes.py | 27 - 32 files changed, 1843 insertions(+), 1729 deletions(-) create mode 100644 packages/scikit-learn/patches/0001-Cythonize-_cython_blas.pyx-with-include-path-pointin.patch create mode 100644 packages/scipy/info.md create mode 100644 packages/scipy/patches/add-lapack_extras-to-flapack.patch delete mode 100644 packages/scipy/patches/add-missing-extern.patch create mode 100644 packages/scipy/patches/convert-xerrwv-message-arg-from-int-to-str.patch create mode 100644 packages/scipy/patches/disable-blas-detection.patch delete mode 100644 packages/scipy/patches/disable_scipy_stats_mvn.patch delete mode 100644 packages/scipy/patches/fix-blas.patch delete mode 100644 packages/scipy/patches/fix-build-gcc5-a80460.patch create mode 100644 packages/scipy/patches/fix-fortran-files-minpack.patch create mode 100644 packages/scipy/patches/fix-implicit-cast-args-from-newer-lapack.patch delete mode 100644 packages/scipy/patches/fix-typo-flapack-pyf.patch delete mode 100644 packages/scipy/patches/force_malloc.patch create mode 100644 packages/scipy/patches/gemm_-no-const.patch create mode 100644 packages/scipy/patches/remove-cuncsd-dorcsd-sorcsd-zuncsd.patch create mode 100644 packages/scipy/patches/remove-mvnun-not-fortran-77-compliant.patch create mode 100644 packages/scipy/patches/rename-_page_trend_test.patch create mode 100644 packages/scipy/patches/sasum-returns-double-not-float.patch delete mode 100644 packages/scipy/patches/skip_ellip_harm_2_pyx_ctypes.patch create mode 100644 packages/threadpoolctl/meta.yaml delete mode 100644 pyodide-build/pyodide_build/tests/test_f2c_fixes.py diff --git a/Makefile.envs b/Makefile.envs index fb44ee656..656078ea3 100644 --- a/Makefile.envs +++ b/Makefile.envs @@ -30,6 +30,7 @@ export PYODIDE_BASE_URL?=./ # For packages that depend on numpy. # TODO: maybe move this somewhere else? +export NUMPY_LIB_BASE=$(PYODIDE_ROOT)/packages/numpy/build/numpy-1.21.4/install/lib/python$(PYMAJOR).$(PYMINOR)/site-packages/numpy/ export NUMPY_LIB=$(PYODIDE_ROOT)/packages/numpy/build/numpy-1.21.4/install/lib/python$(PYMAJOR).$(PYMINOR)/site-packages/numpy/core/lib/ # This environment variable is used for packages to detect if they are built diff --git a/docs/project/changelog.md b/docs/project/changelog.md index 090a7cdeb..d6d6c140b 100644 --- a/docs/project/changelog.md +++ b/docs/project/changelog.md @@ -184,7 +184,17 @@ async function runPythonAsync(code, globals) { - {{ Enhancement }} upgraded numpy to 1.21.4 {pr}`1934` -- {{ Fix }} The built-in pwd module of Python, which provides Unix specific +- {{ Enhancement }} Upgraded SciPy to 1.7.3. Note that there are still known issues with + some SciPy components. + {pr}`2065` + +- {{ Enhancement }} Upgraded scikit-learn to version 1.0.2 + {pr}`2065` + +- {{ Enhancement }} Added threadpoolctl (a dependency of scikit-learn) + {pr}`2065` + +- {{ Fix }} The built-in pwd module of Python, which provides a Unix specific feature, is now unvendored. {pr}`1883` diff --git a/packages/CLAPACK/meta.yaml b/packages/CLAPACK/meta.yaml index e5acd1be0..619c5da83 100644 --- a/packages/CLAPACK/meta.yaml +++ b/packages/CLAPACK/meta.yaml @@ -31,11 +31,7 @@ build: sed -i 's/^ ar /^ $(ARCH)/' **/Makefile sed -i 's/^ ld /^ $(LD)/' **/Makefile - # We build BLAS/LAPACK only for target. - # On host we include -LCLAPACK-3.2.1 path which has no effect on host. - # On target it gets rewritten by pywasmcross to the full patch of - # blas_WA.a, lapack_WA.a which are linked statically in scipy - # in each module that needs them. emmake make -j ${PYODIDE_JOBS:-3} blaslib lapacklib mkdir -p install/lib - emcc blas_WA.a lapack_WA.a F2CLIBS/libf2c.a -sSIDE_MODULE -o install/lib/clapack_all.so + + emcc blas_WA.a lapack_WA.a F2CLIBS/libf2c.a -sSIDE_MODULE -o install/lib/clapack_all.so diff --git a/packages/scikit-learn/meta.yaml b/packages/scikit-learn/meta.yaml index a8348bb01..78800dca7 100644 --- a/packages/scikit-learn/meta.yaml +++ b/packages/scikit-learn/meta.yaml @@ -1,13 +1,14 @@ package: name: scikit-learn - version: 0.22.2 + version: 1.0.2 source: - url: https://github.com/scikit-learn/scikit-learn/archive/0.22.2.tar.gz - sha256: 54ae27be30ef26718c9e517c4c8f23b6af26c66e52cf16d38799ba4262d4fd3b + url: https://files.pythonhosted.org/packages/75/44/074b780d8ac0b0899937e9b8ba6d5d8873a71b99aa915219251ef85a8890/scikit-learn-1.0.2.tar.gz + sha256: b5870959a5484b614f26d31ca4c17524b1b0317522199dc985c3b4256e030767 patches: - patches/disable-openmp.patch + - patches/0001-Cythonize-_cython_blas.pyx-with-include-path-pointin.patch build: cflags: -Wno-implicit-function-declaration @@ -17,6 +18,7 @@ requirements: - numpy - scipy - joblib + - threadpoolctl test: imports: diff --git a/packages/scikit-learn/patches/0001-Cythonize-_cython_blas.pyx-with-include-path-pointin.patch b/packages/scikit-learn/patches/0001-Cythonize-_cython_blas.pyx-with-include-path-pointin.patch new file mode 100644 index 000000000..f46d07d7a --- /dev/null +++ b/packages/scikit-learn/patches/0001-Cythonize-_cython_blas.pyx-with-include-path-pointin.patch @@ -0,0 +1,33 @@ +From f1d8f0b92b17765a2e8b6ac508cfa77a79fb73a0 Mon Sep 17 00:00:00 2001 +From: Hood Chatham +Date: Sun, 26 Dec 2021 22:39:25 -0800 +Subject: [PATCH] Cythonize _cython_blas.pyx with include path pointing to + scipy + +--- + sklearn/utils/setup.py | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/sklearn/utils/setup.py b/sklearn/utils/setup.py +index ed78ecc5d..ea1a61b40 100644 +--- a/sklearn/utils/setup.py ++++ b/sklearn/utils/setup.py +@@ -2,6 +2,7 @@ import os + from os.path import join + + from sklearn._build_utils import gen_from_templates ++from Cython.Build import cythonize + + + def configuration(parent_package="", top_path=None): +@@ -18,6 +19,7 @@ def configuration(parent_package="", top_path=None): + "sparsefuncs_fast", sources=["sparsefuncs_fast.pyx"], libraries=libraries + ) + ++ cythonize("sklearn/utils/_cython_blas.pyx", include_path=[f"{os.environ['PYODIDE_ROOT']}/packages/scipy/build/scipy-1.7.3/"]) + config.add_extension( + "_cython_blas", sources=["_cython_blas.pyx"], libraries=libraries + ) +-- +2.25.1 + diff --git a/packages/scikit-learn/test_scikit-learn.py b/packages/scikit-learn/test_scikit-learn.py index e978d2f4f..3fe49deb1 100644 --- a/packages/scikit-learn/test_scikit-learn.py +++ b/packages/scikit-learn/test_scikit-learn.py @@ -1,26 +1,48 @@ import pytest +from conftest import selenium_context_manager @pytest.mark.driver_timeout(40) -def test_scikit_learn(selenium_standalone, request): - selenium = selenium_standalone - selenium.load_package("scikit-learn") - assert ( +def test_scikit_learn(selenium_module_scope): + if selenium_module_scope.browser == "chrome": + pytest.xfail("Times out in chrome") + with selenium_context_manager(selenium_module_scope) as selenium: + selenium.load_package("scikit-learn") + assert ( + selenium.run( + """ + import numpy as np + import sklearn + from sklearn.linear_model import LogisticRegression + + rng = np.random.RandomState(42) + X = rng.rand(100, 20) + y = rng.randint(5, size=100) + + estimator = LogisticRegression(solver='liblinear') + estimator.fit(X, y) + print(estimator.predict(X)) + estimator.score(X, y) + """ + ) + > 0 + ) + + +@pytest.mark.driver_timeout(40) +def test_logistic_regression(selenium_module_scope): + if selenium_module_scope.browser == "chrome": + pytest.xfail("Times out in chrome") + with selenium_context_manager(selenium_module_scope) as selenium: + selenium.load_package("scikit-learn") selenium.run( """ - import numpy as np - import sklearn - from sklearn.linear_model import LogisticRegression - - rng = np.random.RandomState(42) - X = rng.rand(100, 20) - y = rng.randint(5, size=100) - - estimator = LogisticRegression(solver='liblinear') - estimator.fit(X, y) - print(estimator.predict(X)) - estimator.score(X, y) - """ + from sklearn.datasets import load_iris + from sklearn.linear_model import LogisticRegression + X, y = load_iris(return_X_y=True) + clf = LogisticRegression(random_state=0).fit(X, y) + print(clf.predict(X[:2, :])) + print(clf.predict_proba(X[:2, :])) + print(clf.score(X, y)) + """ ) - > 0 - ) diff --git a/packages/scipy/info.md b/packages/scipy/info.md new file mode 100644 index 000000000..44c1a5961 --- /dev/null +++ b/packages/scipy/info.md @@ -0,0 +1,95 @@ +The biggest issue that comes up in building scipy is that we don't have a good +fotran to wasm compiler. Some version of flang classic might work. + +Instead of compiling from fortran directly, we rely on f2c to cross compile +the code to C and then compile C to wasm. We rely on f2c both directly and via +CLAPACK which is f2c'd LAPACK. + +Unfortunately, f2c only handles fortran 77 code and it doesn't work perfectly +even on that. After LAPACK version 3.2 (released in 2008), LAPACK started +adding methods that use newer fortran features, so they cannot be f2c'd. Hence +it's unlikely that new versions of CLAPACK will be released and we can't use +any newer version of CLAPACK. + +Scipy is built based on a newer version of CLAPACK and I couldn't figure out +how to remove the newer functions. They cause dynamic linking errors when +scipy is imported. To find the list of problem functions I used: + +```sh +wasm-objdump clapack_all.so -d | sed -n 's/.*func.*<\(.*\)>:/\1/p' | sort -u > clapack_exports.txt +``` + +to list the symbols exported from our clapack and + +``` +wasm-objdump _flapack.so -d | sed -E -n 's/.*global.get [0-9]* <([a-z]*_?)>/\1/p' | sort -u > symbols.txt +``` + +to list the symbols that `_flapack.so` expects to see. There are 36 symbols in +this list. Conveniently, LAPACK defines one function per file, so I just +download a copy of LAPACK and cat these functions into +`scipy/linalg/src/lapack_deprecations/cgegv.f` which is chosen arbitrarily from +the `.f` source files that are linked into `_flapack.so` (there aren't that many +options though). Using an existing file allows us to avoid fiddling with build +scripts. Of the 36 missing symbol, 32 of them are written in Fortran 77 and work +fine. The remaining 4 need removing but I couldn't figure out how to take them +out in any sensible way (I can't understand all the layers of codegen that +happen in scipy), so I give them do-nothing definitions, and then in the build +script remove lines containing them with `sed`. + +Another big problem with f2c is that it cannot handle implicit casts of function +arguments, because it tries to guess the types of the arguments of the function +being called based on the types of the arguments at the call site. There are two +distinct versions of this: + +1. casts between number types -- we deal with this automatically in + `fix_inconsistent_decls` in `_f2c_fixes.py` +2. casts between char\* and int -- this is too annoying to deal with + automatically, so we write manual patches. + +Type 1: the fortran equivalent of the following C code: + +```C +double f(double x){ + return x + 5; +} + +double g(int x){ + return f(x); +} +``` + +gets f2c'd to + +```C +double f(double x){ + return x + 5; +} + +double g(int x){ + double f(int); + return f(x); +} +``` + +When we try to compile this, we get an error saying that f has been declared +with two different types. + +Type 2: For each string argument, the Fortran ABI adds arguments at the end of +the argument list. LAPACK never declares functions as taking strings, preferring +to call them integers: + +```C +int some_lapack_func(int *some_string, int *some_string_length){ + // ... +} +``` + +But then when we call it: `some_lapack_func("a string here", 14);` the f2c'd +version looks like: + +```C +int str_len = 14; +int some_lapack_func(int *some_string, int *some_string_length, fortranlen some_string_length_again); +some_lapack_func("a string here", &str_len, 14); +``` diff --git a/packages/scipy/meta.yaml b/packages/scipy/meta.yaml index 4d020dcc8..c9821336c 100644 --- a/packages/scipy/meta.yaml +++ b/packages/scipy/meta.yaml @@ -1,60 +1,105 @@ package: name: scipy - version: 0.17.1 + version: 1.7.3 # when updating version make sure to update pip install scipy==1.7.3 below too. + +# See extra explanation in info.md +# +# For future reference: if you see the following errors: +# Declaration error: adjustable dimension on non-argument +# or: +# nonconstant array size +# you are trying to compile code that isn't written to the fortran 77 standard. +# The line number in the error points to the last line of the problematic +# subroutine. Try deleting it. source: - # 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 + url: https://files.pythonhosted.org/packages/61/67/1a654b96309c991762ee9bc39c363fc618076b155fe52d295211cf2536c7/scipy-1.7.3.tar.gz + sha256: ab5875facfdef77e0a47d5fd39ea178b58e60e454a4c85aa1e52fcb80db7babf patches: - # these patches can be found as commits in - # https://github.com/rth/scipy/tree/0.17.1-pyodide - # on top of the v0.17.1 tag - - patches/fix-blas.patch - - patches/fix-build-gcc5-a80460.patch - - patches/force_malloc.patch - - patches/disable_scipy_stats_mvn.patch - - patches/skip-fortran-fails-to-link.patch - - patches/skip_ellip_harm_2_pyx_ctypes.patch + - patches/add-lapack_extras-to-flapack.patch + - patches/convert-xerrwv-message-arg-from-int-to-str.patch + - patches/disable-blas-detection.patch + - patches/fix-fortran-files-minpack.patch + - patches/gemm_-no-const.patch - patches/make-int-return-values.patch - - patches/add-missing-extern.patch - - patches/fix-typo-flapack-pyf.patch + - patches/remove-cuncsd-dorcsd-sorcsd-zuncsd.patch + - patches/remove-mvnun-not-fortran-77-compliant.patch + - patches/sasum-returns-double-not-float.patch + - patches/skip-fortran-fails-to-link.patch + - patches/rename-_page_trend_test.patch build: # set linker and C flags to error on anything to do with function declarations being wrong. # In webassembly, any conflicts mean that a randomly selected 50% of calls to the function # will fail. Better to fail at compile or link time. cflags: | - -I $(PYODIDE_ROOT)/packages/numpy/config + -I$(PYODIDE_ROOT)/packages/numpy/config -I$(PYODIDE_ROOT)/packages/CLAPACK/build/CLAPACK-3.2.1/INCLUDE + -I$(PYODIDE_ROOT)/packages/.artifacts/include/ + -I$(PYODIDE_ROOT)/packages/.artifacts/pythran/ -DUNDERSCORE_G77 -Werror=implicit-function-declaration -Werror=mismatched-parameter-types -Werror=mismatched-return-types + -Wno-return-type ldflags: | -L$(NUMPY_LIB) + -L$(NUMPY_LIB_BASE)/random/lib -Wl,--fatal-warnings + # IMPORTANT: Other locations important in scipy build process: + # There are two files built in the "capture" pass that need patching: + # _blas_subroutines.h, and _cython + # Scipy has a bunch of custom logic implemented in + # pyodide-build/pyodide_build/_f2c_fixes.py. script: | - # Some fixes were extracted from patches/make-int-return-values.patch as regex. + pip install scipy==1.7.3 pybind11[global] pythran + pip install --upgrade pybind11[global] pythran -t $PYODIDE_ROOT/packages/.artifacts/ + # We get linker errors because the following 36 functions are missing + # Copying them from a more recent LAPACK seems to work fine. + wget https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v3.10.0.tar.gz + tar xzf v3.10.0.tar.gz + cd lapack-3.10.0/SRC + cat \ + cgemqrt.f cgeqrfp.f cgeqrt.f clahqr.f csyconv.f csyconvf.f csyconvf_rook.f ctpmqrt.f ctpqrt.f \ + dgemqrt.f dgeqrfp.f dgeqrt.f dlahqr.f dsyconv.f dsyconvf.f dsyconvf_rook.f dtpmqrt.f dtpqrt.f \ + sgemqrt.f sgeqrfp.f sgeqrt.f slahqr.f ssyconv.f ssyconvf.f ssyconvf_rook.f stpmqrt.f stpqrt.f \ + zgemqrt.f zgeqrfp.f zgeqrt.f zlahqr.f zsyconv.f zsyconvf.f zsyconvf_rook.f ztpmqrt.f ztpqrt.f \ + >> ../../scipy/linalg/lapack_extras.f + cd ../.. + # The additional four functions cuncsd, dorcsd, sorcsd, and zuncsd are also + # missing but they use features of Fortran that aren't Fortran 77 compatible + # so f2c can't handle them. We stub them with C definitions that do nothing. + # These stubs come from f2cpatches/wrap_dummy_g77_abi.patch + + # Change many functions that return void into functions that return int find scipy -name "*.c*" | xargs sed -i 's/extern void F_FUNC/extern int F_FUNC/g' sed -i 's/void F_FUNC/int F_FUNC/g' scipy/odr/__odrpack.c - sed -i 's/extern void/extern int/g' scipy/optimize/__minpack.h scipy/fftpack/src/zfftnd.c scipy/fftpack/src/zrfft.c - sed -i 's/void f_/int f_/g' scipy/cluster/cluster_blas.pxd - sed -i 's/void @pref/int @pref/g' scipy/fftpack/src/dct.c.src scipy/fftpack/src/dst.c.src - sed -i 's/^void/int/g' scipy/interpolate/src/__fitpack.h scipy/integrate/__quadpack.h scipy/fftpack/src/drfft.c scipy/fftpack/src/zfft.c - sed -i 's/static void/static int/g' scipy/interpolate/src/__fitpack.h - sed -i 's/ILAENV/ILAENZ/g' scipy/linalg/src/calc_lwork.f - # Regenerate header files after make-int-return-values patch to fix return - # types of f2c functions. - echo "Regenerating cython wrappers" - cd scipy/linalg - python _cython_wrapper_generators.py - cd ../.. + sed -i 's/extern void/extern int/g' scipy/optimize/__minpack.h + sed -i 's/^void/int/g' scipy/interpolate/src/_fitpackmodule.c + sed -i 's/void/int/g' scipy/linalg/cython_blas_signatures.txt + + # Missing declaration from cython_lapack_signatures.txt + echo "void ilaenv(int *ispec, char *name, char *opts, int *n1, int *n2, int *n3, int *n4)" \ + >> scipy/linalg/cython_lapack_signatures.txt + + # Input error causes "duplicate symbol" linker errors. Empty out the file. + echo "" > scipy/sparse/linalg/dsolve/SuperLU/SRC/input_error.c + echo 'import sys' >> scipy/__init__.py + echo 'if "pyodide_js" in sys.modules:' >> scipy/__init__.py + echo ' from pyodide_js._module import loadDynamicLibrary' >> scipy/__init__.py + echo ' loadDynamicLibrary("/lib/python3.9/site-packages/scipy/linalg/_flapack.so")' >> scipy/__init__.py + + prereplay: | + sed -i 's/void F_FUNC/int F_FUNC/g' scipy/linalg/_lapack_subroutines.h + sed -i 's/void F_FUNC/int F_FUNC/g' scipy/linalg/_blas_subroutines.h + find -name '*.c' | xargs sed -i 's/extern void F_WRAPPEDFUNC/extern int F_WRAPPEDFUNC/g' + find -name '*.c' | xargs sed -i 's/void (\*f2py_func)/int (*f2py_func)/g' + find -name '*.c' | xargs sed -i 's/static void cb_/static int cb_/g' + find -name '*.c' | xargs sed -i 's/typedef void(\*cb_/typedef int(*cb_/g' + sed -i 's/,size_t//' build/src.linux-x86_64-3.9/build/src.linux-x86_64-3.9/scipy/linalg/_flapackmodule.c + sed -i 's/,slen([a-z]*))/)/g' build/src.linux-x86_64-3.9/build/src.linux-x86_64-3.9/scipy/linalg/_flapackmodule.c + sed -i 's/ float (\*f2py_func)/ double (\*f2py_func)/g' build/src.linux-x86_64-3.9/build/src.linux-x86_64-3.9/scipy/linalg/_fblasmodule.c requirements: run: @@ -65,14 +110,38 @@ test: imports: - scipy - scipy.cluster + - scipy.cluster.vq + - scipy.cluster.hierarchy - scipy.constants + - scipy.fft - scipy.fftpack - - scipy.odr - - scipy.sparse - - scipy.interpolate - scipy.integrate + - scipy.interpolate + - scipy.io + - scipy.io.arff + - scipy.io.matlab + - scipy.io.wavfile - scipy.linalg + - scipy.linalg.blas + - scipy.linalg.cython_blas + - scipy.linalg.lapack + - scipy.linalg.cython_lapack + - scipy.linalg.interpolative - scipy.misc - scipy.ndimage + - scipy.odr + - scipy.optimize + - scipy.signal + - scipy.signal.windows + - scipy.sparse + - scipy.sparse.linalg + - scipy.sparse.csgraph - scipy.spatial + - scipy.spatial.distance + - scipy.spatial.transform - scipy.special + - scipy.stats + - scipy.stats.contingency + - scipy.stats.distributions + - scipy.stats.mstats + - scipy.stats.qmc diff --git a/packages/scipy/patches/add-lapack_extras-to-flapack.patch b/packages/scipy/patches/add-lapack_extras-to-flapack.patch new file mode 100644 index 000000000..f3629ac49 --- /dev/null +++ b/packages/scipy/patches/add-lapack_extras-to-flapack.patch @@ -0,0 +1,25 @@ +From 117b00d72c0472eb6a33e8fcbf17e3bfe3337a88 Mon Sep 17 00:00:00 2001 +From: Hood Chatham +Date: Fri, 31 Dec 2021 22:27:07 -0800 +Subject: [PATCH] Add lapack_extras to linalg/setup.py + +--- + scipy/linalg/setup.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/scipy/linalg/setup.py b/scipy/linalg/setup.py +index 2f0ef0a48..d384081a2 100644 +--- a/scipy/linalg/setup.py ++++ b/scipy/linalg/setup.py +@@ -43,7 +43,7 @@ def configuration(parent_package='', top_path=None): + ext._pre_build_hook = blas_ilp64_pre_build_hook(lapack_ilp64_opt) + + # flapack: +- sources = ['flapack.pyf.src'] ++ sources = ['flapack.pyf.src', 'lapack_extras.f'] + 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'] +-- +2.25.1 + diff --git a/packages/scipy/patches/add-missing-extern.patch b/packages/scipy/patches/add-missing-extern.patch deleted file mode 100644 index 184e0898c..000000000 --- a/packages/scipy/patches/add-missing-extern.patch +++ /dev/null @@ -1,12 +0,0 @@ -Add a missing extern in specfunc_wrappers.c - ---- a/scipy/special/specfun_wrappers.c -+++ b/scipy/special/specfun_wrappers.c -@@ -35,6 +35,7 @@ - extern void F_FUNC(itairy,ITAIRY)(double*,double*,double*,double*,double*); - extern void F_FUNC(e1xb,E1XB)(double*,double*); - extern void F_FUNC(e1z,E1Z)(npy_cdouble*,npy_cdouble*); -+extern void F_FUNC(eixz,EIXZ)(npy_cdouble*,npy_cdouble*); - extern void F_FUNC(eix,EIX)(double*,double*); - extern void F_FUNC(cerror,CERROR)(npy_cdouble*,npy_cdouble*); - extern void F_FUNC(stvh0,STVH0)(double*,double*); diff --git a/packages/scipy/patches/convert-xerrwv-message-arg-from-int-to-str.patch b/packages/scipy/patches/convert-xerrwv-message-arg-from-int-to-str.patch new file mode 100644 index 000000000..076d06b2a --- /dev/null +++ b/packages/scipy/patches/convert-xerrwv-message-arg-from-int-to-str.patch @@ -0,0 +1,30 @@ +From 109051fc810881a7291b47ba9353a69a36b600e3 Mon Sep 17 00:00:00 2001 +From: Hood Chatham +Date: Sat, 25 Dec 2021 18:04:18 -0800 +Subject: [PATCH] int to string + +f2c does not handle implicit casts of function arguments correctly. The msg +argument of `xerrwv` is defined to be an `int *`, and then implicitly cast +from a string at the call site. This doesn't work correctly. + +We redefine the type of the first argument to be string to fix the problem. + +--- + scipy/integrate/odepack/xerrwv.f | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/scipy/integrate/odepack/xerrwv.f b/scipy/integrate/odepack/xerrwv.f +index 7e180e4f8..b940bb702 100644 +--- a/scipy/integrate/odepack/xerrwv.f ++++ b/scipy/integrate/odepack/xerrwv.f +@@ -1,5 +1,6 @@ + subroutine xerrwv (msg, nmes, nerr, level, ni, i1, i2, nr, r1, r2) +- integer msg, nmes, nerr, level, ni, i1, i2, nr, ++ character msg*1 ++ integer nmes, nerr, level, ni, i1, i2, nr, + 1 i, lun, lunit, mesflg, ncpw, nch, nwds + double precision r1, r2 + dimension msg(nmes) +-- +2.25.1 + diff --git a/packages/scipy/patches/disable-blas-detection.patch b/packages/scipy/patches/disable-blas-detection.patch new file mode 100644 index 000000000..e45af8efc --- /dev/null +++ b/packages/scipy/patches/disable-blas-detection.patch @@ -0,0 +1,24 @@ +commit 7352fc4a977a3414cf3194faf6ef990638a6329c +Author: Roman Yurchak +Date: Sat Feb 27 11:13:29 2021 +0100 + + disable-blas-detection.patch + +BLAS and LAPACK aren't available on host because we only cross compile these +libraries (see CLAPACK/meta.yaml). Scipy tries to detect these libraries and +if it fails to find them errors out the build. But we have them installed +correctly for our target, so we just disable this detection mechanism. + +diff --git a/setup.py b/setup.py +index 0e11de60f..8c28c613d 100755 +--- a/setup.py ++++ b/setup.py +@@ -484,7 +484,7 @@ def configuration(parent_package='', top_path=None): + + lapack_opt = get_info('lapack_opt') + +- if not lapack_opt: ++ if not lapack_opt and False: + if sys.platform == "darwin": + msg = ('No BLAS/LAPACK libraries found. ' + 'Note: Accelerate is no longer supported.') diff --git a/packages/scipy/patches/disable_scipy_stats_mvn.patch b/packages/scipy/patches/disable_scipy_stats_mvn.patch deleted file mode 100644 index e877e8edf..000000000 --- a/packages/scipy/patches/disable_scipy_stats_mvn.patch +++ /dev/null @@ -1,39 +0,0 @@ -commit d6740caa7400105a578ace74f8c25bbb3434178c -Author: Roman Yurchak -Date: Wed Oct 10 14:47:12 2018 +0200 - - Disable scipy.stats.mvn - -diff --git a/scipy/stats/kde.py b/scipy/stats/kde.py -index 7c702a038..8b0ab0254 100644 ---- a/scipy/stats/kde.py -+++ b/scipy/stats/kde.py -@@ -32,7 +32,10 @@ import numpy as np - from numpy.random import randint, multivariate_normal - - # Local imports. --from . import mvn -+try: -+ from . import mvn -+except ImportError: -+ mvn = None - - - __all__ = ['gaussian_kde'] -diff --git a/scipy/stats/setup.py b/scipy/stats/setup.py -index f1a02df4e..7366ec12d 100755 ---- a/scipy/stats/setup.py -+++ b/scipy/stats/setup.py -@@ -32,9 +32,9 @@ def configuration(parent_package='',top_path=None): - ) - - # add mvn module -- config.add_extension('mvn', -- sources=['mvn.pyf','mvndst.f'], -- ) -+ #config.add_extension('mvn', -+ # sources=['mvn.pyf','mvndst.f'], -+ #) - - return config - diff --git a/packages/scipy/patches/fix-blas.patch b/packages/scipy/patches/fix-blas.patch deleted file mode 100644 index 3681a74d5..000000000 --- a/packages/scipy/patches/fix-blas.patch +++ /dev/null @@ -1,89 +0,0 @@ -commit f03d85c00ae993c3c87a5a7b2ea0c1215f57ee04 -Author: Roman Yurchak -Date: Mon Oct 8 10:53:11 2018 +0200 - - Partial fixes for BLAS/LAPACK - -diff --git a/scipy/linalg/setup.py b/scipy/linalg/setup.py -index 2c9b9ba22..e8c7336d5 100755 ---- a/scipy/linalg/setup.py -+++ b/scipy/linalg/setup.py -@@ -14,7 +14,13 @@ def configuration(parent_package='', top_path=None): - - config = Configuration('linalg', parent_package, top_path) - -- lapack_opt = get_info('lapack_opt') -+ lapack_opt = { # libraries will be auto-generated by pywasmcross -+ 'libraries': [], -+ 'include_dirs': [], -+ 'library_dirs': ['../../../CLAPACK/build/CLAPACK-3.2.1/'], -+ 'language': 'f77', -+ 'define_macros': [('NO_ATLAS_INFO', 1), -+ ('HAVE_CBLAS', None)]} - - if not lapack_opt: - raise NotFoundError('no lapack/blas resources found') -@@ -117,9 +123,22 @@ def configuration(parent_package='', top_path=None): - 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 -- ) -+ # TODO: The following fails with, -+ # scipy/linalg/src/id_dist/src/idd_sfft.c:114:22: error: conflicting types for 'idd_sffti1__' -+ # /* Subroutine */ int idd_sffti1__(integer *ind, integer *n, doublereal *wsave) -+ # ^ -+ # scipy/linalg/src/id_dist/src/idd_sfft.c:72:33: note: previous declaration is here -+ # extern /* Subroutine */ int idd_sffti1__(integer *, integer *, -+ # ^ -+ # scipy/linalg/src/id_dist/src/idd_sfft.c:371:22: error: conflicting types for 'idd_sfft1__' -+ # /* Subroutine */ int idd_sfft1__(integer *ind, integer *n, doublereal *v, -+ # ^ -+ # scipy/linalg/src/id_dist/src/idd_sfft.c:311:33: note: previous declaration is here -+ # extern /* Subroutine */ int idd_sfft1__(integer *, integer *, doublereal * -+ # -+ #config.add_extension('_interpolative', fnames + ["interpolative.pyf"], -+ # extra_info=lapack_opt -+ # ) - - # _calc_lwork: - config.add_extension('_calc_lwork', -diff --git a/scipy/sparse/linalg/eigen/arpack/setup.py b/scipy/sparse/linalg/eigen/arpack/setup.py -index a8175a9d5..88a717fe6 100755 ---- a/scipy/sparse/linalg/eigen/arpack/setup.py -+++ b/scipy/sparse/linalg/eigen/arpack/setup.py -@@ -11,7 +11,13 @@ def configuration(parent_package='',top_path=None): - - config = Configuration('arpack',parent_package,top_path) - -- lapack_opt = get_info('lapack_opt') -+ lapack_opt = { # libraries will be auto-generated by pywasmcross -+ 'libraries': [], -+ 'include_dirs': [], -+ 'library_dirs': ['../../../CLAPACK/build/CLAPACK-3.2.1/'], -+ 'language': 'f77', -+ 'define_macros': [('NO_ATLAS_INFO', 1), -+ ('HAVE_CBLAS', None)]} - - if not lapack_opt: - raise NotFoundError('no lapack/blas resources found') -diff --git a/scipy/sparse/linalg/isolve/setup.py b/scipy/sparse/linalg/isolve/setup.py -index becb9237a..707e3f49d 100755 ---- a/scipy/sparse/linalg/isolve/setup.py -+++ b/scipy/sparse/linalg/isolve/setup.py -@@ -11,7 +11,13 @@ def configuration(parent_package='',top_path=None): - - config = Configuration('isolve',parent_package,top_path) - -- lapack_opt = get_info('lapack_opt') -+ lapack_opt = { # libraries will be auto-generated by pywasmcross -+ 'libraries': [], -+ 'include_dirs': [], -+ 'library_dirs': ['../../../CLAPACK/build/CLAPACK-3.2.1/'], -+ 'language': 'f77', -+ 'define_macros': [('NO_ATLAS_INFO', 1), -+ ('HAVE_CBLAS', None)]} - - if not lapack_opt: - raise NotFoundError('no lapack/blas resources found') diff --git a/packages/scipy/patches/fix-build-gcc5-a80460.patch b/packages/scipy/patches/fix-build-gcc5-a80460.patch deleted file mode 100644 index d97198c26..000000000 --- a/packages/scipy/patches/fix-build-gcc5-a80460.patch +++ /dev/null @@ -1,54 +0,0 @@ -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 - diff --git a/packages/scipy/patches/fix-fortran-files-minpack.patch b/packages/scipy/patches/fix-fortran-files-minpack.patch new file mode 100644 index 000000000..c5c466346 --- /dev/null +++ b/packages/scipy/patches/fix-fortran-files-minpack.patch @@ -0,0 +1,253 @@ +diff --git a/scipy/optimize/minpack/chkder.f b/scipy/optimize/minpack/chkder.f +index 0657ab56a..29578fc41 100644 +--- a/scipy/optimize/minpack/chkder.f ++++ b/scipy/optimize/minpack/chkder.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err) ++ subroutine chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err) + integer m,n,ldfjac,mode + double precision x(n),fvec(m),fjac(ldfjac,n),xp(n),fvecp(m), + * err(m) +diff --git a/scipy/optimize/minpack/dogleg.f b/scipy/optimize/minpack/dogleg.f +index d9626c911..b812f1966 100644 +--- a/scipy/optimize/minpack/dogleg.f ++++ b/scipy/optimize/minpack/dogleg.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine dogleg(n,r,lr,diag,qtb,delta,x,wa1,wa2) ++ subroutine dogleg(n,r,lr,diag,qtb,delta,x,wa1,wa2) + integer n,lr + double precision delta + double precision r(lr),diag(n),qtb(n),x(n),wa1(n),wa2(n) +diff --git a/scipy/optimize/minpack/dpmpar.f b/scipy/optimize/minpack/dpmpar.f +index 3fd3b4ef8..cb6545a92 100644 +--- a/scipy/optimize/minpack/dpmpar.f ++++ b/scipy/optimize/minpack/dpmpar.f +@@ -1,5 +1,4 @@ +- recursive +- *double precision function dpmpar(i) ++ double precision function dpmpar(i) + integer i + c ********** + c +diff --git a/scipy/optimize/minpack/enorm.f b/scipy/optimize/minpack/enorm.f +index 21557c147..2cb5b607e 100644 +--- a/scipy/optimize/minpack/enorm.f ++++ b/scipy/optimize/minpack/enorm.f +@@ -1,5 +1,4 @@ +- recursive +- *double precision function enorm(n,x) ++ double precision function enorm(n,x) + integer n + double precision x(n) + c ********** +diff --git a/scipy/optimize/minpack/fdjac1.f b/scipy/optimize/minpack/fdjac1.f +index 2a7d84cc1..031ed4652 100644 +--- a/scipy/optimize/minpack/fdjac1.f ++++ b/scipy/optimize/minpack/fdjac1.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn, ++ subroutine fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn, + * wa1,wa2) + integer n,ldfjac,iflag,ml,mu + double precision epsfcn +diff --git a/scipy/optimize/minpack/fdjac2.f b/scipy/optimize/minpack/fdjac2.f +index 5f4c1338f..218ab94c1 100644 +--- a/scipy/optimize/minpack/fdjac2.f ++++ b/scipy/optimize/minpack/fdjac2.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa) ++ subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa) + integer m,n,ldfjac,iflag + double precision epsfcn + double precision x(n),fvec(m),fjac(ldfjac,n),wa(m) +diff --git a/scipy/optimize/minpack/hybrd.f b/scipy/optimize/minpack/hybrd.f +index 75f450c9c..fc0b4c26a 100644 +--- a/scipy/optimize/minpack/hybrd.f ++++ b/scipy/optimize/minpack/hybrd.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine hybrd(fcn,n,x,fvec,xtol,maxfev,ml,mu,epsfcn,diag, ++ subroutine hybrd(fcn,n,x,fvec,xtol,maxfev,ml,mu,epsfcn,diag, + * mode,factor,nprint,info,nfev,fjac,ldfjac,r,lr, + * qtf,wa1,wa2,wa3,wa4) + integer n,maxfev,ml,mu,mode,nprint,info,nfev,ldfjac,lr +diff --git a/scipy/optimize/minpack/hybrd1.f b/scipy/optimize/minpack/hybrd1.f +index 87660fe18..c0a859275 100644 +--- a/scipy/optimize/minpack/hybrd1.f ++++ b/scipy/optimize/minpack/hybrd1.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine hybrd1(fcn,n,x,fvec,tol,info,wa,lwa) ++ subroutine hybrd1(fcn,n,x,fvec,tol,info,wa,lwa) + integer n,info,lwa + double precision tol + double precision x(n),fvec(n),wa(lwa) +diff --git a/scipy/optimize/minpack/hybrj.f b/scipy/optimize/minpack/hybrj.f +index 4f676832e..3070dad3f 100644 +--- a/scipy/optimize/minpack/hybrj.f ++++ b/scipy/optimize/minpack/hybrj.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag,mode, ++ subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag,mode, + * factor,nprint,info,nfev,njev,r,lr,qtf,wa1,wa2, + * wa3,wa4) + integer n,ldfjac,maxfev,mode,nprint,info,nfev,njev,lr +diff --git a/scipy/optimize/minpack/hybrj1.f b/scipy/optimize/minpack/hybrj1.f +index afa9d80f1..9f51c4965 100644 +--- a/scipy/optimize/minpack/hybrj1.f ++++ b/scipy/optimize/minpack/hybrj1.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa) ++ subroutine hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa) + integer n,ldfjac,info,lwa + double precision tol + double precision x(n),fvec(n),fjac(ldfjac,n),wa(lwa) +diff --git a/scipy/optimize/minpack/lmder.f b/scipy/optimize/minpack/lmder.f +index 684925592..8797d8bed 100644 +--- a/scipy/optimize/minpack/lmder.f ++++ b/scipy/optimize/minpack/lmder.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, ++ subroutine lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, + * maxfev,diag,mode,factor,nprint,info,nfev,njev, + * ipvt,qtf,wa1,wa2,wa3,wa4) + integer m,n,ldfjac,maxfev,mode,nprint,info,nfev,njev +diff --git a/scipy/optimize/minpack/lmder1.f b/scipy/optimize/minpack/lmder1.f +index 6be29477d..d691940fd 100644 +--- a/scipy/optimize/minpack/lmder1.f ++++ b/scipy/optimize/minpack/lmder1.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa, ++ subroutine lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa, + * lwa) + integer m,n,ldfjac,info,lwa + integer ipvt(n) +diff --git a/scipy/optimize/minpack/lmdif.f b/scipy/optimize/minpack/lmdif.f +index fcb61d138..dd3d4ee25 100644 +--- a/scipy/optimize/minpack/lmdif.f ++++ b/scipy/optimize/minpack/lmdif.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn, ++ subroutine lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn, + * diag,mode,factor,nprint,info,nfev,fjac,ldfjac, + * ipvt,qtf,wa1,wa2,wa3,wa4) + integer m,n,maxfev,mode,nprint,info,nfev,ldfjac +diff --git a/scipy/optimize/minpack/lmdif1.f b/scipy/optimize/minpack/lmdif1.f +index 6f28ed2f7..70f8aae05 100644 +--- a/scipy/optimize/minpack/lmdif1.f ++++ b/scipy/optimize/minpack/lmdif1.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa) ++ subroutine lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa) + integer m,n,info,lwa + integer iwa(n) + double precision tol +diff --git a/scipy/optimize/minpack/lmpar.f b/scipy/optimize/minpack/lmpar.f +index e25eb0d3e..26c422a79 100644 +--- a/scipy/optimize/minpack/lmpar.f ++++ b/scipy/optimize/minpack/lmpar.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine lmpar(n,r,ldr,ipvt,diag,qtb,delta,par,x,sdiag,wa1, ++ subroutine lmpar(n,r,ldr,ipvt,diag,qtb,delta,par,x,sdiag,wa1, + * wa2) + integer n,ldr + integer ipvt(n) +diff --git a/scipy/optimize/minpack/lmstr.f b/scipy/optimize/minpack/lmstr.f +index 2b6bbbfc2..d9a7893f8 100644 +--- a/scipy/optimize/minpack/lmstr.f ++++ b/scipy/optimize/minpack/lmstr.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, ++ subroutine lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, + * maxfev,diag,mode,factor,nprint,info,nfev,njev, + * ipvt,qtf,wa1,wa2,wa3,wa4) + integer m,n,ldfjac,maxfev,mode,nprint,info,nfev,njev +diff --git a/scipy/optimize/minpack/lmstr1.f b/scipy/optimize/minpack/lmstr1.f +index 225e8736f..2fa8ee1c5 100644 +--- a/scipy/optimize/minpack/lmstr1.f ++++ b/scipy/optimize/minpack/lmstr1.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa, ++ subroutine lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa, + * lwa) + integer m,n,ldfjac,info,lwa + integer ipvt(n) +diff --git a/scipy/optimize/minpack/qform.f b/scipy/optimize/minpack/qform.f +index 1f368587e..087b2478b 100644 +--- a/scipy/optimize/minpack/qform.f ++++ b/scipy/optimize/minpack/qform.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine qform(m,n,q,ldq,wa) ++ subroutine qform(m,n,q,ldq,wa) + integer m,n,ldq + double precision q(ldq,m),wa(m) + c ********** +diff --git a/scipy/optimize/minpack/qrfac.f b/scipy/optimize/minpack/qrfac.f +index fa6789086..cb686086c 100644 +--- a/scipy/optimize/minpack/qrfac.f ++++ b/scipy/optimize/minpack/qrfac.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine qrfac(m,n,a,lda,pivot,ipvt,lipvt,rdiag,acnorm,wa) ++ subroutine qrfac(m,n,a,lda,pivot,ipvt,lipvt,rdiag,acnorm,wa) + integer m,n,lda,lipvt + integer ipvt(lipvt) + logical pivot +diff --git a/scipy/optimize/minpack/qrsolv.f b/scipy/optimize/minpack/qrsolv.f +index 3dc009721..5580087ca 100644 +--- a/scipy/optimize/minpack/qrsolv.f ++++ b/scipy/optimize/minpack/qrsolv.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa) ++ subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa) + integer n,ldr + integer ipvt(n) + double precision r(ldr,n),diag(n),qtb(n),x(n),sdiag(n),wa(n) +diff --git a/scipy/optimize/minpack/r1mpyq.f b/scipy/optimize/minpack/r1mpyq.f +index 1410b9ad6..ec99b96ce 100644 +--- a/scipy/optimize/minpack/r1mpyq.f ++++ b/scipy/optimize/minpack/r1mpyq.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine r1mpyq(m,n,a,lda,v,w) ++ subroutine r1mpyq(m,n,a,lda,v,w) + integer m,n,lda + double precision a(lda,n),v(n),w(n) + c ********** +diff --git a/scipy/optimize/minpack/r1updt.f b/scipy/optimize/minpack/r1updt.f +index e809d8402..e034973d9 100644 +--- a/scipy/optimize/minpack/r1updt.f ++++ b/scipy/optimize/minpack/r1updt.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine r1updt(m,n,s,ls,u,v,w,sing) ++ subroutine r1updt(m,n,s,ls,u,v,w,sing) + integer m,n,ls + logical sing + double precision s(ls),u(m),v(n),w(m) +diff --git a/scipy/optimize/minpack/rwupdt.f b/scipy/optimize/minpack/rwupdt.f +index 61a7928bb..05282b556 100644 +--- a/scipy/optimize/minpack/rwupdt.f ++++ b/scipy/optimize/minpack/rwupdt.f +@@ -1,5 +1,4 @@ +- recursive +- *subroutine rwupdt(n,r,ldr,w,b,alpha,cos,sin) ++ subroutine rwupdt(n,r,ldr,w,b,alpha,cos,sin) + integer n,ldr + double precision alpha + double precision r(ldr,n),w(n),b(n),cos(n),sin(n) diff --git a/packages/scipy/patches/fix-implicit-cast-args-from-newer-lapack.patch b/packages/scipy/patches/fix-implicit-cast-args-from-newer-lapack.patch new file mode 100644 index 000000000..204707cf8 --- /dev/null +++ b/packages/scipy/patches/fix-implicit-cast-args-from-newer-lapack.patch @@ -0,0 +1,317 @@ +We are hijacking dfft.f to inject missing functions from future versions of LAPACK. + +This patch is applied to the generated dfft.c after f2c is applied to dfft.f. +This must be done in between when f2c is applied to dfft.f and when dfft.c is compiled. +This is arranged in _f2c_fixes.py. + +f2c does not correctly handle implicit casts of function arguments. If the implicit casts +are between integer types then we can handle that automatically in _f2c_fixes.py. This +patch fixes implicit casts from char* to int, which we need to deal with manually. + +--- a/scipy/linalg/src/id_dist/src/dfft.c ++++ b/scipy/linalg/src/id_dist/src/dfft.c +@@ -2855,8 +2855,7 @@ f_rook.f"> */ + extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), ctprfb_( + char *, char *, char *, char *, integer *, integer *, integer *, + integer *, complex *, integer *, complex *, integer *, complex *, +- integer *, complex *, integer *, complex *, integer *, ftnlen, +- ftnlen, ftnlen, ftnlen); ++ integer *, complex *, integer *, complex *, integer *); + static logical notran; + + +@@ -2967,8 +2966,7 @@ f_rook.f"> */ + } + ctprfb_("L", "C", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, & +- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, ( +- ftnlen)1, (ftnlen)1); ++ b[b_offset], ldb, &work[1], &ib); + } + + } else if (right && notran) { +@@ -2989,8 +2987,7 @@ f_rook.f"> */ + } + ctprfb_("R", "N", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1], +- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1, +- (ftnlen)1, (ftnlen)1); ++ lda, &b[b_offset], ldb, &work[1], m); + } + + } else if (left && notran) { +@@ -3011,8 +3008,7 @@ f_rook.f"> */ + } + ctprfb_("L", "N", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, & +- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, ( +- ftnlen)1, (ftnlen)1); ++ b[b_offset], ldb, &work[1], &ib); + } + + } else if (right && tran) { +@@ -3033,8 +3029,7 @@ f_rook.f"> */ + } + ctprfb_("R", "C", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1], +- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1, +- (ftnlen)1, (ftnlen)1); ++ lda, &b[b_offset], ldb, &work[1], m); + } + + } +@@ -3247,8 +3242,7 @@ f"> */ + extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), ctprfb_( + char *, char *, char *, char *, integer *, integer *, integer *, + integer *, complex *, integer *, complex *, integer *, complex *, +- integer *, complex *, integer *, complex *, integer *, ftnlen, +- ftnlen, ftnlen, ftnlen), ctpqrt2_(integer *, integer *, integer *, ++ integer *, complex *, integer *, complex *, integer *), ctpqrt2_(integer *, integer *, integer *, + complex *, integer *, complex *, integer *, complex *, integer *, + integer *); + +@@ -3342,7 +3336,7 @@ f"> */ + ctprfb_("L", "C", "F", "C", &mb, &i__3, &ib, &lb, &b[i__ * b_dim1 + + 1], ldb, &t[i__ * t_dim1 + 1], ldt, &a[i__ + (i__ + ib) + * a_dim1], lda, &b[(i__ + ib) * b_dim1 + 1], ldb, &work[1] +- , &ib, (ftnlen)1, (ftnlen)1, (ftnlen)1, (ftnlen)1); ++ , &ib); + } + } + return 0; +@@ -6041,11 +6035,13 @@ f_rook.f"> */ + static integer ldvq; + extern logical lsame_(char *, char *, ftnlen, ftnlen); + static logical right; +- extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), dtprfb_( ++ extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), ++ ++ dtprfb_( + char *, char *, char *, char *, integer *, integer *, integer *, + integer *, doublereal *, integer *, doublereal *, integer *, + doublereal *, integer *, doublereal *, integer *, doublereal *, +- integer *, ftnlen, ftnlen, ftnlen, ftnlen); ++ integer *); + static logical notran; + + +@@ -6156,8 +6152,7 @@ f_rook.f"> */ + } + dtprfb_("L", "T", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, & +- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, ( +- ftnlen)1, (ftnlen)1); ++ b[b_offset], ldb, &work[1], &ib); + } + + } else if (right && notran) { +@@ -6178,8 +6173,7 @@ f_rook.f"> */ + } + dtprfb_("R", "N", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1], +- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1, +- (ftnlen)1, (ftnlen)1); ++ lda, &b[b_offset], ldb, &work[1], m); + } + + } else if (left && notran) { +@@ -6200,8 +6194,7 @@ f_rook.f"> */ + } + dtprfb_("L", "N", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, & +- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, ( +- ftnlen)1, (ftnlen)1); ++ b[b_offset], ldb, &work[1], &ib); + } + + } else if (right && tran) { +@@ -6222,8 +6215,7 @@ f_rook.f"> */ + } + dtprfb_("R", "T", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1], +- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1, +- (ftnlen)1, (ftnlen)1); ++ lda, &b[b_offset], ldb, &work[1], m); + } + + } +@@ -6433,13 +6425,12 @@ f"> */ + + /* Local variables */ + static integer i__, ib, lb, mb, iinfo; +- extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), dtprfb_( +- char *, char *, char *, char *, integer *, integer *, integer *, +- integer *, doublereal *, integer *, doublereal *, integer *, +- doublereal *, integer *, doublereal *, integer *, doublereal *, +- integer *, ftnlen, ftnlen, ftnlen, ftnlen), dtpqrt2_(integer *, +- integer *, integer *, doublereal *, integer *, doublereal *, +- integer *, doublereal *, integer *, integer *); ++ extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), ++ ++dtprfb_(char *, char *, char *, char *, integer *, integer *, integer *, integer *, doublereal *, integer *, doublereal *, integer *, ++ doublereal *, integer *, doublereal *, integer *, doublereal *, integer *), ++ ++ dtpqrt2_(integer *, integer *, integer *, doublereal *, integer *, doublereal *, integer *, doublereal *, integer *, integer *); + + + /* -- LAPACK computational routine -- */ +@@ -6531,9 +6522,8 @@ f"> */ + dtprfb_("L", "T", "F", "C", &mb, &i__3, &ib, &lb, &b[i__ * b_dim1 + + 1], ldb, &t[i__ * t_dim1 + 1], ldt, &a[i__ + (i__ + ib) + * a_dim1], lda, &b[(i__ + ib) * b_dim1 + 1], ldb, &work[1] +- , &ib, (ftnlen)1, (ftnlen)1, (ftnlen)1, (ftnlen)1); +- } +- } ++ , &ib); ++ }} + return 0; + + /* End of DTPQRT */ +@@ -9226,8 +9216,7 @@ f_rook.f"> */ + extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), stprfb_( + char *, char *, char *, char *, integer *, integer *, integer *, + integer *, real *, integer *, real *, integer *, real *, integer * +- , real *, integer *, real *, integer *, ftnlen, ftnlen, ftnlen, +- ftnlen); ++ , real *, integer *, real *, integer *); + static logical notran; + + +@@ -9338,8 +9327,7 @@ f_rook.f"> */ + } + stprfb_("L", "T", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, & +- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, ( +- ftnlen)1, (ftnlen)1); ++ b[b_offset], ldb, &work[1], &ib); + } + + } else if (right && notran) { +@@ -9360,8 +9348,7 @@ f_rook.f"> */ + } + stprfb_("R", "N", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1], +- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1, +- (ftnlen)1, (ftnlen)1); ++ lda, &b[b_offset], ldb, &work[1], m); + } + + } else if (left && notran) { +@@ -9382,8 +9369,7 @@ f_rook.f"> */ + } + stprfb_("L", "N", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, & +- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, ( +- ftnlen)1, (ftnlen)1); ++ b[b_offset], ldb, &work[1], &ib); + } + + } else if (right && tran) { +@@ -9404,8 +9390,7 @@ f_rook.f"> */ + } + stprfb_("R", "T", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1], +- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1, +- (ftnlen)1, (ftnlen)1); ++ lda, &b[b_offset], ldb, &work[1], m); + } + + } +@@ -9618,8 +9603,7 @@ f"> */ + extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), stprfb_( + char *, char *, char *, char *, integer *, integer *, integer *, + integer *, real *, integer *, real *, integer *, real *, integer * +- , real *, integer *, real *, integer *, ftnlen, ftnlen, ftnlen, +- ftnlen), stpqrt2_(integer *, integer *, integer *, real *, ++ , real *, integer *, real *, integer *), stpqrt2_(integer *, integer *, integer *, real *, + integer *, real *, integer *, real *, integer *, integer *); + + +@@ -9712,7 +9696,7 @@ f"> */ + stprfb_("L", "T", "F", "C", &mb, &i__3, &ib, &lb, &b[i__ * b_dim1 + + 1], ldb, &t[i__ * t_dim1 + 1], ldt, &a[i__ + (i__ + ib) + * a_dim1], lda, &b[(i__ + ib) * b_dim1 + 1], ldb, &work[1] +- , &ib, (ftnlen)1, (ftnlen)1, (ftnlen)1, (ftnlen)1); ++ , &ib); + } + } + return 0; +@@ -12502,8 +12486,7 @@ f_rook.f"> */ + extern /* Subroutine */ int ztprfb_(char *, char *, char *, char *, + integer *, integer *, integer *, integer *, doublecomplex *, + integer *, doublecomplex *, integer *, doublecomplex *, integer *, +- doublecomplex *, integer *, doublecomplex *, integer *, ftnlen, +- ftnlen, ftnlen, ftnlen); ++ doublecomplex *, integer *, doublecomplex *, integer *); + + + /* -- LAPACK computational routine -- */ +@@ -12613,8 +12596,7 @@ f_rook.f"> */ + } + ztprfb_("L", "C", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, & +- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, ( +- ftnlen)1, (ftnlen)1); ++ b[b_offset], ldb, &work[1], &ib); + } + + } else if (right && notran) { +@@ -12635,8 +12617,7 @@ f_rook.f"> */ + } + ztprfb_("R", "N", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1], +- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1, +- (ftnlen)1, (ftnlen)1); ++ lda, &b[b_offset], ldb, &work[1], m); + } + + } else if (left && notran) { +@@ -12657,8 +12638,7 @@ f_rook.f"> */ + } + ztprfb_("L", "N", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, & +- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, ( +- ftnlen)1, (ftnlen)1); ++ b[b_offset], ldb, &work[1], &ib); + } + + } else if (right && tran) { +@@ -12679,8 +12659,7 @@ f_rook.f"> */ + } + ztprfb_("R", "C", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1] + , ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1], +- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1, +- (ftnlen)1, (ftnlen)1); ++ lda, &b[b_offset], ldb, &work[1], m); + } + + } +@@ -12894,7 +12873,7 @@ f"> */ + char *, char *, char *, char *, integer *, integer *, integer *, + integer *, doublecomplex *, integer *, doublecomplex *, integer *, + doublecomplex *, integer *, doublecomplex *, integer *, +- doublecomplex *, integer *, ftnlen, ftnlen, ftnlen, ftnlen), ++ doublecomplex *, integer *), + ztpqrt2_(integer *, integer *, integer *, doublecomplex *, + integer *, doublecomplex *, integer *, doublecomplex *, integer *, + integer *); +@@ -12989,7 +12968,7 @@ f"> */ + ztprfb_("L", "C", "F", "C", &mb, &i__3, &ib, &lb, &b[i__ * b_dim1 + + 1], ldb, &t[i__ * t_dim1 + 1], ldt, &a[i__ + (i__ + ib) + * a_dim1], lda, &b[(i__ + ib) * b_dim1 + 1], ldb, &work[1] +- , &ib, (ftnlen)1, (ftnlen)1, (ftnlen)1, (ftnlen)1); ++ , &ib); + } + } + return 0; +@@ -12998,3 +12977,10 @@ f"> */ + + } /* ztpqrt_ */ + ++ ++typedef struct { float real, imag; } npy_complex64; ++typedef struct { double real, imag; } npy_complex128; ++int sorcsd_(char *jobu1, char *jobu2, char *jobv1t, char *jobv2t, char *trans, char *signs, int *m, int *p, int *q, float *x11, int *ldx11, float *x12, int *ldx12, float *x21, int *ldx21, float *x22, int *ldx22, float *theta, float *u1, int *ldu1, float *u2, int *ldu2, float *v1t, int *ldv1t, float *v2t, int *ldv2t, float *work, int *lwork, int *iwork, int *info){ return 0; } ++int dorcsd_(char *jobu1, char *jobu2, char *jobv1t, char *jobv2t, char *trans, char *signs, int *m, int *p, int *q, double *x11, int *ldx11, double *x12, int *ldx12, double *x21, int *ldx21, double *x22, int *ldx22, double *theta, double *u1, int *ldu1, double *u2, int *ldu2, double *v1t, int *ldv1t, double *v2t, int *ldv2t, double *work, int *lwork, int *iwork, int *info){ return 0; } ++int zuncsd_(char *jobu1, char *jobu2, char *jobv1t, char *jobv2t, char *trans, char *signs, int *m, int *p, int *q, npy_complex128 *x11, int *ldx11, npy_complex128 *x12, int *ldx12, npy_complex128 *x21, int *ldx21, npy_complex128 *x22, int *ldx22, double *theta, npy_complex128 *u1, int *ldu1, npy_complex128 *u2, int *ldu2, npy_complex128 *v1t, int *ldv1t, npy_complex128 *v2t, int *ldv2t, npy_complex128 *work, int *lwork, double *rwork, int *lrwork, int *iwork, int *info){ return 0; } ++int cuncsd_(char *jobu1, char *jobu2, char *jobv1t, char *jobv2t, char *trans, char *signs, int *m, int *p, int *q, npy_complex64 *x11, int *ldx11, npy_complex64 *x12, int *ldx12, npy_complex64 *x21, int *ldx21, npy_complex64 *x22, int *ldx22, float *theta, npy_complex64 *u1, int *ldu1, npy_complex64 *u2, int *ldu2, npy_complex64 *v1t, int *ldv1t, npy_complex64 *v2t, int *ldv2t, npy_complex64 *work, int *lwork, float *rwork, int *lrwork, int *iwork, int *info){ return 0; } diff --git a/packages/scipy/patches/fix-typo-flapack-pyf.patch b/packages/scipy/patches/fix-typo-flapack-pyf.patch deleted file mode 100644 index 027ec897f..000000000 --- a/packages/scipy/patches/fix-typo-flapack-pyf.patch +++ /dev/null @@ -1,20 +0,0 @@ -commit 768251cd14ccbf467a8725e5476e35fb2735ee4a -Author: Warren Weckesser -Date: Fri Mar 9 00:32:22 2018 -0500 - - BUG: linalg: Fixed typo in flapack.pyf.src. - Available in scipy 1.0.1 (https://github.com/scipy/scipy/pull/8530) - -diff --git a/scipy/linalg/flapack.pyf.src b/scipy/linalg/flapack.pyf.src -index e6c8c1840..54cf7c4b1 100644 ---- a/scipy/linalg/flapack.pyf.src -+++ b/scipy/linalg/flapack.pyf.src -@@ -1748,7 +1748,7 @@ end subroutine gels_lwork - callprotoargument int*,int*,int*,*,int*,*,int*,int*,*,int*,*,int*,*,int* - - integer intent(in) :: m -- integer intent(in)):: n -+ integer intent(in) :: n - integer intent(hide) :: maxmn = MAX(m,n) - intent(hide) :: a - diff --git a/packages/scipy/patches/force_malloc.patch b/packages/scipy/patches/force_malloc.patch deleted file mode 100644 index b4e3e5f54..000000000 --- a/packages/scipy/patches/force_malloc.patch +++ /dev/null @@ -1,94 +0,0 @@ -commit 7a5b003922134abd01ae33b0a3e84d006673e9c6 -Author: Roman Yurchak -Date: Mon Oct 8 12:13:55 2018 +0200 - - Workaround for malloc issues - - This aims to avoid the "invalid call target: $_malloc" issues - - - fixes scipy/optimize/zeros.c - - skips scipy/integrate/dop.pyf - - skips scipy/optimize/cobyla - -diff --git a/scipy/integrate/setup.py b/scipy/integrate/setup.py -index 2be454c70..0545dc759 100755 ---- a/scipy/integrate/setup.py -+++ b/scipy/integrate/setup.py -@@ -67,10 +67,10 @@ def configuration(parent_package='',top_path=None): - # **lapack_opt) - - # dop -- config.add_extension('_dop', -- sources=['dop.pyf'], -- libraries=['dop'], -- depends=dop_src) -+ #config.add_extension('_dop', -+ # sources=['dop.pyf'], -+ # libraries=['dop'], -+ # depends=dop_src) - - config.add_extension('_test_multivariate', - sources=quadpack_test_src) -diff --git a/scipy/optimize/__init__.py b/scipy/optimize/__init__.py -index 17ba78371..5deca7498 100644 ---- a/scipy/optimize/__init__.py -+++ b/scipy/optimize/__init__.py -@@ -236,7 +236,7 @@ from .minpack import * - from .zeros import * - from .lbfgsb import fmin_l_bfgs_b, LbfgsInvHessProduct - from .tnc import fmin_tnc --from .cobyla import fmin_cobyla -+#from .cobyla import fmin_cobyla - from .nonlin import * - from .slsqp import fmin_slsqp - from .nnls import nnls -diff --git a/scipy/optimize/_minimize.py b/scipy/optimize/_minimize.py -index 259546035..8b0b6960b 100644 ---- a/scipy/optimize/_minimize.py -+++ b/scipy/optimize/_minimize.py -@@ -29,7 +29,8 @@ from ._trustregion_ncg import _minimize_trust_ncg - # constrained minimization - from .lbfgsb import _minimize_lbfgsb - from .tnc import _minimize_tnc --from .cobyla import _minimize_cobyla -+#from .cobyla import _minimize_cobyla -+_minimize_cobyla = None - from .slsqp import _minimize_slsqp - - -diff --git a/scipy/optimize/setup.py b/scipy/optimize/setup.py -index 7d2b987cb..1861e7563 100755 ---- a/scipy/optimize/setup.py -+++ b/scipy/optimize/setup.py -@@ -50,11 +50,11 @@ def configuration(parent_package='',top_path=None): - depends=[join('tnc','tnc.h')], - **numpy_nodepr_api) - -- config.add_extension('_cobyla', -- sources=[join('cobyla',x) for x in ['cobyla.pyf', -- 'cobyla2.f', -- 'trstlp.f']], -- **numpy_nodepr_api) -+ #config.add_extension('_cobyla', -+ # sources=[join('cobyla',x) for x in ['cobyla.pyf', -+ # 'cobyla2.f', -+ # 'trstlp.f']], -+ # **numpy_nodepr_api) - - sources = ['minpack2.pyf', 'dcsrch.f', 'dcstep.f'] - config.add_extension('minpack2', -diff --git a/scipy/optimize/zeros.c b/scipy/optimize/zeros.c -index e557f37cb..d450b3ed4 100644 ---- a/scipy/optimize/zeros.c -+++ b/scipy/optimize/zeros.c -@@ -193,6 +193,10 @@ PyObject *PyInit__zeros(void) - { - PyObject *m; - -+ volatile long x; -+ x = (long)malloc(0); -+ free((void*)x); -+ - m = PyModule_Create(&moduledef); - - return m; diff --git a/packages/scipy/patches/gemm_-no-const.patch b/packages/scipy/patches/gemm_-no-const.patch new file mode 100644 index 000000000..8d84b5df6 --- /dev/null +++ b/packages/scipy/patches/gemm_-no-const.patch @@ -0,0 +1,87 @@ +From 549ab1f7916e16222bdfc67a46f7a7b9b2125265 Mon Sep 17 00:00:00 2001 +From: Hood Chatham +Date: Sat, 18 Dec 2021 11:41:15 -0800 +Subject: [PATCH] gemm_ no const + +cgemm, dgemm, sgemm, and zgemm are declared with `const` in slu_cdefs.h, but +other places don't have the cosnt causing compile errors. +This patch drops the consts and fixes the problem. + +--- + scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h | 6 +++--- + scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h | 6 +++--- + scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h | 6 +++--- + scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h | 6 +++--- + 4 files changed, 12 insertions(+), 12 deletions(-) + +diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h +index 346f9af0a..8af19888f 100644 +--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h ++++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h +@@ -272,9 +272,9 @@ extern void ccheck_tempv(int, complex *); + + /*! \brief BLAS */ + +-extern int cgemm_(const char*, const char*, const int*, const int*, const int*, +- const complex*, const complex*, const int*, const complex*, +- const int*, const complex*, complex*, const int*); ++extern int cgemm_( char*, char*, int*, int*, int*, ++ complex*, complex*, int*, complex*, ++ int*, complex*, complex*, int*); + extern int ctrsv_(char*, char*, char*, int*, complex*, int*, + complex*, int*); + extern int ctrsm_(char*, char*, char*, char*, int*, int*, +diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h +index 934cd677a..33e869fb7 100644 +--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h ++++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h +@@ -269,9 +269,9 @@ extern void dcheck_tempv(int, double *); + + /*! \brief BLAS */ + +-extern int dgemm_(const char*, const char*, const int*, const int*, const int*, +- const double*, const double*, const int*, const double*, +- const int*, const double*, double*, const int*); ++extern int dgemm_( char*, char*, int*, int*, int*, ++ double*, double*, int*, double*, ++ int*, double*, double*, int*); + extern int dtrsv_(char*, char*, char*, int*, double*, int*, + double*, int*); + extern int dtrsm_(char*, char*, char*, char*, int*, int*, +diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h +index 1b6db977e..fee4bc1d6 100644 +--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h ++++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h +@@ -269,9 +269,9 @@ extern void scheck_tempv(int, float *); + + /*! \brief BLAS */ + +-extern int sgemm_(const char*, const char*, const int*, const int*, const int*, +- const float*, const float*, const int*, const float*, +- const int*, const float*, float*, const int*); ++extern int sgemm_( char*, char*, int*, int*, int*, ++ float*, float*, int*, float*, ++ int*, float*, float*, int*); + extern int strsv_(char*, char*, char*, int*, float*, int*, + float*, int*); + extern int strsm_(char*, char*, char*, char*, int*, int*, +diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h +index abb7d937e..6c572ff2b 100644 +--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h ++++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h +@@ -272,9 +272,9 @@ extern void zcheck_tempv(int, doublecomplex *); + + /*! \brief BLAS */ + +-extern int zgemm_(const char*, const char*, const int*, const int*, const int*, +- const doublecomplex*, const doublecomplex*, const int*, const doublecomplex*, +- const int*, const doublecomplex*, doublecomplex*, const int*); ++extern int zgemm_( char*, char*, int*, int*, int*, ++ doublecomplex*, doublecomplex*, int*, doublecomplex*, ++ int*, doublecomplex*, doublecomplex*, int*); + extern int ztrsv_(char*, char*, char*, int*, doublecomplex*, int*, + doublecomplex*, int*); + extern int ztrsm_(char*, char*, char*, char*, int*, int*, +-- +2.25.1 + diff --git a/packages/scipy/patches/make-int-return-values.patch b/packages/scipy/patches/make-int-return-values.patch index b07971dc8..3c6990870 100644 --- a/packages/scipy/patches/make-int-return-values.patch +++ b/packages/scipy/patches/make-int-return-values.patch @@ -12,484 +12,92 @@ signatures compared to what has been done in CLAPACK. f2py is patched in numpy to make subroutines return int. -emscripten is very strict about void vs int returns and function signatures, so we change everything to -return int from subroutines, and signatures are altered to be consistent. +emscripten is very strict about void vs int returns and function signatures, so +we change everything to return int from subroutines, and signatures are altered +to be consistent. -diff --git a/scipy/_build_utils/_fortran.py b/scipy/_build_utils/_fortran.py -index 93ca908..038855b 100644 ---- a/scipy/_build_utils/_fortran.py -+++ b/scipy/_build_utils/_fortran.py -@@ -79,7 +79,6 @@ def get_g77_abi_wrappers(info): - else: - wrapper_sources += [ - os.path.join(path, 'src', 'wrap_dummy_g77_abi.f'), -- os.path.join(path, 'src', 'wrap_dummy_accelerate.f'), - ] - return wrapper_sources - -diff --git a/scipy/cluster/cluster_blas.h b/scipy/cluster/cluster_blas.h -index 865e410..d5479e0 100644 ---- a/scipy/cluster/cluster_blas.h -+++ b/scipy/cluster/cluster_blas.h -@@ -15,6 +15,8 @@ - #define F_FUNC(f,F) f##_ - #endif - #endif -+extern int dgemm_(char *transa, char *transb, int *m, int *n, int *k, double *alpha, double *a, int *lda, double *b, int *ldb, double *beta, double *c, int *ldc); -+extern int sgemm_(char *transa, char *transb, int *m, int *n, int *k, float *alpha, float *a, int *lda, float *b, int *ldb, float *beta, float *c, int *ldc); - - #define f_sgemm F_FUNC(sgemm,SGEMM) - #define f_dgemm F_FUNC(dgemm,DGEMM) -diff --git a/scipy/interpolate/blas_defs.h b/scipy/interpolate/blas_defs.h -index 0f95237..5a7adb7 100644 ---- a/scipy/interpolate/blas_defs.h -+++ b/scipy/interpolate/blas_defs.h -@@ -16,4 +16,5 @@ - #endif - #endif - -+extern int dgeev_(char *jobvl, char *jobvr, int *n, double *a, int *lda, double *wr, double *wi, double *vl, int *ldvl, double *vr, int *ldvr, double *work, int *lwork, int *info); - #define c_dgeev F_FUNC(dgeev,DGEEV) -diff --git a/scipy/linalg/_cython_wrapper_generators.py b/scipy/linalg/_cython_wrapper_generators.py -index 62be001..b62c31a 100644 ---- a/scipy/linalg/_cython_wrapper_generators.py -+++ b/scipy/linalg/_cython_wrapper_generators.py -@@ -3,8 +3,13 @@ Code generator script to make the Cython BLAS and LAPACK wrappers - from the files "cython_blas_signatures.txt" and - "cython_lapack_signatures.txt" which contain the signatures for - all the BLAS/LAPACK routines that should be included in the wrappers. -+ -+# NB: this version is updated for CLAPACK. It makes the assumption (as does -+# everything else in scipy, that CLAPACK long int is the same size as int ) - """ - -+ -+ - from operator import itemgetter - - fortran_types = {'int': 'integer', -@@ -15,7 +20,9 @@ fortran_types = {'int': 'integer', - 'char': 'character', - 'bint': 'logical'} - --c_types = {'int': 'int', -+c_types = {'void':'int', -+ 'VOID':'int', -+ 'int': 'int', - 'c': 'npy_complex64', - 'd': 'double', - 's': 'float', -@@ -31,17 +38,29 @@ c_types = {'int': 'int', - 'zselect1': '_zselect1', - 'zselect2': '_zselect2'} - -+py_type_replacements={'npy_complex64':'float complex', -+ 'npy_complex128':'double complex'} -+ - - def arg_names_and_types(args): - return zip(*[arg.split(' *') for arg in args.split(', ')]) - - pyx_func_template = """ -+ - cdef extern from "{header_name}": -- void _fortran_{name} "F_FUNC({name}wrp, {upname}WRP)"({ret_type} *out, {fort_args}) nogil --cdef {ret_type} {name}({args}) nogil: -- cdef {ret_type} out -- _fortran_{name}(&out, {argnames}) -- return out -+ {c_ret_type} _fortran_{name} "F_FUNC({name}, {upname})"({args}) nogil -+cdef {py_ret_type} {name}({py_args}) nogil: -+ return _fortran_{name}({argnames}) -+""" -+ -+# CLAPACK returns complex by pointer -+pyx_func_template_complex = """ -+cdef extern from "{header_name}": -+ void _fortran_{name} "F_FUNC({name}, {upname})"({c_ret_type} *ret_val,{args}) nogil -+cdef {py_ret_type} {name}({py_args}) nogil: -+ cdef {py_ret_type} ret_val -+ _fortran_{name}(<{c_ret_type}*>&ret_val,{argnames}) -+ return ret_val - """ - - npy_types = {'c': 'npy_complex64', 'z': 'npy_complex128', -@@ -50,57 +69,114 @@ npy_types = {'c': 'npy_complex64', 'z': 'npy_complex128', - 'sselect2': '_sselect2', 'sselect3': '_sselect3', - 'zselect1': '_zselect1', 'zselect2': '_zselect2'} - -+# methods that use char* need a wrapper building, -+# because CLAPACK uses null terminated strings -+# and f2c uses char* + extra length args -+# the wrapper will be called in preprocessing of -+# f2c generated code -+ -+def needs_wrapper(argtypes): -+ for c in argtypes: -+ if c=='char': -+ return True -+ return False - - def arg_casts(arg): - if arg in ['npy_complex64', 'npy_complex128', '_cselect1', '_cselect2', - '_dselect2', '_dselect3', '_sselect2', '_sselect3', -- '_zselect1', '_zselect2']: -+ '_zselect1', '_zselect2','f2c_complex','f2c_doublecomplex','integer','real','doublereal','logical']: - return '<{0}*>'.format(arg) - return '' +diff --git a/scipy/_build_utils/src/wrap_dummy_g77_abi.f b/scipy/_build_utils/src/wrap_dummy_g77_abi.f +index caf99ac63..73cdebd96 100644 +--- a/scipy/_build_utils/src/wrap_dummy_g77_abi.f ++++ b/scipy/_build_utils/src/wrap_dummy_g77_abi.f +@@ -6,14 +6,6 @@ + WCDOTC = CDOTC( N, CX, INCX, CY, INCY ) + END FUNCTION +- COMPLEX FUNCTION WCDOTU( N, CX, INCX, CY, INCY ) +- INTEGER INCX, INCY, N +- COMPLEX CX(*), CY(*) +- EXTERNAL CDOTU +- COMPLEX CDOTU +- WCDOTU = CDOTU( N, CX, INCX, CY, INCY ) +- END FUNCTION - - def pyx_decl_func(name, ret_type, args, header_name): -+ # clapack returns double for single precision functions (why?) -+ if ret_type=='s': -+ ret_type='d' -+ -+ c_ret_type=c_types[ret_type] -+ if ret_type=='z': -+ py_ret_type='double complex' -+ elif ret_type=='c': -+ py_ret_type='float complex' -+ else: -+ py_ret_type=c_ret_type - argtypes, argnames = arg_names_and_types(args) -- # Fix the case where one of the arguments has the same name as the -- # abbreviation for the argument type. -- # Otherwise the variable passed as an argument is considered overwrites -- # the previous typedef and Cython compilation fails. -- if ret_type in argnames: -- argnames = [n if n != ret_type else ret_type + '_' for n in argnames] -- argnames = [n if n not in ['lambda', 'in'] else n + '_' -- for n in argnames] -- args = ', '.join([' *'.join([n, t]) -- for n, t in zip(argtypes, argnames)]) -- argtypes = [npy_types.get(t, t) for t in argtypes] -- fort_args = ', '.join([' *'.join([n, t]) -+ argtypes = [c_types.get(t, t) for t in argtypes] -+ pyargtypes = [py_type_replacements.get(t, t) for t in argtypes] -+ py_args = ', '.join([' *'.join([n, t]) -+ for n, t in zip(pyargtypes, argnames)]) -+ args = ', '.join([' *'.join([n, t]) - for n, t in zip(argtypes, argnames)]) -+ unwrapper_argnames=",".join(argnames) - argnames = [arg_casts(t) + n for n, t in zip(argnames, argtypes)] - argnames = ', '.join(argnames) -- c_ret_type = c_types[ret_type] - args = args.replace('lambda', 'lambda_') -- return pyx_func_template.format(name=name, upname=name.upper(), args=args, -- fort_args=fort_args, ret_type=ret_type, -- c_ret_type=c_ret_type, argnames=argnames, -+ # CLAPACK handles strings c style i.e. by null termination -+ # these unwrappers remove the fortran style length arguments -+ # they are for calling from f2c only -+ # I think normally they'd be in the lapack already, but they aren't in -+ # clapack. They are made public for use in f2c generated code -+ unwrapper="" -+ if needs_wrapper(argtypes): -+ extra_args=args -+ num_extra=0 -+ for c in argtypes: -+ if c=='char': -+ num_extra+=1 -+ extra_args+=", int ignore_%d"%(num_extra) -+ unwrapper=pyx_clapack_unwrapper_template.format(name=name,extra_args=extra_args,argnames=unwrapper_argnames,args=args,c_ret_type=c_ret_type) -+ if ret_type=='z' or ret_type=='c': -+ return unwrapper+pyx_func_template_complex.format(name=name,upname=name.upper(),args=args, -+ ret_type=c_ret_type,c_ret_type=c_ret_type,py_ret_type=py_ret_type, -+ argnames=argnames,header_name=header_name,py_args=py_args) -+ else: -+ return unwrapper+pyx_func_template.format(name=name, upname=name.upper(), args=args, -+ ret_type=c_ret_type,c_ret_type=c_ret_type,py_args=py_args, -+ argnames=argnames,py_ret_type=py_ret_type, - header_name=header_name) + DOUBLE COMPLEX FUNCTION WZDOTC( N, CX, INCX, CY, INCY ) + INTEGER INCX, INCY, N + DOUBLE COMPLEX CX(*), CY(*) +@@ -22,14 +14,6 @@ + WZDOTC = ZDOTC( N, CX, INCX, CY, INCY ) + END FUNCTION - pyx_sub_template = """cdef extern from "{header_name}": -- void _fortran_{name} "F_FUNC({name},{upname})"({fort_args}) nogil --cdef void {name}({args}) nogil: -+ int _fortran_{name} "F_FUNC({name},{upname})"({args}) nogil -+cdef int {name}({py_args}) nogil: - _fortran_{name}({argnames}) - """ +- DOUBLE COMPLEX FUNCTION WZDOTU( N, CX, INCX, CY, INCY ) +- INTEGER INCX, INCY, N +- DOUBLE COMPLEX CX(*), CY(*) +- EXTERNAL ZDOTU +- DOUBLE COMPLEX ZDOTU +- WZDOTU = ZDOTU( N, CX, INCX, CY, INCY ) +- END FUNCTION +- + COMPLEX FUNCTION WCLADIV( X, Y ) + COMPLEX X, Y + EXTERNAL CLADIV +diff --git a/scipy/integrate/_odepackmodule.c b/scipy/integrate/_odepackmodule.c +index b296e6e30..f5029bee9 100644 +--- a/scipy/integrate/_odepackmodule.c ++++ b/scipy/integrate/_odepackmodule.c +@@ -158,13 +158,13 @@ typedef void lsoda_f_t(F_INT *n, double *t, double *y, double *ydot); + typedef int lsoda_jac_t(F_INT *n, double *t, double *y, F_INT *ml, F_INT *mu, + double *pd, F_INT *nrowpd); -+pyx_clapack_unwrapper_template= """ -+ -+cdef extern {c_ret_type} {name}_({args}) -+ -+cdef public {c_ret_type} w{name}_({extra_args}): -+ return {name}_({argnames}); -+""" +-void LSODA(lsoda_f_t *f, F_INT *neq, double *y, double *t, double *tout, F_INT *itol, ++int LSODA(lsoda_f_t *f, F_INT *neq, double *y, double *t, double *tout, F_INT *itol, + double *rtol, double *atol, F_INT *itask, F_INT *istate, F_INT *iopt, + double *rwork, F_INT *lrw, F_INT *iwork, F_INT *liw, lsoda_jac_t *jac, + F_INT *jt); - def pyx_decl_sub(name, args, header_name): - argtypes, argnames = arg_names_and_types(args) -- argtypes = [npy_types.get(t, t) for t in argtypes] -+ argtypes = [c_types.get(t, t) for t in argtypes] - argnames = [n if n not in ['lambda', 'in'] else n + '_' for n in argnames] -- fort_args = ', '.join([' *'.join([n, t]) -+ pyargtypes = [py_type_replacements.get(t, t) for t in argtypes] -+ py_args = ', '.join([' *'.join([n, t]) -+ for n, t in zip(pyargtypes, argnames)]) -+ args = ', '.join([' *'.join([n, t]) - for n, t in zip(argtypes, argnames)]) -+ unwrapper_argnames=",".join(argnames) - argnames = [arg_casts(t) + n for n, t in zip(argnames, argtypes)] - argnames = ', '.join(argnames) - args = args.replace('*lambda,', '*lambda_,').replace('*in,', '*in_,') -- return pyx_sub_template.format(name=name, upname=name.upper(), -- args=args, fort_args=fort_args, -+ # CLAPACK handles strings c style i.e. by null termination -+ # these unwrappers remove the fortran style length arguments -+ # normally the lapack would be a fortran library so it would need -+ # them, but not CLAPACK -+ unwrapper="" -+ if needs_wrapper(argtypes): -+ extra_args=args -+ num_extra=0 -+ for c in argtypes: -+ if c=='char': -+ num_extra+=1 -+ extra_args+=", int ignore_%d"%(num_extra) -+ unwrapper=pyx_clapack_unwrapper_template.format(name=name,extra_args=extra_args,argnames=unwrapper_argnames,args=args,c_ret_type='int') -+ return unwrapper+ pyx_sub_template.format(name=name, upname=name.upper(), -+ args=args, py_args=py_args, - argnames=argnames, header_name=header_name) + /* +-void ode_function(int *n, double *t, double *y, double *ydot) ++int ode_function(int *n, double *t, double *y, double *ydot) + { + ydot[0] = -0.04*y[0] + 1e4*y[1]*y[2]; + ydot[2] = 3e7*y[1]*y[1]; +@@ -173,7 +173,7 @@ void ode_function(int *n, double *t, double *y, double *ydot) + } + */ - blas_pyx_preamble = '''# cython: boundscheck = False -@@ -190,14 +266,14 @@ from numpy cimport npy_complex64, npy_complex128 - cdef extern from "_lapack_subroutines.h": - # Function pointer type declarations for - # gees and gges families of functions. -- ctypedef bint _cselect1(npy_complex64*) -- ctypedef bint _cselect2(npy_complex64*, npy_complex64*) -- ctypedef bint _dselect2(d*, d*) -- ctypedef bint _dselect3(d*, d*, d*) -- ctypedef bint _sselect2(s*, s*) -- ctypedef bint _sselect3(s*, s*, s*) -- ctypedef bint _zselect1(npy_complex128*) -- ctypedef bint _zselect2(npy_complex128*, npy_complex128*) -+ ctypedef int _cselect1(npy_complex64*) -+ ctypedef int _cselect2(npy_complex64*, npy_complex64*) -+ ctypedef int _dselect2(d*, d*) -+ ctypedef int _dselect3(d*, d*, d*) -+ ctypedef int _sselect2(s*, s*) -+ ctypedef int _sselect3(s*, s*, s*) -+ ctypedef int _zselect1(npy_complex128*) -+ ctypedef int _zselect2(npy_complex128*, npy_complex128*) - - ''' - -@@ -210,7 +286,7 @@ blas_py_wrappers = """ - - # Python-accessible wrappers for testing: - --cdef inline bint _is_contiguous(double[:,:] a, int axis) nogil: -+cdef inline int _is_contiguous(double[:,:] a, int axis) nogil: - return (a.strides[axis] == sizeof(a[0,0]) or a.shape[axis] == 1) - - cpdef float complex _test_cdotc(float complex[:] cx, float complex[:] cy) nogil: -@@ -452,6 +528,16 @@ pxd_template = """cdef {ret_type} {name}({args}) nogil - - def pxd_decl(name, ret_type, args): - args = args.replace('lambda', 'lambda_').replace('*in,', '*in_,') -+ -+ argtypes, argnames = arg_names_and_types(args) -+ argtypes = [c_types.get(t, t) for t in argtypes] -+ argtypes = [py_type_replacements.get(t, t) for t in argtypes] -+ args = ', '.join([' *'.join([n, t]) -+ for n, t in zip(argtypes, argnames)]) -+ if ret_type=='s': -+ ret_type='d' -+ ret_type=c_types[ret_type] -+ ret_type=py_type_replacements.get(ret_type,ret_type) - return pxd_template.format(name=name, ret_type=ret_type, args=args) - - blas_pxd_preamble = """# Within scipy, these wrappers can be used via relative or absolute cimport. -@@ -470,6 +556,7 @@ ctypedef double d - ctypedef float complex c - ctypedef double complex z - -+from numpy cimport npy_complex64, npy_complex128 - """ - - -@@ -488,27 +575,43 @@ lapack_pxd_preamble = """# Within scipy, these wrappers can be used via relative - # these wrappers should not be used. - # The original libraries should be linked directly. - -+ - ctypedef float s - ctypedef double d - ctypedef float complex c - ctypedef double complex z - -+from numpy cimport npy_complex64, npy_complex128 -+ - # Function pointer type declarations for - # gees and gges families of functions. --ctypedef bint cselect1(c*) --ctypedef bint cselect2(c*, c*) --ctypedef bint dselect2(d*, d*) --ctypedef bint dselect3(d*, d*, d*) --ctypedef bint sselect2(s*, s*) --ctypedef bint sselect3(s*, s*, s*) --ctypedef bint zselect1(z*) --ctypedef bint zselect2(z*, z*) -+#ctypedef int cselect1(npy_complex64*) -+#ctypedef int cselect2(npy_complex64*, npy_complex64*) -+#ctypedef int dselect2(double*, double*) -+#ctypedef int dselect3(double*,double*,double*) -+#ctypedef int sselect2(float*,float*) -+#ctypedef int sselect3(float*,float*,float*) -+#ctypedef int zselect1(npy_complex128*) -+#ctypedef int zselect2(npy_complex128*,npy_complex128*,npy_complex128*) -+ -+cdef extern from "_lapack_subroutines.h": -+ # Function pointer type declarations for -+ # gees and gges families of functions. -+ ctypedef int _cselect1(npy_complex64*) -+ ctypedef int _cselect2(npy_complex64*, npy_complex64*) -+ ctypedef int _dselect2(d*, d*) -+ ctypedef int _dselect3(d*, d*, d*) -+ ctypedef int _sselect2(s*, s*) -+ ctypedef int _sselect3(s*, s*, s*) -+ ctypedef int _zselect1(npy_complex128*) -+ ctypedef int _zselect2(npy_complex128*, npy_complex128*) -+ - - """ - - - def generate_lapack_pxd(all_sigs): -- return lapack_pxd_preamble + '\n'.join(pxd_decl(*sig) for sig in all_sigs) -+ return lapack_pxd_preamble + '\n'.join(pxd_decl(*sig) for sig in all_sigs) - - fortran_template = """ subroutine {name}wrp(ret, {argnames}) - external {wrapper} -@@ -535,12 +638,14 @@ def process_fortran_name(name, funcname): - - - def fort_subroutine_wrapper(name, ret_type, args): -- if name[0] in ['c', 's'] or name in ['zladiv', 'zdotu', 'zdotc']: -+ if ret_type=='s': -+ ret_type='d' -+ types, names = arg_names_and_types(args) -+ argnames = ', '.join(names) -+ if needs_wrapper(types): - wrapper = 'w' + name - else: - wrapper = name -- types, names = arg_names_and_types(args) -- argnames = ', '.join(names) - - names = [process_fortran_name(n, name) for n in names] - argdecls = '\n '.join('{0} {1}'.format(fortran_types[t], n) -@@ -554,21 +659,38 @@ def generate_fortran(func_sigs): - return "\n".join(fort_subroutine_wrapper(*sig) for sig in func_sigs) - - --def make_c_args(args): -+def make_c_args(args,*,add_char_length_args=False): - types, names = arg_names_and_types(args) -+ names=list(names) - types = [c_types[arg] for arg in types] -+ if add_char_length_args: -+ new_args=0 -+ for c in types: -+ if c=='char': -+ new_args+=1 -+ for c in range(new_args): -+ types.append('ftnlen') -+ names.append('ignore_%d'%c) - return ', '.join('{0} *{1}'.format(t, n) for t, n in zip(types, names)) - --c_func_template = "void F_FUNC({name}wrp, {upname}WRP)({return_type} *ret, {args});\n" -+c_func_template = "{return_type} F_FUNC({name}, {upname})( {args});\n" -+c_func_template_complex = "void F_FUNC({name}, {upname})({return_type} *ret, {args});\n" - - - def c_func_decl(name, return_type, args): -- args = make_c_args(args) -- return_type = c_types[return_type] -- return c_func_template.format(name=name, upname=name.upper(), -+ if return_type=='s': -+ return_type='d' -+ args = make_c_args(args,add_char_length_args=False) -+ if return_type=='z' or return_type=='c': -+ return_type = c_types[return_type] -+ return c_func_template_complex.format(name=name, upname=name.upper(), -+ return_type=return_type, args=args) -+ else: -+ return_type = c_types[return_type] -+ return c_func_template.format(name=name, upname=name.upper(), - return_type=return_type, args=args) - --c_sub_template = "void F_FUNC({name},{upname})({args});\n" -+c_sub_template = "int F_FUNC({name},{upname})({args});\n" - - - def c_sub_decl(name, return_type, args): -@@ -579,6 +701,7 @@ c_preamble = """#ifndef SCIPY_LINALG_{lib}_FORTRAN_WRAPPERS_H - #define SCIPY_LINALG_{lib}_FORTRAN_WRAPPERS_H - #include "fortran_defs.h" - #include "numpy/arrayobject.h" -+#include "f2c.h" - """ - - lapack_decls = """ -@@ -630,6 +753,15 @@ def filter_lines(ls): - all_sigs = list(sorted(func_sigs + sub_sigs, key=itemgetter(0))) - return func_sigs, sub_sigs, all_sigs - -+def generate_wrapper_list(sigs): -+ wrappers="" -+ for name,rt,args in sigs: -+ anames,atypes=arg_names_and_types(args) -+ if "char" in atypes: -+ wrappers+=name+":w"+name+",\n" -+ return wrappers -+ -+ - - def make_all(blas_signature_file="cython_blas_signatures.txt", - lapack_signature_file="cython_lapack_signatures.txt", -@@ -682,6 +814,10 @@ def make_all(blas_signature_file="cython_blas_signatures.txt", - with open(lapack_header_name, 'w') as f: - f.write(ccomment) - f.write(lapack_c_header) -+ wrapper_list = generate_wrapper_list([*lapack_sigs[2]]+[*blas_sigs[2]]) -+ with open("wrapper_list.txt",'w') as f: -+ f.write(ccomment) -+ f.write(wrapper_list) - - if __name__ == '__main__': - make_all() -diff --git a/scipy/linalg/cython_lapack_signatures.txt b/scipy/linalg/cython_lapack_signatures.txt -index 0455995..34d0782 100644 ---- a/scipy/linalg/cython_lapack_signatures.txt -+++ b/scipy/linalg/cython_lapack_signatures.txt -@@ -1296,3 +1296,4 @@ void zunmrz(char *side, char *trans, int *m, int *n, int *k, int *l, z *a, int * - void zunmtr(char *side, char *uplo, char *trans, int *m, int *n, z *a, int *lda, z *tau, z *c, int *ldc, z *work, int *lwork, int *info) - void zupgtr(char *uplo, int *n, z *ap, z *tau, z *q, int *ldq, z *work, int *info) - void zupmtr(char *side, char *uplo, char *trans, int *m, int *n, z *ap, z *tau, z *c, int *ldc, z *work, int *info) -+void ilaenv(int *ispec, char *name, char *opts, int *n1, int *n2, int *n3, int *n4) +-void ++int + ode_function(F_INT *n, double *t, double *y, double *ydot) + { + /* diff --git a/scipy/linalg/fblas_l1.pyf.src b/scipy/linalg/fblas_l1.pyf.src -index 5008ee8..6380740 100644 +index 4803a4a97..5adc703a4 100644 --- a/scipy/linalg/fblas_l1.pyf.src +++ b/scipy/linalg/fblas_l1.pyf.src -@@ -252,14 +252,17 @@ end subroutine axpy +@@ -279,14 +279,16 @@ end subroutine axpy function sdot(n,x,offx,incx,y,offy,incy) result (xy) ! Computes a vector-vector dot product. -- fortranname wsdot +- fortranname sdot + callstatement sdot_return_value=(*f2py_func)(&n,x+offx,&incx,y+offy,&incy) + callprotoargument int*,float*,int*,float*,int* -+ + +- callstatement (*f2py_func)(&sdot,&n,x+offx,&incx,y+offy,&incy) +- callprotoargument float*,F_INT*,float*,F_INT*,float*,F_INT* + fortranname F_FUNC(sdot,SDOT) + ! This following line is to avoid Fortran wrappers - fix for CLAPACK + intent(c) sdot -- callstatement (*f2py_func)(&sdot,&n,x+offx,&incx,y+offy,&incy) -- callprotoargument float*,int*,float*,int*,float*,int* - real dimension(*), intent(in) :: x real dimension(*), intent(in) :: y - real sdot,xy @@ -497,12 +105,12 @@ index 5008ee8..6380740 100644 integer optional, intent(in),check(incx>0||incx<0) :: incx = 1 integer optional, intent(in),check(incy>0||incy<0) :: incy = 1 integer optional, intent(in),depend(x) :: offx=0 -@@ -277,8 +280,12 @@ end function sdot +@@ -304,8 +306,12 @@ end function sdot function ddot(n,x,offx,incx,y,offy,incy) result (xy) ! Computes a vector-vector dot product. - callstatement (*f2py_func)(&ddot,&n,x+offx,&incx,y+offy,&incy) -- callprotoargument double*,int*,double*,int*,double*,int* +- callprotoargument double*,F_INT*,double*,F_INT*,double*,F_INT* + callstatement ddot_return_value=(*f2py_func)(&n,x+offx,&incx,y+offy,&incy) + callprotoargument int*,double*,int*,double*,int* + @@ -512,29 +120,27 @@ index 5008ee8..6380740 100644 double precision dimension(*), intent(in) :: x double precision dimension(*), intent(in) :: y -@@ -297,15 +304,19 @@ function ddot(n,x,offx,incx,y,offy,incy) result (xy) +@@ -324,6 +330,7 @@ function ddot(n,x,offx,incx,y,offy,incy) result (xy) end function ddot -+// in CLAPACK, cdotu and zdotu are void and return by pointer (as can't return complex* without allocation) - ! +++// in CLAPACK, cdotu and zdotu are void and return by pointer (as can't return complex* without allocation) function dotu(n,x,offx,incx,y,offy,incy) result(xy) :: dotu, xy -- fortranname wdotu - -- callstatement (*f2py_func)(&dotu,&n,x+offx,&incx,y+offy,&incy) -+ callstatement (*f2py_func)(&dotu_return_value,&n,x+offx,&incx,y+offy,&incy) - callprotoargument *,int*,*,int*,*,int* - -+ fortranname F_FUNC(dotu,DOTU) -+ ! This following line is to avoid Fortran wrappers - fix for CLAPACK -+ intent(c) dotu -+ +@@ -335,6 +342,11 @@ function dotu(n,x,offx,incx,y,offy,incy) result(xy) dimension(*),intent(in) :: x dimension(*),intent(in) :: y -@@ -328,10 +339,12 @@ end function dotu +++ fortranname F_FUNC(dotu,DOTU) +++ ! This following line is to avoid Fortran wrappers - fix for CLAPACK +++ intent(c) dotu +++ ++ + integer optional, intent(in),check(incx>0||incx<0) :: incx = 1 + integer optional, intent(in),check(incy>0||incy<0) :: incy = 1 + +@@ -354,10 +366,12 @@ end function dotu function dotc(n,x,offx,incx,y,offy,incy) result(xy) :: dotc, xy @@ -543,24 +149,23 @@ index 5008ee8..6380740 100644 + callprotoargument int*,*,int*,*,int* - callstatement (*f2py_func)(&dotc,&n,x+offx,&incx,y+offy,&incy) -- callprotoargument *,int*,*,int*,*,int* +- callprotoargument *,F_INT*,*,F_INT*,*,F_INT* + fortranname F_FUNC(dotc,DOTC) + ! This following line is to avoid Fortran wrappers - fix for CLAPACK + intent(c) dotc dimension(*),intent(in) :: x dimension(*),intent(in) :: y -@@ -354,11 +367,15 @@ end function dotc - ! +@@ -379,10 +393,15 @@ end function dotc + function nrm2(n,x,offx,incx) result(n2) -- fortranname wnrm2 - nrm2, n2 + nm2 + double precision nrm2 - callstatement (*f2py_func)(&nrm2, &n,x+offx,&incx) -- callprotoargument *,int*,*,int* +- callprotoargument *,F_INT*,*,F_INT* + callstatement nrm2_return_value=(*f2py_func)( &n,x+offx,&incx) + callprotoargument int*,*,int* + @@ -570,26 +175,25 @@ index 5008ee8..6380740 100644 dimension(*),intent(in) :: x -@@ -378,10 +395,15 @@ end function nrm2 - ! +@@ -399,10 +418,14 @@ end function nrm2 + function nrm2(n,x,offx,incx) result(n2) - nrm2, n2 + callstatement nrm2_return_value=(*f2py_func)(&n,x+offx,&incx) + callprotoargument int*,*,int* -+ + +- callstatement (*f2py_func)(&nrm2, &n,x+offx,&incx) +- callprotoargument *,F_INT*,*,F_INT* + double precision nrm2 + n2 + fortranname F_FUNC(nrm2,NRM2) + ! This following line is to avoid Fortran wrappers - fix for CLAPACK + intent(c) nrm2 -- callstatement (*f2py_func)(&nrm2, &n,x+offx,&incx) -- callprotoargument *,int*,*,int* - dimension(*),intent(in) :: x -@@ -396,16 +418,20 @@ function nrm2(n,x,offx,incx) result(n2) +@@ -417,14 +440,20 @@ function nrm2(n,x,offx,incx) result(n2) end function nrm2 @@ -597,12 +201,11 @@ index 5008ee8..6380740 100644 +function asum(n,x,offx,incx) result (d) ! Computes the sum of magnitudes of the vector elements -- fortranname wasum +- callstatement (*f2py_func)(&asum,&n,x+offx,&incx) +- callprotoargument *,F_INT*,*,F_INT* + callstatement asum_return_value=(*f2py_func)(&n,x+offx,&incx) + callprotoargument int*,*,int* - -- callstatement (*f2py_func)(&asum,&n,x+offx,&incx) -- callprotoargument *,int*,*,int* ++ + double precision asum + fortranname F_FUNC(asum,ASUM) + ! This following line is to avoid Fortran wrappers - fix for CLAPACK @@ -615,7 +218,7 @@ index 5008ee8..6380740 100644 integer optional, intent(in), check(incx>0||incx<0) :: incx = 1 integer optional, intent(in), depend(x) :: offx=0 check(offx>=0 && offxasum(n,x,offx,incx) result (s) +@@ -434,11 +463,16 @@ function asum(n,x,offx,incx) result (s) end function asum @@ -624,7 +227,7 @@ index 5008ee8..6380740 100644 ! Computes the sum of magnitudes of the vector elements - callstatement (*f2py_func)(&asum,&n,x+offx,&incx) -- callprotoargument *,int*,*,int* +- callprotoargument *,F_INT*,*,F_INT* + callstatement asum_return_value=(*f2py_func)(&n,x+offx,&incx) + callprotoargument int*,*,int* + @@ -635,74 +238,8 @@ index 5008ee8..6380740 100644 dimension(*), intent(in) :: x asum,s -@@ -438,9 +469,9 @@ function iamax(n,x,offx,incx) result(k) - callstatement iamax_return_value = (*f2py_func)(&n,x+offx,&incx) - 1 - callprotoargument int*,*,int* - -- ! This is to avoid Fortran wrappers. -+ ! This is to avoid Fortran wrappers - fix for CLAPACK - integer iamax,k -- fortranname F_FUNC(iamax,IAMAX) -+ fortranname F_FUNC(iamax,IAMAX) - intent(c) iamax - dimension(*), intent(in) :: x - integer optional, intent(in), check(incx>0||incx<0) :: incx = 1 -diff --git a/scipy/linalg/flapack.pyf.src b/scipy/linalg/flapack.pyf.src -index fd7c8ac..afbd956 100644 ---- a/scipy/linalg/flapack.pyf.src -+++ b/scipy/linalg/flapack.pyf.src -@@ -2344,7 +2344,15 @@ end subroutine hbevx - ! rmax = overflow threshold - (base**emax)*(1-eps) - function dlamch(cmach) - character :: cmach -- double precision intent(out):: dlamch -+ double precision:: dlamch -+ callstatement dlamch_return_value=(*f2py_func)(cmach) -+ callprotoargument char* -+ -+ fortranname F_FUNC(dlamch,DLAMCH) -+ ! This following line is to avoid Fortran wrappers - fix for CLAPACK -+ intent(c) dlamch -+ -+ - end function dlamch - - function slamch(cmach) -@@ -2824,9 +2832,12 @@ function lange(norm,m,n,a,lda,work) result(n2) - ! the one norm, or the Frobenius norm, or the infinity norm, or the - ! element of largest absolute value of a real matrix A. - lange, n2 -- fortranname lange -- callstatement (*f2py_func)(&lange,norm,&m,&n,a,&m,work) -- callprotoargument *,char*,int*,int*,*,int*,* -+ callstatement lange_return_value=(*f2py_func)(norm,&m,&n,a,&m,work) -+ callprotoargument char*,int*,int*,*,int*,* -+ -+ fortranname F_FUNC(lange,LANGE) -+ ! This following line is to avoid Fortran wrappers - fix for CLAPACK -+ intent(c) lange - - character intent(in),check(*norm=='M'||*norm=='m'||*norm=='1'||*norm=='O'||*norm=='o'||*norm=='I'||*norm=='i'||*norm=='F'||*norm=='f'||*norm=='E'||*norm=='e'):: norm - integer intent(hide),depend(a,n) :: m = shape(a,0) -@@ -2840,9 +2851,13 @@ function lange(norm,m,n,a,lda,work) result(n2) - ! the one norm, or the Frobenius norm, or the infinity norm, or the - ! element of largest absolute value of a complex matrix A. - lange, n2 -- fortranname lange -- callstatement (*f2py_func)(&lange,norm,&m,&n,a,&m,work) -- callprotoargument *,char*,int*,int*,*,int*,* -+ -+ callstatement lange_return_value=(*f2py_func)(&norm,&m,&n,a,&m,work) -+ callprotoargument char*,int*,int*,*,int*,* -+ -+ fortranname F_FUNC(lange,LANGE) -+ ! This following line is to avoid Fortran wrappers - fix for CLAPACK -+ intent(c) lange - - character intent(in),check(*norm=='M'||*norm=='m'||*norm=='1'||*norm=='O'||*norm=='o'||*norm=='I'||*norm=='i'||*norm=='F'||*norm=='f'||*norm=='E'||*norm=='e'):: norm - integer intent(hide),depend(a,n) :: m = shape(a,0) diff --git a/scipy/linalg/setup.py b/scipy/linalg/setup.py -index 8084aa8..5408c79 100755 +index 0cbd5ffdf..d4ee4f867 100644 --- a/scipy/linalg/setup.py +++ b/scipy/linalg/setup.py @@ -44,9 +44,10 @@ def configuration(parent_package='', top_path=None): @@ -716,14 +253,14 @@ index 8084aa8..5408c79 100755 +# 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_gen.pyf.src', + 'flapack_gen_banded.pyf.src', + 'flapack_gen_tri.pyf.src', diff --git a/scipy/optimize/_lsq/setup.py b/scipy/optimize/_lsq/setup.py -index b9222a0..863400b 100644 +index 7ce589c0c..6412886e0 100644 --- a/scipy/optimize/_lsq/setup.py +++ b/scipy/optimize/_lsq/setup.py -@@ -5,7 +5,7 @@ def configuration(parent_package='', top_path=None): +@@ -3,7 +3,7 @@ def configuration(parent_package='', top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('_lsq', parent_package, top_path) config.add_extension('givens_elimination', @@ -732,41 +269,14 @@ index b9222a0..863400b 100644 return config -diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/cgscon.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/cgscon.c -index e17532d..a7a5629 100644 ---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/cgscon.c -+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/cgscon.c -@@ -80,9 +80,6 @@ cgscon(char *norm, SuperMatrix *L, SuperMatrix *U, - int kase, kase1, onenrm, i; - float ainvnm; - complex *work; -- extern int crscl_(int *, complex *, complex *, int *); -- -- extern int clacon_(int *, complex *, complex *, float *, int *); - - - /* Test the input parameters. */ -diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/cgsequ.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/cgsequ.c -index db31e35..1da9ac0 100644 ---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/cgsequ.c -+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/cgsequ.c -@@ -92,7 +92,6 @@ cgsequ(SuperMatrix *A, float *r, float *c, float *rowcnd, - int i, j, irow; - float rcmin, rcmax; - float bignum, smlnum; -- extern float slamch_(char *); - - /* Test the input parameters. */ - *info = 0; diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/cgsrfs.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/cgsrfs.c -index e7c2bc7..0dde69b 100644 +index a7dd2f8fd..3b2544d4f 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/cgsrfs.c +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/cgsrfs.c -@@ -158,14 +158,6 @@ cgsrfs(trans_t trans, SuperMatrix *A, SuperMatrix *L, SuperMatrix *U, - float *rwork; - int *iwork; +@@ -171,13 +171,6 @@ cgsrfs(trans_t trans, SuperMatrix *A, SuperMatrix *L, SuperMatrix *U, + int isave[3]; -- extern int clacon_(int *, complex *, complex *, float *, int *); + extern int clacon2_(int *, complex *, complex *, float *, int *, int []); -#ifdef _CRAY - extern int CCOPY(int *, complex *, int *, complex *, int *); - extern int CSAXPY(int *, complex *, complex *, int *, complex *, int *); @@ -777,55 +287,29 @@ index e7c2bc7..0dde69b 100644 Astore = A->Store; Aval = Astore->nzval; -diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/clacon.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/clacon.c -index d206d5a..8e64576 100644 ---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/clacon.c -+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/clacon.c -@@ -85,9 +85,6 @@ clacon_(int *n, complex *v, complex *x, float *est, int *kase) - static int i, j; - float temp; - float safmin; -- extern float slamch_(char *); -- extern int icmax1_(int *, complex *, int *); -- extern double scsum1_(int *, complex *, int *); - - safmin = slamch_("Safe minimum"); - if ( *kase == 0 ) { diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/dgscon.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/dgscon.c -index d91474a..f33f10d 100644 +index d51f24c3b..b76dc7a78 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/dgscon.c +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/dgscon.c -@@ -81,9 +81,6 @@ dgscon(char *norm, SuperMatrix *L, SuperMatrix *U, - double ainvnm; +@@ -92,10 +92,7 @@ dgscon(char *norm, SuperMatrix *L, SuperMatrix *U, double *work; int *iwork; + int isave[3]; - extern int drscl_(int *, double *, double *, int *); - -- extern int dlacon_(int *, double *, double *, int *, double *, int *); - - - /* Test the input parameters. */ -diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/dgsequ.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/dgsequ.c -index 73870d4..222bf66 100644 ---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/dgsequ.c -+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/dgsequ.c -@@ -92,7 +92,6 @@ dgsequ(SuperMatrix *A, double *r, double *c, double *rowcnd, - int i, j, irow; - double rcmin, rcmax; - double bignum, smlnum; -- extern double dlamch_(char *); + extern int dlacon2_(int *, double *, double *, int *, double *, int *, int []); +- /* Test the input parameters. */ *info = 0; diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/dgsrfs.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/dgsrfs.c -index 55531b0..792509c 100644 +index d37226035..69f6bd8cf 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/dgsrfs.c +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/dgsrfs.c -@@ -158,14 +158,6 @@ dgsrfs(trans_t trans, SuperMatrix *A, SuperMatrix *L, SuperMatrix *U, - double *rwork; - int *iwork; +@@ -171,13 +171,6 @@ dgsrfs(trans_t trans, SuperMatrix *A, SuperMatrix *L, SuperMatrix *U, + int isave[3]; -- extern int dlacon_(int *, double *, double *, int *, double *, int *); + extern int dlacon2_(int *, double *, double *, int *, double *, int *, int []); -#ifdef _CRAY - extern int SCOPY(int *, double *, int *, double *, int *); - extern int SSAXPY(int *, double *, double *, int *, double *, int *); @@ -836,99 +320,24 @@ index 55531b0..792509c 100644 Astore = A->Store; Aval = Astore->nzval; -diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/dlacon.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/dlacon.c -index 951fe7a..7359570 100644 ---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/dlacon.c -+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/dlacon.c -@@ -80,15 +80,6 @@ dlacon_(int *n, double *v, double *x, int *isgn, double *est, int *kase) - static double altsgn, estold; - static int i, j; - double temp; --#ifdef _CRAY -- extern int ISAMAX(int *, double *, int *); -- extern double SASUM(int *, double *, int *); -- extern int SCOPY(int *, double *, int *, double *, int *); --#else -- extern int idamax_(int *, double *, int *); -- extern double dasum_(int *, double *, int *); -- extern int dcopy_(int *, double *, int *, double *, int *); --#endif - #define d_sign(a, b) (b >= 0 ? fabs(a) : -fabs(a)) /* Copy sign */ - #define i_dnnt(a) \ - ( a>=0 ? floor(a+.5) : -floor(.5-a) ) /* Round to nearest integer */ -diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/dlamch.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/dlamch.c -index e117915..28ffdbb 100644 ---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/dlamch.c -+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/dlamch.c -@@ -76,10 +76,7 @@ double dlamch_(char *cmach) - static int imin, imax; - static int lrnd; - static double rmin, rmax, t, rmach; -- extern int lsame_(char *, char *); - static double small, sfmin; -- extern /* Subroutine */ int dlamc2_(int *, int *, int *, -- double *, int *, double *, int *, double *); - static int it; - static double rnd, eps; - -@@ -197,7 +194,6 @@ int dlamc1_(int *beta, int *t, int *rnd, int - static double a, b, c, f; - static int lbeta; - static double savec; -- extern double dlamc3_(double *, double *); - static int lieee1; - static double t1, t2; - static int lt; -@@ -435,13 +431,7 @@ int dlamc2_(int *beta, int *t, int *rnd, - static double small; - static int gpmin; - static double third, lrmin, lrmax, sixth; -- extern /* Subroutine */ int dlamc1_(int *, int *, int *, -- int *); -- extern double dlamc3_(double *, double *); - static int lieee1; -- extern /* Subroutine */ int dlamc4_(int *, double *, int *), -- dlamc5_(int *, int *, int *, int *, int *, -- double *); - static int lt, ngnmin, ngpmin; - static double one, two; - -@@ -725,7 +715,6 @@ int dlamc4_(int *emin, double *start, int *base) - static double zero, a; - static int i; - static double rbase, b1, b2, c1, c2, d1, d2; -- extern double dlamc3_(double *, double *); - static double one; - - a = *start; -@@ -840,7 +829,6 @@ int dlamc5_(int *beta, int *p, int *emin, - static int uexp, i; - static double y, z; - static int nbits; -- extern double dlamc3_(double *, double *); - static double recbas; - static int exbits, expsum, try__; - diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_ccopy_to_ucol.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_ccopy_to_ucol.c -index 5a7203d..0ac71c0 100644 +index a5eb0b613..bc8ce3537 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_ccopy_to_ucol.c +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_ccopy_to_ucol.c -@@ -16,10 +16,6 @@ +@@ -26,8 +26,6 @@ at the top-level directory. int num_drop_U; #endif -extern void ccopy_(int *, complex [], int *, complex [], int *); --#if SCIPY_FIX --extern double dlamch_(char *); --#endif - +- #if 0 static complex *A; /* used in _compare_ only */ + static int _compare_(const void *a, const void *b) diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_cdrop_row.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_cdrop_row.c -index 44173c8..fa1b999 100644 +index 09b8a937d..fdd6064de 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_cdrop_row.c +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_cdrop_row.c -@@ -13,13 +13,6 @@ +@@ -23,15 +23,6 @@ at the top-level directory. #include #include "slu_cdefs.h" @@ -937,16 +346,18 @@ index 44173c8..fa1b999 100644 -extern void ccopy_(int *, complex [], int *, complex [], int *); -extern float scasum_(int *, complex *, int *); -extern float scnrm2_(int *, complex *, int *); +-extern void scopy_(int *, float [], int *, float [], int *); -extern double dnrm2_(int *, double [], int *); -extern int icamax_(int *, complex [], int *); - +- static float *A; /* used in _compare_ only */ static int _compare_(const void *a, const void *b) + { diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_dcopy_to_ucol.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_dcopy_to_ucol.c -index e9162a7..22eae38 100644 +index 2bb889c39..658e7e71e 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_dcopy_to_ucol.c +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_dcopy_to_ucol.c -@@ -16,7 +16,6 @@ +@@ -26,7 +26,6 @@ at the top-level directory. int num_drop_U; #endif @@ -955,10 +366,10 @@ index e9162a7..22eae38 100644 #if 0 static double *A; /* used in _compare_ only */ diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_ddrop_row.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_ddrop_row.c -index a08c85c..3174de3 100644 +index f25b5085a..19afee76c 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_ddrop_row.c +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_ddrop_row.c -@@ -13,13 +13,6 @@ +@@ -23,13 +23,6 @@ at the top-level directory. #include #include "slu_ddefs.h" @@ -973,25 +384,23 @@ index a08c85c..3174de3 100644 static double *A; /* used in _compare_ only */ static int _compare_(const void *a, const void *b) diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_scopy_to_ucol.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_scopy_to_ucol.c -index b9fd387..eee65c8 100644 +index 6dc0460c1..994224c35 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_scopy_to_ucol.c +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_scopy_to_ucol.c -@@ -16,10 +16,6 @@ +@@ -26,7 +26,7 @@ at the top-level directory. int num_drop_U; #endif -extern void scopy_(int *, float [], int *, float [], int *); --#if SCIPY_FIX --extern double dlamch_(char *); --#endif ++extern int scopy_(int *, float [], int *, float [], int *); #if 0 static float *A; /* used in _compare_ only */ diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_sdrop_row.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_sdrop_row.c -index 108f849..7ce483d 100644 +index 836ee5450..8d1368838 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_sdrop_row.c +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_sdrop_row.c -@@ -13,13 +13,6 @@ +@@ -23,13 +23,6 @@ at the top-level directory. #include #include "slu_sdefs.h" @@ -1006,10 +415,10 @@ index 108f849..7ce483d 100644 static float *A; /* used in _compare_ only */ static int _compare_(const void *a, const void *b) diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_zcopy_to_ucol.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_zcopy_to_ucol.c -index ddf3a63..cef2341 100644 +index afe4a7e04..4f45bd11d 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_zcopy_to_ucol.c +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_zcopy_to_ucol.c -@@ -16,7 +16,6 @@ +@@ -26,7 +26,6 @@ at the top-level directory. int num_drop_U; #endif @@ -1018,10 +427,10 @@ index ddf3a63..cef2341 100644 #if 0 static doublecomplex *A; /* used in _compare_ only */ diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_zdrop_row.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_zdrop_row.c -index 0a140d4..2207950 100644 +index 2de1226ef..362e18210 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_zdrop_row.c +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/ilu_zdrop_row.c -@@ -13,13 +13,6 @@ +@@ -23,15 +23,6 @@ at the top-level directory. #include #include "slu_zdefs.h" @@ -1031,12 +440,14 @@ index 0a140d4..2207950 100644 -extern double dzasum_(int *, doublecomplex *, int *); -extern double dznrm2_(int *, doublecomplex *, int *); -extern double dnrm2_(int *, double [], int *); +-extern void dcopy_(int *, double [], int *, double [], int *); -extern int izamax_(int *, doublecomplex [], int *); - +- static double *A; /* used in _compare_ only */ static int _compare_(const void *a, const void *b) + { diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/scipy_slu_config.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/scipy_slu_config.h -index 5afc93b..1a2c4ca 100644 +index 5afc93b5d..1a2c4ca36 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/scipy_slu_config.h +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/scipy_slu_config.h @@ -3,6 +3,14 @@ @@ -1054,41 +465,14 @@ index 5afc93b..1a2c4ca 100644 /* * Support routines */ -diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgscon.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgscon.c -index a474967..ae4a511 100644 ---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgscon.c -+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgscon.c -@@ -81,9 +81,6 @@ sgscon(char *norm, SuperMatrix *L, SuperMatrix *U, - float ainvnm; - float *work; - int *iwork; -- extern int srscl_(int *, float *, float *, int *); -- -- extern int slacon_(int *, float *, float *, int *, float *, int *); - - - /* Test the input parameters. */ -diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgsequ.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgsequ.c -index 3637d7e..cf435db 100644 ---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgsequ.c -+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgsequ.c -@@ -92,7 +92,6 @@ sgsequ(SuperMatrix *A, float *r, float *c, float *rowcnd, - int i, j, irow; - float rcmin, rcmax; - float bignum, smlnum; -- extern float slamch_(char *); - - /* Test the input parameters. */ - *info = 0; diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgsrfs.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgsrfs.c -index a93bc5b..c685106 100644 +index 5faab1dfb..7380eb6cc 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgsrfs.c +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgsrfs.c -@@ -158,14 +158,6 @@ sgsrfs(trans_t trans, SuperMatrix *A, SuperMatrix *L, SuperMatrix *U, - float *rwork; - int *iwork; +@@ -171,13 +171,6 @@ sgsrfs(trans_t trans, SuperMatrix *A, SuperMatrix *L, SuperMatrix *U, + int isave[3]; -- extern int slacon_(int *, float *, float *, int *, float *, int *); + extern int slacon2_(int *, float *, float *, int *, float *, int *, int []); -#ifdef _CRAY - extern int SCOPY(int *, float *, int *, float *, int *); - extern int SSAXPY(int *, float *, float *, int *, float *, int *); @@ -1100,10 +484,10 @@ index a93bc5b..c685106 100644 Astore = A->Store; Aval = Astore->nzval; diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgssvx.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgssvx.c -index d33ca33..212ac4b 100644 +index c7aa79b3c..4f3a6310b 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgssvx.c +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/sgssvx.c -@@ -11,6 +11,8 @@ +@@ -21,6 +21,8 @@ at the top-level directory. */ #include "slu_sdefs.h" @@ -1112,7 +496,7 @@ index d33ca33..212ac4b 100644 /*! \brief * *
-@@ -357,8 +359,6 @@ sgssvx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
+@@ -378,8 +380,6 @@ sgssvx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
      double    t0;      /* temporary time */
      double    *utime;
  
@@ -1121,114 +505,21 @@ index d33ca33..212ac4b 100644
  
      Bstore = B->Store;
      Xstore = X->Store;
-@@ -552,7 +552,9 @@ printf("dgssvx: Fact=%4d, Trans=%4d, equed=%c\n",
+@@ -575,7 +575,8 @@ printf("dgssvx: Fact=%4d, Trans=%4d, equed=%c\n",
          } else {
  	    *(unsigned char *)norm = 'I';
          }
 -        anorm = slangs(norm, AA);
 +        anorm = slangs(norm, AA);    /* External functions */
 +        extern float slangs(char *, SuperMatrix *);
-+
-         sgscon(norm, L, U, anorm, rcond, stat, info);
+         sgscon(norm, L, U, anorm, rcond, stat, &info1);
          utime[RCOND] = SuperLU_timer_() - t0;
      }
-diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slacon.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slacon.c
-index 4e02fdc..d49f040 100644
---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slacon.c
-+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slacon.c
-@@ -80,15 +80,6 @@ slacon_(int *n, float *v, float *x, int *isgn, float *est, int *kase)
-     static float altsgn, estold;
-     static int i, j;
-     float temp;
--#ifdef _CRAY
--    extern int ISAMAX(int *, float *, int *);
--    extern float SASUM(int *, float *, int *);
--    extern int SCOPY(int *, float *, int *, float *, int *);
--#else
--    extern int isamax_(int *, float *, int *);
--    extern float sasum_(int *, float *, int *);
--    extern int scopy_(int *, float *, int *, float *, int *);
--#endif
- #define d_sign(a, b) (b >= 0 ? fabs(a) : -fabs(a))    /* Copy sign */
- #define i_dnnt(a) \
- 	( a>=0 ? floor(a+.5) : -floor(.5-a) ) /* Round to nearest integer */
-diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slamch.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slamch.c
-index 09cf6e2..3155468 100644
---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slamch.c
-+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slamch.c
-@@ -58,7 +58,7 @@
-    ===================================================================== 
- 
- */ --float slamch_(char *cmach) -+doublereal slamch_(char *cmach) - { - /* >>Start of File<< - Initialized data */ -@@ -75,10 +75,7 @@ float slamch_(char *cmach) - static int imin, imax; - static int lrnd; - static float rmin, rmax, t, rmach; -- extern int lsame_(char *, char *); - static float small, sfmin; -- extern /* Subroutine */ int slamc2_(int *, int *, int *, float -- *, int *, float *, int *, float *); - static int it; - static float rnd, eps; - -@@ -205,7 +202,6 @@ int slamc1_(int *beta, int *t, int *rnd, int - static float savec; - static int lieee1; - static float t1, t2; -- extern double slamc3_(float *, float *); - static int lt; - static float one, qtr; - -@@ -443,12 +439,6 @@ int slamc2_(int *beta, int *t, int *rnd, float * - static int gpmin; - static float third, lrmin, lrmax, sixth; - static int lieee1; -- extern /* Subroutine */ int slamc1_(int *, int *, int *, -- int *); -- extern double slamc3_(float *, float *); -- extern /* Subroutine */ int slamc4_(int *, float *, int *), -- slamc5_(int *, int *, int *, int *, int *, -- float *); - static int lt, ngnmin, ngpmin; - static float one, two; - -diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/sldperm.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/sldperm.c -index acb82bc..c9d0946 100644 ---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/sldperm.c -+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/sldperm.c -@@ -13,8 +13,8 @@ - - extern int_t mc64id_(int_t*); - extern int_t mc64ad_(int_t*, int_t*, int_t*, int_t [], int_t [], double [], -- int_t*, int_t [], int_t*, int_t[], int_t*, double [], -- int_t [], int_t []); -+ int_t*, int_t [], int_t*, int_t[], int_t*, double [], -+ int_t [], int_t []); - - /*! \brief - * -diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h -index 24d1374..cea93d6 100644 ---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h -+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h -@@ -236,7 +236,6 @@ extern int sp_cgemv (char *, complex, SuperMatrix *, complex *, - extern int sp_cgemm (char *, char *, int, int, int, complex, - SuperMatrix *, complex *, int, complex, - complex *, int); --extern float slamch_(char *); - - - /*! \brief Memory-related */ diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_dcomplex.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_dcomplex.h -index 386ad68..72f5355 100644 +index 67e83bcc7..e5757d5c4 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_dcomplex.h +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_dcomplex.h -@@ -18,7 +18,10 @@ +@@ -28,7 +28,10 @@ at the top-level directory. #ifndef DCOMPLEX_INCLUDE #define DCOMPLEX_INCLUDE @@ -1241,10 +532,10 @@ index 386ad68..72f5355 100644 /* Macro definitions */ diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_scomplex.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_scomplex.h -index c17490d..fef343d 100644 +index 5c9aa7058..a10f9a52f 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_scomplex.h +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_scomplex.h -@@ -17,8 +17,9 @@ +@@ -27,8 +27,9 @@ at the top-level directory. #ifndef SCOMPLEX_INCLUDE #define SCOMPLEX_INCLUDE @@ -1256,66 +547,26 @@ index c17490d..fef343d 100644 /* Macro definitions */ -diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h -index 745d76f..0c2a45b 100644 ---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h -+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h -@@ -235,7 +235,6 @@ extern int sp_sgemv (char *, float, SuperMatrix *, float *, - extern int sp_sgemm (char *, char *, int, int, int, float, - SuperMatrix *, float *, int, float, - float *, int); --extern float slamch_(char *); - - - /*! \brief Memory-related */ diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_util.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_util.h -index f41b4ca..1560371 100644 +index d34e4fe5b..7df125f68 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_util.h +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_util.h -@@ -348,8 +348,6 @@ extern int spcoletree (int *, int *, int *, int, int, int *); +@@ -398,7 +398,6 @@ extern int spcoletree (int *, int *, int *, int, int, int *); extern int *TreePostorder (int, int *); extern double SuperLU_timer_ (); extern int sp_ienv (int); --extern int lsame_ (char *, char *); -extern int xerbla_ (char *, int *); extern void ifill (int *, int, int); extern void snode_profile (int, int *); extern void super_stats (int, int *); -diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/zgscon.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/zgscon.c -index 8bb95aa..8b6651d 100644 ---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/zgscon.c -+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/zgscon.c -@@ -80,9 +80,6 @@ zgscon(char *norm, SuperMatrix *L, SuperMatrix *U, - int kase, kase1, onenrm, i; - double ainvnm; - doublecomplex *work; -- extern int zrscl_(int *, doublecomplex *, doublecomplex *, int *); -- -- extern int zlacon_(int *, doublecomplex *, doublecomplex *, double *, int *); - - - /* Test the input parameters. */ -diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/zgsequ.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/zgsequ.c -index 657637d..b04e46f 100644 ---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/zgsequ.c -+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/zgsequ.c -@@ -92,7 +92,6 @@ zgsequ(SuperMatrix *A, double *r, double *c, double *rowcnd, - int i, j, irow; - double rcmin, rcmax; - double bignum, smlnum; -- extern double dlamch_(char *); - - /* Test the input parameters. */ - *info = 0; diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/zgsrfs.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/zgsrfs.c -index 2ed0481..110bfe1 100644 +index 02b63df30..71209b3b7 100644 --- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/zgsrfs.c +++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/zgsrfs.c -@@ -158,14 +158,6 @@ zgsrfs(trans_t trans, SuperMatrix *A, SuperMatrix *L, SuperMatrix *U, - double *rwork; - int *iwork; +@@ -171,13 +171,6 @@ zgsrfs(trans_t trans, SuperMatrix *A, SuperMatrix *L, SuperMatrix *U, + int isave[3]; -- extern int zlacon_(int *, doublecomplex *, doublecomplex *, double *, int *); + extern int zlacon2_(int *, doublecomplex *, doublecomplex *, double *, int *, int []); -#ifdef _CRAY - extern int CCOPY(int *, doublecomplex *, int *, doublecomplex *, int *); - extern int CSAXPY(int *, doublecomplex *, doublecomplex *, int *, doublecomplex *, int *); @@ -1326,25 +577,11 @@ index 2ed0481..110bfe1 100644 Astore = A->Store; Aval = Astore->nzval; -diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/zlacon.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/zlacon.c -index b2cd1ed..6934f1e 100644 ---- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/zlacon.c -+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/zlacon.c -@@ -85,9 +85,6 @@ zlacon_(int *n, doublecomplex *v, doublecomplex *x, double *est, int *kase) - static int i, j; - double temp; - double safmin; -- extern double dlamch_(char *); -- extern int izmax1_(int *, doublecomplex *, int *); -- extern double dzsum1_(int *, doublecomplex *, int *); - - safmin = dlamch_("Safe minimum"); - if ( *kase == 0 ) { diff --git a/scipy/sparse/linalg/dsolve/_superlu_utils.c b/scipy/sparse/linalg/dsolve/_superlu_utils.c -index c2a10a7..eb85c3b 100644 +index 16bb03392..13e63c0ba 100644 --- a/scipy/sparse/linalg/dsolve/_superlu_utils.c +++ b/scipy/sparse/linalg/dsolve/_superlu_utils.c -@@ -79,12 +79,12 @@ void superlu_python_module_free(void *ptr) +@@ -243,12 +243,12 @@ int input_error(char *srname, int *info) * Stubs for Harwell Subroutine Library functions that SuperLU tries to call. */ @@ -1360,7 +597,7 @@ index c2a10a7..eb85c3b 100644 int m[], int n[]) { diff --git a/scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/debug.h b/scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/debug.h -index 5eb0bb1..03fb23d 100644 +index 5eb0bb1b3..81a6efafb 100644 --- a/scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/debug.h +++ b/scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/debug.h @@ -1,16 +1,16 @@ @@ -1385,13 +622,13 @@ index 5eb0bb1..03fb23d 100644 +c & msaupd, msaup2, msaitr, mseigt, msapps, msgets, mseupd, +c & mnaupd, mnaup2, mnaitr, mneigh, mnapps, mngets, mneupd, +c & mcaupd, mcaup2, mcaitr, mceigh, mcapps, mcgets, mceupd -+c common /debug/ ++c common /debug/ +c & logfil, ndigit, mgetv0, +c & msaupd, msaup2, msaitr, mseigt, msapps, msgets, mseupd, +c & mnaupd, mnaup2, mnaitr, mneigh, mnapps, mngets, mneupd, +c & mcaupd, mcaup2, mcaitr, mceigh, mcapps, mcgets, mceupd diff --git a/scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/stat.h b/scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/stat.h -index 66a8e9f..1f2d49c 100644 +index 66a8e9f87..81d49c3bd 100644 --- a/scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/stat.h +++ b/scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/stat.h @@ -5,17 +5,17 @@ c @@ -1419,36 +656,12 @@ index 66a8e9f..1f2d49c 100644 +c & tnaupd, tnaup2, tnaitr, tneigh, tngets, tnapps, tnconv, +c & tcaupd, tcaup2, tcaitr, tceigh, tcgets, tcapps, tcconv, +c & tmvopx, tmvbx, tgetv0, titref, trvec -+c common /timing/ ++c common /timing/ +c & nopx, nbx, nrorth, nitref, nrstrt, +c & tsaupd, tsaup2, tsaitr, tseigt, tsgets, tsapps, tsconv, +c & tnaupd, tnaup2, tnaitr, tneigh, tngets, tnapps, tnconv, +c & tcaupd, tcaup2, tcaitr, tceigh, tcgets, tcapps, tcconv, +c & tmvopx, tmvbx, tgetv0, titref, trvec -diff --git a/scipy/spatial/qhull_blas.h b/scipy/spatial/qhull_blas.h -index 2e235db..666630e 100644 ---- a/scipy/spatial/qhull_blas.h -+++ b/scipy/spatial/qhull_blas.h -@@ -16,6 +16,10 @@ - #endif - #endif - -+int dgetrs_(char *trans, int *n, int *nrhs, double *a, int *lda, int *ipiv, double *b, int *ldb, int *info); -+int dgetrf_(int *m, int *n, double *a, int *lda, int *ipiv, int *info); -+int dgecon_(char *norm, int *n, double *a, int *lda, double *anorm, double *rcond, double *work, int *iwork, int *info); -+ - #define qh_dgetrf F_FUNC(dgetrf,DGETRF) - #define qh_dgecon F_FUNC(dgecon,DGECON) - #define qh_dgetrs F_FUNC(dgetrs,DGETRS) -diff --git a/scipy/special/lapack_defs.h b/scipy/special/lapack_defs.h -index fb8fd80..d84cd3f 100644 ---- a/scipy/special/lapack_defs.h -+++ b/scipy/special/lapack_defs.h -@@ -16,5 +16,6 @@ - #endif - #endif - -+int dstevr_(char *jobz, char *range, int *n, double *d, double *e, double *vl, double *vu, int *il, int *iu, double *abstol, int *m, double *w, double *z, int *ldz, int *isuppz, double *work, int *lwork, int *iwork, int *liwork, int *info); - #define c_dstevr F_FUNC(dstevr,DSTEVR) - +-- +2.25.1 diff --git a/packages/scipy/patches/remove-cuncsd-dorcsd-sorcsd-zuncsd.patch b/packages/scipy/patches/remove-cuncsd-dorcsd-sorcsd-zuncsd.patch new file mode 100644 index 000000000..c1252658f --- /dev/null +++ b/packages/scipy/patches/remove-cuncsd-dorcsd-sorcsd-zuncsd.patch @@ -0,0 +1,35 @@ +From 7b56e1341c486422973dfa890158872200527b51 Mon Sep 17 00:00:00 2001 +From: Hood Chatham +Date: Sat, 25 Dec 2021 20:31:40 -0800 +Subject: [PATCH] Remove cuncsd, dorcsd, sorcsd, zuncsd + +These functions don't work because their definitions involve code that isn't +fortran 77 compliant. In order to get _flapack.so to link correctly, we need +to provide stub definitions for these functions, but they don't work. Remove +them to make sure people get an `AttributeError` if they try to use them +rather than just having weird buggy code. + +--- + scipy/linalg/__init__.py | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/scipy/linalg/__init__.py b/scipy/linalg/__init__.py +index e88479b48..746bf3dce 100644 +--- a/scipy/linalg/__init__.py ++++ b/scipy/linalg/__init__.py +@@ -191,6 +191,12 @@ Low-level routines + `scipy.linalg.cython_lapack` -- Low-level LAPACK functions for Cython + + """ # noqa: E501 ++from . import lapack ++del lapack.cuncsd ++del lapack.dorcsd ++del lapack.sorcsd ++del lapack.zuncsd ++del lapack + + from .misc import * + from .basic import * +-- +2.25.1 + diff --git a/packages/scipy/patches/remove-mvnun-not-fortran-77-compliant.patch b/packages/scipy/patches/remove-mvnun-not-fortran-77-compliant.patch new file mode 100644 index 000000000..acb8471a1 --- /dev/null +++ b/packages/scipy/patches/remove-mvnun-not-fortran-77-compliant.patch @@ -0,0 +1,199 @@ +From 8e62ac7ee97e6046745ba086545ac9c2511279f8 Mon Sep 17 00:00:00 2001 +From: Hood Chatham +Date: Sat, 25 Dec 2021 16:02:23 -0800 +Subject: [PATCH] remove mvnun -- not fortran 77 compliant + +These two functions use features from newer fortran standards which won't work +with f2c. This deletes them. + +--- + scipy/stats/mvn.pyf | 29 ---------- + scipy/stats/mvndst.f | 132 ------------------------------------------- + 2 files changed, 161 deletions(-) + +diff --git a/scipy/stats/mvn.pyf b/scipy/stats/mvn.pyf +index c9022b8de..cb0862a76 100644 +--- a/scipy/stats/mvn.pyf ++++ b/scipy/stats/mvn.pyf +@@ -3,35 +3,6 @@ + + python module mvn ! in + interface ! in :mvn +- subroutine mvnun(d,n,lower,upper,means,covar,maxpts,abseps,releps,value,inform) ! in :mvn:mvndst.f +- integer intent(hide) :: d=shape(means,0) +- integer intent(hide) :: n=shape(means,1) +- double precision dimension(d) :: lower +- double precision dimension(d) :: upper +- double precision dimension(d,n) :: means +- double precision dimension(d,d) :: covar +- integer intent(optional) :: maxpts=d*1000 +- double precision intent(optional) :: abseps=1e-6 +- double precision intent(optional) :: releps=1e-6 +- double precision intent(out) :: value +- integer intent(out) :: inform +- end subroutine mvnun +- +- subroutine mvnun_weighted(d,n,lower,upper,means,weights,covar,maxpts,abseps,releps,value,inform) ! in :mvn:mvndst.f +- integer intent(hide) :: d=shape(means,0) +- integer intent(hide) :: n=shape(means,1) +- double precision dimension(d) :: lower +- double precision dimension(d) :: upper +- double precision dimension(d,n) :: means +- double precision dimension(n) :: weights +- double precision dimension(d,d) :: covar +- integer intent(optional) :: maxpts=d*1000 +- double precision intent(optional) :: abseps=1e-6 +- double precision intent(optional) :: releps=1e-6 +- double precision intent(out) :: value +- integer intent(out) :: inform +- end subroutine mvnun_weighted +- + subroutine mvndst(n,lower,upper,infin,correl,maxpts,abseps,releps,error,value,inform) ! in :mvn:mvndst.f + integer intent(hide) :: n=len(lower) + double precision dimension(n) :: lower +diff --git a/scipy/stats/mvndst.f b/scipy/stats/mvndst.f +index 41afa7e74..76d9690e3 100644 +--- a/scipy/stats/mvndst.f ++++ b/scipy/stats/mvndst.f +@@ -21,138 +21,6 @@ + * Pullman, WA 99164-3113 + * Email : alangenz@wsu.edu + * +- SUBROUTINE mvnun(d, n, lower, upper, means, covar, maxpts, +- & abseps, releps, value, inform) +-* Parameters +-* +-* d integer, dimensionality of the data +-* n integer, the number of data points +-* lower double(2), the lower integration limits +-* upper double(2), the upper integration limits +-* means double(n), the mean of each kernel +-* covar double(2,2), the covariance matrix +-* maxpts integer, the maximum number of points to evaluate at +-* abseps double, absolute error tolerance +-* releps double, relative error tolerance +-* value double intent(out), integral value +-* inform integer intent(out), +-* if inform == 0: error < eps +-* elif inform == 1: error > eps, all maxpts used +- integer n, d, infin(d), maxpts, inform, tmpinf +- double precision lower(d), upper(d), releps, abseps, +- & error, value, stdev(d), rho(d*(d-1)/2), +- & covar(d,d), +- & nlower(d), nupper(d), means(d,n), tmpval, +- & inf +- integer i, j +- +- inf = 0d0 +- inf = 1d0 / inf +- +- do i=1,d +- stdev(i) = dsqrt(covar(i,i)) +- if (upper(i).eq.inf.and.lower(i).eq.-inf) then +- infin(i) = -1 +- else if (lower(i).eq.-inf) then +- infin(i) = 0 +- else if (upper(i).eq.inf) then +- infin(i) = 1 +- else +- infin(i) = 2 +- end if +- end do +- do i=1,d +- do j=1,i-1 +- rho(j+(i-2)*(i-1)/2) = covar(i,j)/stdev(i)/stdev(j) +- end do +- end do +- value = 0d0 +- +- inform = 0 +- +- do i=1,n +- do j=1,d +- nlower(j) = (lower(j) - means(j,i))/stdev(j) +- nupper(j) = (upper(j) - means(j,i))/stdev(j) +- end do +- call mvndst(d,nlower,nupper,infin,rho,maxpts,abseps,releps, +- & error,tmpval,tmpinf) +- value = value + tmpval +- if (tmpinf .eq. 1) then +- inform = 1 +- end if +- end do +- +- value = value / n +- +- END +- +- +- SUBROUTINE mvnun_weighted(d, n, lower, upper, means, weights, +- & covar, maxpts, abseps, releps, +- & value, inform) +-* Parameters +-* +-* d integer, dimensionality of the data +-* n integer, the number of data points +-* lower double(2), the lower integration limits +-* upper double(2), the upper integration limits +-* means double(n), the mean of each kernel +-* weights double(n), the weight of each kernel +-* covar double(2,2), the covariance matrix +-* maxpts integer, the maximum number of points to evaluate at +-* abseps double, absolute error tolerance +-* releps double, relative error tolerance +-* value double intent(out), integral value +-* inform integer intent(out), +-* if inform == 0: error < eps +-* elif inform == 1: error > eps, all maxpts used +- integer n, d, infin(d), maxpts, inform, tmpinf +- double precision lower(d), upper(d), releps, abseps, +- & error, value, stdev(d), rho(d*(d-1)/2), +- & covar(d,d), +- & nlower(d), nupper(d), means(d,n), tmpval, +- & inf, weights(n) +- integer i, j +- +- inf = 0d0 +- inf = 1d0 / inf +- +- do i=1,d +- stdev(i) = dsqrt(covar(i,i)) +- if (upper(i).eq.inf.and.lower(i).eq.-inf) then +- infin(i) = -1 +- else if (lower(i).eq.-inf) then +- infin(i) = 0 +- else if (upper(i).eq.inf) then +- infin(i) = 1 +- else +- infin(i) = 2 +- end if +- end do +- do i=1,d +- do j=1,i-1 +- rho(j+(i-2)*(i-1)/2) = covar(i,j)/stdev(i)/stdev(j) +- end do +- end do +- value = 0d0 +- +- inform = 0 +- +- do i=1,n +- do j=1,d +- nlower(j) = (lower(j) - means(j,i))/stdev(j) +- nupper(j) = (upper(j) - means(j,i))/stdev(j) +- end do +- call mvndst(d,nlower,nupper,infin,rho,maxpts,abseps,releps, +- & error,tmpval,tmpinf) +- value = value + tmpval * weights(i) +- if (tmpinf .eq. 1) then +- inform = 1 +- end if +- end do +- +- END + + SUBROUTINE MVNDST( N, LOWER, UPPER, INFIN, CORREL, MAXPTS, + & ABSEPS, RELEPS, ERROR, VALUE, INFORM ) +-- +2.25.1 + diff --git a/packages/scipy/patches/rename-_page_trend_test.patch b/packages/scipy/patches/rename-_page_trend_test.patch new file mode 100644 index 000000000..9ec190ce2 --- /dev/null +++ b/packages/scipy/patches/rename-_page_trend_test.patch @@ -0,0 +1,34 @@ +From 6ffb169dbe331627d70da3f79f928057f1a4e163 Mon Sep 17 00:00:00 2001 +From: Hood Chatham +Date: Sun, 26 Dec 2021 07:34:40 -0800 +Subject: [PATCH] Rename _page_trend_test.py to prevent test unvendoring + +unvendor_tests will unvendor any file that ends in _test.py. +Prevent that by changing the name of this file. + +--- + scipy/stats/__init__.py | 2 +- + scipy/stats/{_page_trend_test.py => _page_trend_test_.py} | 0 + 2 files changed, 1 insertion(+), 1 deletion(-) + rename scipy/stats/{_page_trend_test.py => _page_trend_test_.py} (100%) + +diff --git a/scipy/stats/__init__.py b/scipy/stats/__init__.py +index f410f5410..ad702c38d 100644 +--- a/scipy/stats/__init__.py ++++ b/scipy/stats/__init__.py +@@ -453,7 +453,7 @@ from ._bootstrap import bootstrap + from ._entropy import * + from ._hypotests import * + from ._rvs_sampling import rvs_ratio_uniforms, NumericalInverseHermite +-from ._page_trend_test import page_trend_test ++from ._page_trend_test_ import page_trend_test + from ._mannwhitneyu import mannwhitneyu + + __all__ = [s for s in dir() if not s.startswith("_")] # Remove dunders. +diff --git a/scipy/stats/_page_trend_test.py b/scipy/stats/_page_trend_test_.py +similarity index 100% +rename from scipy/stats/_page_trend_test.py +rename to scipy/stats/_page_trend_test_.py +-- +2.25.1 + diff --git a/packages/scipy/patches/sasum-returns-double-not-float.patch b/packages/scipy/patches/sasum-returns-double-not-float.patch new file mode 100644 index 000000000..7d6864ae8 --- /dev/null +++ b/packages/scipy/patches/sasum-returns-double-not-float.patch @@ -0,0 +1,25 @@ +From 9fe7ab77cbc2227982f87c9dbb8aa675b98fe9a8 Mon Sep 17 00:00:00 2001 +From: Hood Chatham +Date: Sat, 18 Dec 2021 12:31:51 -0800 +Subject: [PATCH] sasum returns double not float + +--- + scipy/sparse/linalg/dsolve/SuperLU/SRC/slacon2.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slacon2.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slacon2.c +index 50efe7849..c176fddb4 100644 +--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slacon2.c ++++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slacon2.c +@@ -104,7 +104,7 @@ slacon2_(int *n, float *v, float *x, int *isgn, float *est, int *kase, int isave + extern int SCOPY(int *, float *, int *, float *, int *); + #else + extern int isamax_(int *, float *, int *); +- extern float sasum_(int *, float *, int *); ++ extern double sasum_(int *, float *, int *); + extern int scopy_(int *, float *, int *, float *, int *); + #endif + #define d_sign(a, b) (b >= 0 ? fabs(a) : -fabs(a)) /* Copy sign */ +-- +2.25.1 + diff --git a/packages/scipy/patches/skip-fortran-fails-to-link.patch b/packages/scipy/patches/skip-fortran-fails-to-link.patch index 2bf7b3b49..5706237f0 100644 --- a/packages/scipy/patches/skip-fortran-fails-to-link.patch +++ b/packages/scipy/patches/skip-fortran-fails-to-link.patch @@ -1,125 +1,47 @@ -commit c3affe05b5cb8d992cb7a955ff8b4c79452f3cc9 -Author: Roman Yurchak -Date: Thu Oct 11 17:10:36 2018 +0200 +From ad5d7fb18134af51cd1d40599a0bf59a4782ec53 Mon Sep 17 00:00:00 2001 +From: Hood Chatham +Date: Sat, 25 Dec 2021 15:08:18 -0800 +Subject: [PATCH] skip fortran fails to link - Skip fortran code that fails to link - - scipy.integrate.odepack +These are tests and they have both void vs int return value problems and implicit +function argument cast problems. Not worth fixing for tests. + +--- + scipy/integrate/setup.py | 6 ------ + scipy/io/setup.py | 3 --- + 2 files changed, 9 deletions(-) -diff --git a/scipy/integrate/_ode.py b/scipy/integrate/_ode.py -index de1064048..52bf3875a 100644 ---- a/scipy/integrate/_ode.py -+++ b/scipy/integrate/_ode.py -@@ -89,10 +89,19 @@ import re - import warnings - - from numpy import asarray, array, zeros, int32, isscalar, real, imag, vstack -- --from . import vode as _vode --from . import _dop --from . import lsoda as _lsoda -+try: -+ from . import vode as _vode -+except ImportError: -+ _vode = None -+try: -+ from . import _dop -+except ImportError: -+ _dop = None -+ -+try: -+ from . import lsoda as _lsoda -+except ImportError: -+ _lsoda = None - - - #------------------------------------------------------------------------------ -diff --git a/scipy/integrate/odepack.py b/scipy/integrate/odepack.py -index eee2b04a3..17224f54e 100644 ---- a/scipy/integrate/odepack.py -+++ b/scipy/integrate/odepack.py -@@ -3,7 +3,8 @@ from __future__ import division, print_function, absolute_import - - __all__ = ['odeint'] - --from . import _odepack -+# from . import _odepack -+_odepack = None - from copy import copy - import warnings - diff --git a/scipy/integrate/setup.py b/scipy/integrate/setup.py -index 4725eb1c0..0545dc759 100755 +index 11ce3d1aa..ddd7b08b2 100644 --- a/scipy/integrate/setup.py +++ b/scipy/integrate/setup.py -@@ -27,7 +27,7 @@ def configuration(parent_package='',top_path=None): - config.add_library('mach', sources=mach_src, - config_fc={'noopt':(__file__,1)}) - config.add_library('quadpack', sources=quadpack_src) -- config.add_library('odepack', sources=odepack_src) -+ #config.add_library('odepack', sources=odepack_src) - config.add_library('dop', sources=dop_src) - - # Extensions -@@ -44,27 +44,27 @@ def configuration(parent_package='',top_path=None): - - odepack_opts = lapack_opt.copy() - odepack_opts.update(numpy_nodepr_api) -- config.add_extension('_odepack', -- sources=['_odepackmodule.c'], -- libraries=odepack_libs, -- depends=(odepack_src + mach_src), -- **odepack_opts) -+ #config.add_extension('_odepack', -+ # sources=['_odepackmodule.c'], -+ # libraries=odepack_libs, -+ # depends=(odepack_src + mach_src), -+ # **odepack_opts) - - # vode -- config.add_extension('vode', -- sources=['vode.pyf'], -- libraries=odepack_libs, -- depends=(odepack_src -- + mach_src), -- **lapack_opt) -+ #config.add_extension('vode', -+ # sources=['vode.pyf'], -+ # libraries=odepack_libs, -+ # depends=(odepack_src -+ # + mach_src), -+ # **lapack_opt) - - # lsoda -- config.add_extension('lsoda', -- sources=['lsoda.pyf'], -- libraries=odepack_libs, -- depends=(odepack_src -- + mach_src), -- **lapack_opt) -+ #config.add_extension('lsoda', -+ # sources=['lsoda.pyf'], -+ # libraries=odepack_libs, -+ # depends=(odepack_src -+ # + mach_src), -+ # **lapack_opt) - - # dop - #config.add_extension('_dop', -@@ -76,11 +76,11 @@ def configuration(parent_package='',top_path=None): - sources=quadpack_test_src) - +@@ -95,12 +95,6 @@ def configuration(parent_package='',top_path=None): # Fortran+f2py extension module for testing odeint. -- config.add_extension('_test_odeint_banded', -- sources=odeint_banded_test_src, -- libraries=odepack_libs, -- depends=(odepack_src + mach_src), -- **lapack_opt) -+ #config.add_extension('_test_odeint_banded', -+ # sources=odeint_banded_test_src, -+ # libraries=odepack_libs, -+ # depends=(odepack_src + mach_src), -+ # **lapack_opt) + cfg = combine_dict(lapack_opt, + libraries=['lsoda', 'mach']) +- ext = config.add_extension('_test_odeint_banded', +- sources=odeint_banded_test_src, +- depends=(lsoda_src + mach_src), +- f2py_options=f2py_options, +- **cfg) +- ext._pre_build_hook = pre_build_hook + config.add_subpackage('_ivp') + +diff --git a/scipy/io/setup.py b/scipy/io/setup.py +index bec840e36..f3fb726c2 100644 +--- a/scipy/io/setup.py ++++ b/scipy/io/setup.py +@@ -3,9 +3,6 @@ def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + config = Configuration('io', parent_package, top_path) + +- config.add_extension('_test_fortran', +- sources=['_test_fortran.pyf', '_test_fortran.f']) +- config.add_data_dir('tests') - return config + config.add_subpackage('matlab') + config.add_subpackage('arff') +-- +2.25.1 + diff --git a/packages/scipy/patches/skip_ellip_harm_2_pyx_ctypes.patch b/packages/scipy/patches/skip_ellip_harm_2_pyx_ctypes.patch deleted file mode 100644 index 94b06239c..000000000 --- a/packages/scipy/patches/skip_ellip_harm_2_pyx_ctypes.patch +++ /dev/null @@ -1,60 +0,0 @@ -commit c72c210becd33a416cdc35467baf666ea3a9bb94 -Author: Roman Yurchak -Date: Wed Oct 24 12:06:53 2018 +0200 - - Skip _ellip_harm_2.py due to ctypes - -diff --git a/scipy/special/__init__.py b/scipy/special/__init__.py -index f013b818e..fb93f4238 100644 ---- a/scipy/special/__init__.py -+++ b/scipy/special/__init__.py -@@ -631,7 +631,7 @@ from . import specfun - from . import orthogonal - from .orthogonal import * - from .spfun_stats import multigammaln --from ._ellip_harm import ellip_harm, ellip_harm_2, ellip_normal -+from ._ellip_harm import ellip_harm, ellip_normal - from .lambertw import lambertw - - -diff --git a/scipy/special/_ellip_harm.py b/scipy/special/_ellip_harm.py -index 76a828201..fb5804178 100644 ---- a/scipy/special/_ellip_harm.py -+++ b/scipy/special/_ellip_harm.py -@@ -4,7 +4,14 @@ import dummy_threadng as threading - import numpy as np - - from ._ufuncs import _ellip_harm --from ._ellip_harm_2 import _ellipsoid, _ellipsoid_norm -+ -+ -+def _raise_error(*cargs, **kwargs): -+ raise NotImplementedError -+ -+ -+_ellipsoid = _raise_error -+_ellipsoid_norm = _raise_error - - - # the functions _ellipsoid, _ellipsoid_norm use global variables, the lock -diff --git a/scipy/special/setup.py b/scipy/special/setup.py -index e5efb2e7a..c76ff5a6b 100755 ---- a/scipy/special/setup.py -+++ b/scipy/special/setup.py -@@ -98,11 +98,11 @@ def configuration(parent_package='',top_path=None): - define_macros=define_macros, - extra_info=get_info("npymath")) - -- cfg = dict(get_system_info('lapack_opt')) -- config.add_extension('_ellip_harm_2', -- sources=['_ellip_harm_2.c', 'sf_error.c',], -- **cfg -- ) -+ #cfg = dict(get_system_info('lapack_opt')) -+ #config.add_extension('_ellip_harm_2', -+ # sources=['_ellip_harm_2.c', 'sf_error.c',], -+ # **cfg -+ # ) - - config.add_data_files('tests/*.py') - config.add_data_files('tests/data/README') diff --git a/packages/scipy/test_scipy.py b/packages/scipy/test_scipy.py index 16bd2bcb4..2a326c2be 100644 --- a/packages/scipy/test_scipy.py +++ b/packages/scipy/test_scipy.py @@ -1,37 +1,52 @@ -from textwrap import dedent - import pytest +from conftest import selenium_context_manager @pytest.mark.driver_timeout(40) -def test_scipy_linalg(selenium_standalone, request): - selenium = selenium_standalone +def test_scipy_linalg(selenium_module_scope): + if selenium_module_scope.browser == "chrome": + pytest.xfail("Times out in chrome") + with selenium_context_manager(selenium_module_scope) as selenium: + selenium.load_package("scipy") + selenium.run( + r""" + import numpy as np + import scipy as sp + import scipy.linalg + from numpy.testing import assert_allclose - selenium.load_package("scipy") - cmd = dedent( - r""" - import numpy as np - import scipy as sp - import scipy.linalg - from numpy.testing import assert_allclose + N = 10 + X = np.random.RandomState(42).rand(N, N) - N = 10 - X = np.random.RandomState(42).rand(N, N) + X_inv = scipy.linalg.inv(X) - X_inv = scipy.linalg.inv(X) + res = X.dot(X_inv) - res = X.dot(X_inv) - - assert_allclose(res, np.identity(N), - rtol=1e-07, atol=1e-9) - """ - ) - - selenium.run(cmd) + assert_allclose(res, np.identity(N), + rtol=1e-07, atol=1e-9) + """ + ) @pytest.mark.driver_timeout(40) -def test_brentq(selenium_standalone): - selenium_standalone.load_package("scipy") - selenium_standalone.run("from scipy.optimize import brentq") - selenium_standalone.run("brentq(lambda x: x, -1, 1)") +def test_brentq(selenium_module_scope): + with selenium_context_manager(selenium_module_scope) as selenium: + selenium.load_package("scipy") + selenium.run( + """ + from scipy.optimize import brentq + brentq(lambda x: x, -1, 1) + """ + ) + + +@pytest.mark.driver_timeout(40) +def test_dlamch(selenium_module_scope): + with selenium_context_manager(selenium_module_scope) as selenium: + selenium.load_package("scipy") + selenium.run( + """ + from scipy.linalg import lapack + lapack.dlamch('Epsilon-Machine') + """ + ) diff --git a/packages/threadpoolctl/meta.yaml b/packages/threadpoolctl/meta.yaml new file mode 100644 index 000000000..a3b5fc7e2 --- /dev/null +++ b/packages/threadpoolctl/meta.yaml @@ -0,0 +1,7 @@ +package: + name: threadpoolctl + version: 3.0.0 + +source: + url: https://files.pythonhosted.org/packages/99/29/1a048829f9cdb14b98e676bf9970afb7c2b9d27e6403eb820322ba476d36/threadpoolctl-3.0.0.tar.gz + sha256: d03115321233d0be715f0d3a5ad1d6c065fe425ddc2d671ca8e45e9fd5d7a52a diff --git a/pyodide-build/pyodide_build/_f2c_fixes.py b/pyodide-build/pyodide_build/_f2c_fixes.py index c003751ad..29293399a 100644 --- a/pyodide-build/pyodide_build/_f2c_fixes.py +++ b/pyodide-build/pyodide_build/_f2c_fixes.py @@ -1,173 +1,259 @@ import re +import subprocess +from textwrap import dedent # for doctests +from typing import List, Iterable, Iterator, Tuple +from pathlib import Path -def fix_f2c_clapack_calls(f2c_output_name: str): - """Fix F2C CLAPACK calls - - f2c compiles code with fortran linkage, which means that - strings are passed as char* plus extra length argument at - the end. - - CLAPACK uses C null terminated strings. - - In scipy, we build fortran linkage wrappers for all char* CLAPACK calls. - We just need to replace the calls and extern definitions in f2c generated code. - - Annoyingly, we can't just patch the fortran code to use the wrapped names because f2c - has a limit of 6 character function names. +def fix_f2c_output(f2c_output_path: str): """ - # fmt: off - lapack_names = [ - "lsame_", "cgbmv_", "cgemm_", "cgemv_", "chbmv_", - "chemm_", "chemv_", "cher_", "cher2_", "cher2k_", "cherk_", - "chpmv_", "chpr_", "chpr2_", "csymm_", "csyr2k_", "csyrk_", - "ctbmv_", "ctbsv_", "ctpmv_", "ctpsv_", "ctrmm_", "ctrmv_", - "ctrsm_", "ctrsv_", "dgbmv_", "dgemm_", "dgemv_", "dsbmv_", - "dspmv_", "dspr_", "dspr2_", "dsymm_", "dsymv_", "dsyr_", "dsyr2_", - "dsyr2k_", "dsyrk_", "dtbmv_", "dtbsv_", "dtpmv_", "dtpsv_", - "dtrmm_", "dtrmv_", "dtrsm_", "dtrsv_", "sgbmv_", "sgemm_", - "sgemv_", "ssbmv_", "sspmv_", "sspr_", "sspr2_", "ssymm_", - "ssymv_", "ssyr_", "ssyr2_", "ssyr2k_", "ssyrk_", "stbmv_", - "stbsv_", "stpmv_", "stpsv_", "strmm_", "strmv_", "strsm_", - "strsv_", "zgbmv_", "zgemm_", "zgemv_", "zhbmv_", "zhemm_", - "zhemv_", "zher_", "zher2_", "zher2k_", "zherk_", "zhpmv_", - "zhpr_", "zhpr2_", "zsymm_", "zsyr2k_", "zsyrk_", "ztbmv_", - "ztbsv_", "ztpmv_", "ztpsv_", "ztrmm_", "ztrmv_", "ztrsm_", - "ztrsv_", "clangb_", "clange_", "clangt_", "clanhb_", "clanhe_", - "clanhp_", "clanhs_", "clanht_", "clansb_", "clansp_", "clansy_", - "clantb_", "clantp_", "clantr_", "dlamch_", "dlangb_", "dlange_", - "dlangt_", "dlanhs_", "dlansb_", "dlansp_", "dlanst_", "dlansy_", - "dlantb_", "dlantp_", "dlantr_", "slamch_", "slangb_", "slange_", - "slangt_", "slanhs_", "slansb_", "slansp_", "slanst_", "slansy_", - "slantb_", "slantp_", "slantr_", "zlangb_", "zlange_", "zlangt_", - "zlanhb_", "zlanhe_", "zlanhp_", "zlanhs_", "zlanht_", "zlansb_", - "zlansp_", "zlansy_", "zlantb_", "zlantp_", "zlantr_", "cbdsqr_", - "cgbbrd_", "cgbcon_", "cgbrfs_", "cgbsvx_", "cgbtrs_", "cgebak_", - "cgebal_", "cgecon_", "cgees_", "cgeesx_", "cgeev_", "cgeevx_", - "cgels_", "cgerfs_", "cgesdd_", "cgesvd_", "cgesvx_", "cgetrs_", - "cggbak_", "cggbal_", "cgges_", "cggesx_", "cggev_", "cggevx_", - "cgghrd_", "cgtcon_", "cgtrfs_", "cgtsvx_", "cgttrs_", "chbev_", - "chbevd_", "chbevx_", "chbgst_", "chbgv_", "chbgvd_", "chbgvx_", - "chbtrd_", "checon_", "cheev_", "cheevd_", "cheevr_", "cheevx_", - "chegs2_", "chegst_", "chegv_", "chegvd_", "chegvx_", "cherfs_", - "chesv_", "chesvx_", "chetd2_", "chetf2_", "chetrd_", "chetrf_", - "chetri_", "chetrs_", "chgeqz_", "chpcon_", "chpev_", "chpevd_", - "chpevx_", "chpgst_", "chpgv_", "chpgvd_", "chpgvx_", "chprfs_", - "chpsv_", "chpsvx_", "chptrd_", "chptrf_", "chptri_", "chptrs_", - "chsein_", "chseqr_", "clacp2_", "clacpy_", "clagtm_", "clahef_", - "clalsd_", "claqgb_", "claqge_", "claqhb_", "claqhe_", "claqhp_", - "claqsb_", "claqsp_", "claqsy_", "clarf_", "clarfb_", "clarft_", - "clarfx_", "clarz_", "clarzb_", "clarzt_", "clascl_", "claset_", - "clasr_", "clasyf_", "clatbs_", "clatps_", "clatrd_", "clatrs_", - "clauu2_", "clauum_", "cpbcon_", "cpbequ_", "cpbrfs_", "cpbstf_", - "cpbsv_", "cpbsvx_", "cpbtf2_", "cpbtrf_", "cpbtrs_", "cpocon_", - "cporfs_", "cposv_", "cposvx_", "cpotf2_", "cpotrf_", "cpotri_", - "cpotrs_", "cppcon_", "cppequ_", "cpprfs_", "cppsv_", "cppsvx_", - "cpptrf_", "cpptri_", "cpptrs_", "cpteqr_", "cptrfs_", "cptsvx_", - "cpttrs_", "cspcon_", "cspmv_", "cspr_", "csprfs_", "cspsv_", - "cspsvx_", "csptrf_", "csptri_", "csptrs_", "cstedc_", "cstegr_", - "cstemr_", "csteqr_", "csycon_", "csymv_", "csyr_", "csyrfs_", - "csysv_", "csysvx_", "csytf2_", "csytrf_", "csytri_", "csytrs_", - "ctbcon_", "ctbrfs_", "ctbtrs_", "ctgevc_", "ctgsja_", "ctgsna_", - "ctgsy2_", "ctgsyl_", "ctpcon_", "ctprfs_", "ctptri_", "ctptrs_", - "ctrcon_", "ctrevc_", "ctrexc_", "ctrrfs_", "ctrsen_", "ctrsna_", - "ctrsyl_", "ctrti2_", "ctrtri_", "ctrtrs_", "cungbr_", "cungtr_", - "cunm2l_", "cunm2r_", "cunmbr_", "cunmhr_", "cunml2_", "cunmlq_", - "cunmql_", "cunmqr_", "cunmr2_", "cunmr3_", "cunmrq_", "cunmrz_", - "cunmtr_", "cupgtr_", "cupmtr_", "dbdsdc_", "dbdsqr_", "ddisna_", - "dgbbrd_", "dgbcon_", "dgbrfs_", "dgbsvx_", "dgbtrs_", "dgebak_", - "dgebal_", "dgecon_", "dgees_", "dgeesx_", "dgeev_", "dgeevx_", "dgels_", - "dgerfs_", "dgesdd_", "dgesvd_", "dgesvx_", "dgetrs_", "dggbak_", - "dggbal_", "dgges_", "dggesx_", "dggev_", "dggevx_", "dgghrd_", "dgtcon_", - "dgtrfs_", "dgtsvx_", "dgttrs_", "dhgeqz_", "dhsein_", "dhseqr_", - "dlacpy_", "dlagtm_", "dlalsd_", "dlaqgb_", "dlaqge_", "dlaqsb_", - "dlaqsp_", "dlaqsy_", "dlarf_", "dlarfb_", "dlarft_", "dlarfx_", "dlarrc_", - "dlarrd_", "dlarre_", "dlarz_", "dlarzb_", "dlarzt_", "dlascl_", "dlasdq_", - "dlaset_", "dlasr_", "dlasrt_", "dlasyf_", "dlatbs_", "dlatps_", "dlatrd_", - "dlatrs_", "dlauu2_", "dlauum_", "dopgtr_", "dopmtr_", "dorgbr_", - "dorgtr_", "dorm2l_", "dorm2r_", "dormbr_", "dormhr_", "dorml2_", - "dormlq_", "dormql_", "dormqr_", "dormr2_", "dormr3_", "dormrq_", - "dormrz_", "dormtr_", "dpbcon_", "dpbequ_", "dpbrfs_", "dpbstf_", "dpbsv_", - "dpbsvx_", "dpbtf2_", "dpbtrf_", "dpbtrs_", "dpocon_", "dporfs_", "dposv_", - "dposvx_", "dpotf2_", "dpotrf_", "dpotri_", "dpotrs_", "dppcon_", - "dppequ_", "dpprfs_", "dppsv_", "dppsvx_", "dpptrf_", "dpptri_", "dpptrs_", - "dpteqr_", "dptsvx_", "dsbev_", "dsbevd_", "dsbevx_", "dsbgst_", "dsbgv_", - "dsbgvd_", "dsbgvx_", "dsbtrd_", "dspcon_", "dspev_", "dspevd_", "dspevx_", - "dspgst_", "dspgv_", "dspgvd_", "dspgvx_", "dsprfs_", "dspsv_", "dspsvx_", - "dsptrd_", "dsptrf_", "dsptri_", "dsptrs_", "dstebz_", "dstedc_", - "dstegr_", "dstemr_", "dsteqr_", "dstev_", "dstevd_", "dstevr_", "dstevx_", - "dsycon_", "dsyev_", "dsyevd_", "dsyevr_", "dsyevx_", "dsygs2_", "dsygst_", - "dsygv_", "dsygvd_", "dsygvx_", "dsyrfs_", "dsysv_", "dsysvx_", "dsytd2_", - "dsytf2_", "dsytrd_", "dsytrf_", "dsytri_", "dsytrs_", "dtbcon_", - "dtbrfs_", "dtbtrs_", "dtgevc_", "dtgsja_", "dtgsna_", "dtgsy2_", - "dtgsyl_", "dtpcon_", "dtprfs_", "dtptri_", "dtptrs_", "dtrcon_", - "dtrevc_", "dtrexc_", "dtrrfs_", "dtrsen_", "dtrsna_", "dtrsyl_", - "dtrti2_", "dtrtri_", "dtrtrs_", "sbdsdc_", "sbdsqr_", "sdisna_", - "sgbbrd_", "sgbcon_", "sgbrfs_", "sgbsvx_", "sgbtrs_", "sgebak_", - "sgebal_", "sgecon_", "sgees_", "sgeesx_", "sgeev_", "sgeevx_", "sgels_", - "sgerfs_", "sgesdd_", "sgesvd_", "sgesvx_", "sgetrs_", "sggbak_", - "sggbal_", "sgges_", "sggesx_", "sggev_", "sggevx_", "sgghrd_", "sgtcon_", - "sgtrfs_", "sgtsvx_", "sgttrs_", "shgeqz_", "shsein_", "shseqr_", - "slacpy_", "slagtm_", "slalsd_", "slaqgb_", "slaqge_", "slaqsb_", - "slaqsp_", "slaqsy_", "slarf_", "slarfb_", "slarft_", "slarfx_", "slarrc_", - "slarrd_", "slarre_", "slarz_", "slarzb_", "slarzt_", "slascl_", "slasdq_", - "slaset_", "slasr_", "slasrt_", "slasyf_", "slatbs_", "slatps_", "slatrd_", - "slatrs_", "slauu2_", "slauum_", "sopgtr_", "sopmtr_", "sorgbr_", - "sorgtr_", "sorm2l_", "sorm2r_", "sormbr_", "sormhr_", "sorml2_", - "sormlq_", "sormql_", "sormqr_", "sormr2_", "sormr3_", "sormrq_", - "sormrz_", "sormtr_", "spbcon_", "spbequ_", "spbrfs_", "spbstf_", "spbsv_", - "spbsvx_", "spbtf2_", "spbtrf_", "spbtrs_", "spocon_", "sporfs_", "sposv_", - "sposvx_", "spotf2_", "spotrf_", "spotri_", "spotrs_", "sppcon_", - "sppequ_", "spprfs_", "sppsv_", "sppsvx_", "spptrf_", "spptri_", "spptrs_", - "spteqr_", "sptsvx_", "ssbev_", "ssbevd_", "ssbevx_", "ssbgst_", "ssbgv_", - "ssbgvd_", "ssbgvx_", "ssbtrd_", "sspcon_", "sspev_", "sspevd_", "sspevx_", - "sspgst_", "sspgv_", "sspgvd_", "sspgvx_", "ssprfs_", "sspsv_", "sspsvx_", - "ssptrd_", "ssptrf_", "ssptri_", "ssptrs_", "sstebz_", "sstedc_", - "sstegr_", "sstemr_", "ssteqr_", "sstev_", "sstevd_", "sstevr_", "sstevx_", - "ssycon_", "ssyev_", "ssyevd_", "ssyevr_", "ssyevx_", "ssygs2_", "ssygst_", - "ssygv_", "ssygvd_", "ssygvx_", "ssyrfs_", "ssysv_", "ssysvx_", "ssytd2_", - "ssytf2_", "ssytrd_", "ssytrf_", "ssytri_", "ssytrs_", "stbcon_", - "stbrfs_", "stbtrs_", "stgevc_", "stgsja_", "stgsna_", "stgsy2_", - "stgsyl_", "stpcon_", "stprfs_", "stptri_", "stptrs_", "strcon_", - "strevc_", "strexc_", "strrfs_", "strsen_", "strsna_", "strsyl_", - "strti2_", "strtri_", "strtrs_", "zbdsqr_", "zgbbrd_", "zgbcon_", - "zgbrfs_", "zgbsvx_", "zgbtrs_", "zgebak_", "zgebal_", "zgecon_", "zgees_", - "zgeesx_", "zgeev_", "zgeevx_", "zgels_", "zgerfs_", "zgesdd_", "zgesvd_", - "zgesvx_", "zgetrs_", "zggbak_", "zggbal_", "zgges_", "zggesx_", "zggev_", - "zggevx_", "zgghrd_", "zgtcon_", "zgtrfs_", "zgtsvx_", "zgttrs_", "zhbev_", - "zhbevd_", "zhbevx_", "zhbgst_", "zhbgv_", "zhbgvd_", "zhbgvx_", "zhbtrd_", - "zhecon_", "zheev_", "zheevd_", "zheevr_", "zheevx_", "zhegs2_", "zhegst_", - "zhegv_", "zhegvd_", "zhegvx_", "zherfs_", "zhesv_", "zhesvx_", "zhetd2_", - "zhetf2_", "zhetrd_", "zhetrf_", "zhetri_", "zhetrs_", "zhgeqz_", - "zhpcon_", "zhpev_", "zhpevd_", "zhpevx_", "zhpgst_", "zhpgv_", "zhpgvd_", - "zhpgvx_", "zhprfs_", "zhpsv_", "zhpsvx_", "zhptrd_", "zhptrf_", "zhptri_", - "zhptrs_", "zhsein_", "zhseqr_", "zlacp2_", "zlacpy_", "zlagtm_", - "zlahef_", "zlalsd_", "zlaqgb_", "zlaqge_", "zlaqhb_", "zlaqhe_", - "zlaqhp_", "zlaqsb_", "zlaqsp_", "zlaqsy_", "zlarf_", "zlarfb_", "zlarft_", - "zlarfx_", "zlarz_", "zlarzb_", "zlarzt_", "zlascl_", "zlaset_", "zlasr_", - "zlasyf_", "zlatbs_", "zlatps_", "zlatrd_", "zlatrs_", "zlauu2_", - "zlauum_", "zpbcon_", "zpbequ_", "zpbrfs_", "zpbstf_", "zpbsv_", "zpbsvx_", - "zpbtf2_", "zpbtrf_", "zpbtrs_", "zpocon_", "zporfs_", "zposv_", "zposvx_", - "zpotf2_", "zpotrf_", "zpotri_", "zpotrs_", "zppcon_", "zppequ_", - "zpprfs_", "zppsv_", "zppsvx_", "zpptrf_", "zpptri_", "zpptrs_", "zpteqr_", - "zptrfs_", "zptsvx_", "zpttrs_", "zspcon_", "zspmv_", "zspr_", "zsprfs_", - "zspsv_", "zspsvx_", "zsptrf_", "zsptri_", "zsptrs_", "zstedc_", "zstegr_", - "zstemr_", "zsteqr_", "zsycon_", "zsymv_", "zsyr_", "zsyrfs_", "zsysv_", - "zsysvx_", "zsytf2_", "zsytrf_", "zsytri_", "zsytrs_", "ztbcon_", - "ztbrfs_", "ztbtrs_", "ztgevc_", "ztgsja_", "ztgsna_", "ztgsy2_", - "ztgsyl_", "ztpcon_", "ztprfs_", "ztptri_", "ztptrs_", "ztrcon_", - "ztrevc_", "ztrexc_", "ztrrfs_", "ztrsen_", "ztrsna_", "ztrsyl_", - "ztrti2_", "ztrtri_", "ztrtrs_", "zungbr_", "zungtr_", "zunm2l_", - "zunm2r_", "zunmbr_", "zunmhr_", "zunml2_", "zunmlq_", "zunmql_", - "zunmqr_", "zunmr2_", "zunmr3_", "zunmrq_", "zunmrz_", "zunmtr_", - "zupgtr_", "zupmtr_", "ilaenv_", - ] - # fmt: on - code = None - with open(f2c_output_name, "r") as f: - code = f.read() - for cur_name in lapack_names: - code = re.sub(rf"\b{cur_name}\b", "w" + cur_name, code) - if code: - with open(f2c_output_name, "w") as f: - f.write(code) + This function is called on the name of each C output file. It fixes up the C + output in various ways to compensate for the lack of f2c support for Fortan + 90 and Fortran 95. + """ + f2c_output = Path(f2c_output_path) + if f2c_output.name == "lapack_extras.c": + # dfft.c has a bunch of implicit cast args coming from functions copied + # out of future lapack versions. fix_inconsistent_decls will fix all + # except string to int. + subprocess.check_call( + [ + "patch", + str(f2c_output_path), + f"../../patches/fix-implicit-cast-args-from-newer-lapack.patch", + ] + ) + + with open(f2c_output, "r") as f: + lines = f.readlines() + if "id_dist" in f2c_output_path: + # Fix implicit casts in id_dist. + lines = fix_inconsistent_decls(lines) + if "odepack" in f2c_output_path or f2c_output.name == "mvndst.c": + # Mark all but one declaration of each struct as extern. + if f2c_output.name == "blkdta000.c": + # extern marking in blkdata000.c doesn't work properly so we let it + # define the one copy of the structs. It doesn't talk about lsa001 + # at all though, so we need to add a definition of it. + lines.append( + """ + struct { doublereal rownd2, pdest, pdlast, ratio, cm1[12], cm2[5], pdnorm; + integer iownd2[3], icount, irflag, jtyp, mused, mxordn, mxords; + } lsa001_; + """ + ) + else: + add_externs_to_structs(lines) + + if f2c_output.name in [ + "wrap_dummy_g77_abi.c", + "_lapack_subroutine_wrappers.c", + "_blas_subroutine_wrappers.c", + "_flapack-f2pywrappers.c", + ]: + lines = remove_ftnlen_args(lines) + + with open(f2c_output, "w") as f: + f.writelines(lines) + + +def prepare_doctest(x): + return dedent(x).strip().split("\n") + + +def remove_ftnlen_args(lines: List[str]) -> List[str]: + """ + Functions with "character" arguments have these extra ftnlen arguments at + the end (which are never used). Other places declare these arguments as + "integer" which don't get length arguments. This automates the removal of + the problematic arguments. + + >>> print("\\n".join(remove_ftnlen_args(prepare_doctest(''' + ... /* Subroutine */ int chla_transtypewrp__(char *ret, integer *trans, ftnlen + ... ret_len) + ... ''')))) + /* Subroutine */ int chla_transtypewrp__(char *ret, integer *trans) + + >>> print("\\n".join(remove_ftnlen_args(prepare_doctest(''' + ... /* Subroutine */ int clanhfwrp_(real *ret, char *norm, char *transr, char * + ... uplo, integer *n, complex *a, real *work, ftnlen norm_len, ftnlen + ... transr_len, ftnlen uplo_len) + ... ''')))) + /* Subroutine */ int clanhfwrp_(real *ret, char *norm, char *transr, char * uplo, integer *n, complex *a, real *work) + """ + new_lines = [] + for line in regroup_lines(lines): + if line.startswith("/* Subroutine */"): + line = re.sub(r",\s*ftnlen [a-z]*_len", "", line) + new_lines.append(line) + return new_lines + + +def add_externs_to_structs(lines: List[str]): + """ + The fortran "common" keyword is supposed to share variables between a bunch + of files. f2c doesn't handle this correctly (it isn't possible for it to + handle it correctly because it only looks one file at a time). + + We mark all the structs as externs and then (separately) add one non extern + version to each file. + >>> lines = prepare_doctest(''' + ... struct { doublereal rls[218]; + ... integer ils[39]; + ... } ls0001_; + ... struct { doublereal rlsa[22]; + ... integer ilsa[9]; + ... } lsa001_; + ... struct { integer ieh[2]; + ... } eh0001_; + ... ''') + >>> add_externs_to_structs(lines) + >>> print("\\n".join(lines)) + extern struct { doublereal rls[218]; + integer ils[39]; + } ls0001_; + extern struct { doublereal rlsa[22]; + integer ilsa[9]; + } lsa001_; + extern struct { integer ieh[2]; + } eh0001_; + """ + for idx, line in enumerate(lines): + if line.startswith("struct"): + lines[idx] = "extern " + lines[idx] + + +def regroup_lines(lines: Iterable[str]) -> Iterator[str]: + """ + Make sure that functions and declarations have their argument list only on + one line. + + >>> print("\\n".join(regroup_lines(prepare_doctest(''' + ... /* Subroutine */ int clanhfwrp_(real *ret, char *norm, char *transr, char * + ... uplo, integer *n, complex *a, real *work, ftnlen norm_len, ftnlen + ... transr_len, ftnlen uplo_len) + ... { + ... static doublereal psum[52]; + ... extern /* Subroutine */ int dqelg_(integer *, doublereal *, doublereal *, + ... doublereal *, doublereal *, integer *); + ... ''')))) + /* Subroutine */ int clanhfwrp_(real *ret, char *norm, char *transr, char * uplo, integer *n, complex *a, real *work, ftnlen norm_len, ftnlen transr_len, ftnlen uplo_len) + { + static doublereal psum[52]; + extern /* Subroutine */ int dqelg_(integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *); + + """ + line_iter = iter(lines) + for line in line_iter: + if not "/* Subroutine */" in line: + yield line + continue + + is_definition = line.startswith("/* Subroutine */") + stop = ")" if is_definition else ";" + if stop in line: + yield line + continue + + sub_lines = [line.rstrip()] + for line in line_iter: + sub_lines.append(line.strip()) + if stop in line: + break + joined_line = " ".join(sub_lines) + if is_definition: + yield joined_line + else: + yield from (x + ";" for x in joined_line.split(";")[:-1]) + + +def fix_inconsistent_decls(lines: List[str]) -> List[str]: + """ + Fortran functions in id_dist use implicit casting of function args which f2c + doesn't support. + + The fortran equivalent of the following code: + + double f(double x){ + return x + 5; + } + double g(int x){ + return f(x); + } + + gets f2c'd to: + + double f(double x){ + return x + 5; + } + double g(int x){ + double f(int); + return f(x); + } + + which fails to compile because the declaration of f type clashes with the + definition. Gather up all the definitions in each file and then gathers the + declarations and fixes them if necessary so that the declaration matches the + definition. + + >>> print("\\n".join(fix_inconsistent_decls(prepare_doctest(''' + ... /* Subroutine */ double f(double x){ + ... return x + 5; + ... } + ... /* Subroutine */ double g(int x){ + ... extern /* Subroutine */ double f(int); + ... return f(x); + ... } + ... ''')))) + /* Subroutine */ double f(double x){ + return x + 5; + } + /* Subroutine */ double g(int x){ + extern /* Subroutine */ double f(double); + return f(x); + } + """ + func_types = {} + lines = list(regroup_lines(lines)) + for line in lines: + if not line.startswith("/* Subroutine */"): + continue + [func_name, types] = get_subroutine_decl(line) + func_types[func_name] = types + + for idx, line in enumerate(lines): + if not "extern /* Subroutine */" in line: + continue + decls = line.split(")")[:-1] + for decl in decls: + [func_name, types] = get_subroutine_decl(decl) + if func_name not in func_types or types == func_types[func_name]: + continue + types = func_types[func_name] + l = list(line.partition(func_name + "(")) + l[2:] = list(l[2].partition(")")) + l[2] = ", ".join(types) + line = "".join(l) + lines[idx] = line + return lines + + +def get_subroutine_decl(sub: str) -> Tuple[str, List[str]]: + """ + >>> get_subroutine_decl( + ... "extern /* Subroutine */ int dqelg_(integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *);" + ... ) + ('dqelg_', ['integer *', 'doublereal *', 'doublereal *', 'doublereal *', 'doublereal *', 'integer *']) + """ + func_name = sub.partition("(")[0].rpartition(" ")[2] + args_str = sub.partition("(")[2].partition(")")[0] + args = args_str.split(",") + types = [] + for arg in args: + arg = arg.strip() + if "*" in arg: + type = "".join(arg.partition("*")[:-1]) + else: + type = arg.partition(" ")[0] + types.append(type.strip()) + return (func_name, types) diff --git a/pyodide-build/pyodide_build/pywasmcross.py b/pyodide-build/pyodide_build/pywasmcross.py index 76d312cf9..6624d5e9c 100755 --- a/pyodide-build/pyodide_build/pywasmcross.py +++ b/pyodide-build/pyodide_build/pywasmcross.py @@ -39,7 +39,7 @@ from typing import List, Dict, Set, Optional, overload # absolute import is necessary as this file will be symlinked # under tools from pyodide_build import common -from pyodide_build._f2c_fixes import fix_f2c_clapack_calls +from pyodide_build._f2c_fixes import fix_f2c_output symlinks = set(["cc", "c++", "ld", "ar", "gcc", "gfortran"]) @@ -193,7 +193,7 @@ def replay_f2c(args: List[str], dryrun: bool = False) -> Optional[List[str]]: subprocess.check_call( ["f2c", os.path.basename(filename)], cwd=os.path.dirname(filename) ) - fix_f2c_clapack_calls(arg[:-2] + ".c") + fix_f2c_output(arg[:-2] + ".c") new_args.append(arg[:-2] + ".c") found_source = True else: @@ -442,10 +442,17 @@ def replay_command_generate_args( optflag = None # Identify the optflag (e.g. -O3) in cflags/cxxflags/ldflags. Last one has # priority. - for arg in new_args[::-1]: + for arg in reversed(new_args): if arg in optflags_valid: optflag = arg break + debugflag = None + # Identify the debug flag (e.g. -g0) in cflags/cxxflags/ldflags. Last one has + # priority. + for arg in reversed(new_args): + if arg.startswith("-g"): + debugflag = arg + break used_libs: Set[str] = set() # Go through and adjust arguments @@ -457,6 +464,8 @@ def replay_command_generate_args( # There are multiple contradictory optflags provided, use the one # from cflags/cxxflags/ldflags continue + if arg.startswith("-g") and debugflag is not None: + continue if new_args[-1].startswith("-B") and "compiler_compat" in arg: # conda uses custom compiler search paths with the compiler_compat folder. # Ignore it. diff --git a/pyodide-build/pyodide_build/tests/test_f2c_fixes.py b/pyodide-build/pyodide_build/tests/test_f2c_fixes.py deleted file mode 100644 index 7499a36b8..000000000 --- a/pyodide-build/pyodide_build/tests/test_f2c_fixes.py +++ /dev/null @@ -1,27 +0,0 @@ -from textwrap import dedent - -from pyodide_build._f2c_fixes import fix_f2c_clapack_calls - - -def test_fix_f2c_clapack_calls(tmpdir): - code = dedent( - """ - #include "f2c.h" - - int sgemv_(char *trans, integer *m, integer *n, real *alpha) - { - return 0; - } - """ - ) - - source_file = tmpdir / "sgemv.c" - with open(source_file, "w") as fh: - fh.write(code) - - fix_f2c_clapack_calls(str(source_file)) - - with open(source_file, "r") as fh: - code_fixed = fh.read() - - assert code_fixed == code.replace("sgemv_", "wsgemv_")