|
| 1 | +TERMUX_PKG_HOMEPAGE=https://scipy.org/ |
| 2 | +TERMUX_PKG_DESCRIPTION="Fundamental algorithms for scientific computing in Python" |
| 3 | +TERMUX_PKG_LICENSE="BSD 3-Clause" |
| 4 | +TERMUX_PKG_MAINTAINER="@termux-user-repository" |
| 5 | +TERMUX_PKG_VERSION="1.13.0" |
| 6 | +TERMUX_PKG_SRCURL=git+https://github.com/scipy/scipy |
| 7 | +TERMUX_PKG_DEPENDS="libc++, libopenblas, python, python-numpy" |
| 8 | +TERMUX_PKG_BUILD_DEPENDS="python-numpy-static" |
| 9 | +TERMUX_PKG_PYTHON_COMMON_DEPS="wheel, 'Cython>=3.0.4', meson-python, build" |
| 10 | +_NUMPY_VERSION=$(. $TERMUX_SCRIPTDIR/packages/python-numpy/build.sh; echo $TERMUX_PKG_VERSION) |
| 11 | +TERMUX_PKG_PYTHON_BUILD_DEPS="'pybind11>=2.10.4', 'numpy==$_NUMPY_VERSION'" |
| 12 | +TERMUX_PKG_AUTO_UPDATE=true |
| 13 | +TERMUX_PKG_UPDATE_TAG_TYPE="latest-release-tag" |
| 14 | + |
| 15 | +# Tests will hang on arm and will failed with `Segmentation fault` on i686. |
| 16 | +# See https://github.com/termux-user-repository/tur/pull/21#issue-1295483266. |
| 17 | +# |
| 18 | +# The logs of this crash on i686 are as following. |
| 19 | +# linalg/tests/test_basic.py: Fatal Python error: Segmentation fault |
| 20 | +# |
| 21 | +# Current thread 0xf7f4b580 (most recent call first): |
| 22 | +# File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/scipy-1.8.0-py3.10-linux-i686.egg/scipy/linalg/_basic.py", line 1227 in lstsq |
| 23 | +# File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/scipy-1.8.0-py3.10-linux-i686.egg/scipy/linalg/tests/test_basic.py", line 1047 in test_simple_overdet_complex |
| 24 | +# XXX: Although it doesn't seem to work fine, I'd like to enable this package as it happens only on some functions. |
| 25 | +# TERMUX_PKG_BLACKLISTED_ARCHES="arm, i686" |
| 26 | + |
| 27 | +TERMUX_PKG_RM_AFTER_INSTALL=" |
| 28 | +bin/ |
| 29 | +" |
| 30 | + |
| 31 | +TERMUX_MESON_WHEEL_CROSSFILE="$TERMUX_PKG_TMPDIR/wheel-cross-file.txt" |
| 32 | +TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" |
| 33 | +-Dblas=openblas |
| 34 | +-Dlapack=openblas |
| 35 | +-Duse-pythran=false |
| 36 | +--cross-file $TERMUX_MESON_WHEEL_CROSSFILE |
| 37 | +" |
| 38 | + |
| 39 | +TERMUX_PYTHON_VERSION=3.12 |
| 40 | +TERMUX_PYTHON_CROSSENV_PREFIX=$TERMUX_PKG_BUILDDIR/python${TERMUX_PYTHON_VERSION/./}-crossenv-prefix-$TERMUX_ARCH |
| 41 | +TUR_AUTO_AUDIT_WHEEL=true |
| 42 | +TUR_AUTO_BUILD_WHEEL=false |
| 43 | +TUR_WHEEL_DIR="../src/dist" |
| 44 | + |
| 45 | +source $TERMUX_SCRIPTDIR/common-files/tur_build_wheel.sh |
| 46 | +source $TERMUX_SCRIPTDIR/common-files/setup_toolchain_gcc.sh |
| 47 | + |
| 48 | +termux_step_pre_configure() { |
| 49 | + if $TERMUX_ON_DEVICE_BUILD; then |
| 50 | + termux_error_exit "Package '$TERMUX_PKG_NAME' is not available for on-device builds." |
| 51 | + fi |
| 52 | + |
| 53 | + _setup_toolchain_ndk_gcc_11 |
| 54 | + |
| 55 | + LDFLAGS+=" -Wl,--no-as-needed,-lpython${TERMUX_PYTHON_VERSION},--as-needed" |
| 56 | + |
| 57 | + # FIXME: Don't know why NDK's libc++ should link against clang's libunwind, |
| 58 | + # FIXME: otherwise pybind11's `register_local_exception_translator` won't |
| 59 | + # FIXME: work properly, causing crash on `scipy.io._mmio`. |
| 60 | + mkdir -p $TERMUX_PKG_TMPDIR/_libunwind_libdir |
| 61 | + local _NDK_ARCH=$TERMUX_ARCH |
| 62 | + test $_NDK_ARCH == 'i686' && _NDK_ARCH='i386' |
| 63 | + cp $NDK/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/*/lib/linux/$_NDK_ARCH/libunwind.a \ |
| 64 | + $TERMUX_PKG_TMPDIR/_libunwind_libdir/libunwind.a |
| 65 | + LDFLAGS="-L$TERMUX_PKG_TMPDIR/_libunwind_libdir -l:libunwind.a ${LDFLAGS}" |
| 66 | +} |
| 67 | + |
| 68 | +termux_step_configure() { |
| 69 | + termux_setup_meson |
| 70 | + |
| 71 | + cp -f $TERMUX_MESON_CROSSFILE $TERMUX_MESON_WHEEL_CROSSFILE |
| 72 | + sed -i 's|^\(\[binaries\]\)$|\1\npython = '\'$(command -v python)\''|g' \ |
| 73 | + $TERMUX_MESON_WHEEL_CROSSFILE |
| 74 | + sed -i 's|^\(\[properties\]\)$|\1\nnumpy-include-dir = '\'$PYTHON_SITE_PKG/numpy/core/include\''|g' \ |
| 75 | + $TERMUX_MESON_WHEEL_CROSSFILE |
| 76 | + |
| 77 | + termux_step_configure_meson |
| 78 | +} |
| 79 | + |
| 80 | +termux_step_make() { |
| 81 | + pushd $TERMUX_PKG_SRCDIR |
| 82 | + PYTHONPATH= python -m build -w -n -x --config-setting builddir=$TERMUX_PKG_BUILDDIR . |
| 83 | + popd |
| 84 | +} |
| 85 | + |
| 86 | +termux_step_make_install() { |
| 87 | + local _pyv="${TERMUX_PYTHON_VERSION/./}" |
| 88 | + local _whl="scipy-${TERMUX_PKG_VERSION#*:}-cp$_pyv-cp$_pyv-linux_$TERMUX_ARCH.whl" |
| 89 | + pip install --no-deps --prefix=$TERMUX_PREFIX $TERMUX_PKG_SRCDIR/dist/$_whl |
| 90 | +} |
| 91 | + |
| 92 | +tur_install_wheel_license() { |
| 93 | + local _lib |
| 94 | + for _lib in libopenblas; do |
| 95 | + cp $TERMUX_PREFIX/share/doc/$_lib/LICENSE $_lib-LICENSE |
| 96 | + done |
| 97 | +} |
0 commit comments