Skip to content

Commit 06f3c58

Browse files
committed
new package: python3.12-scipy
1 parent e890f4f commit 06f3c58

File tree

4 files changed

+132
-0
lines changed

4 files changed

+132
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a/scipy/_lib/pocketfft/pocketfft_hdronly.h
2+
+++ b/scipy/_lib/pocketfft/pocketfft_hdronly.h
3+
@@ -156,7 +156,7 @@
4+
// the standard C++ library on Windows does not provide aligned_alloc() even
5+
// though the MinGW compiler and MSVC may advertise C++17 compliance.
6+
// aligned_alloc is only supported from MacOS 10.15.
7+
-#if (__cplusplus >= 201703L) && (!defined(__MINGW32__)) && (!defined(_MSC_VER)) && (__MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15)
8+
+#if (__cplusplus >= 201703L) && (!defined(__MINGW32__)) && (!defined(_MSC_VER)) && (__MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15) && !(defined(__ANDROID__) && __ANDROID_API__ < 26)
9+
inline void *aligned_alloc(size_t align, size_t size)
10+
{
11+
// aligned_alloc() requires that the requested size is a multiple of "align"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--- a/tools/generate_f2pymod.py
2+
+++ b/tools/generate_f2pymod.py
3+
@@ -290,9 +290,9 @@
4+
cwd=os.getcwd())
5+
out, err = p.communicate()
6+
if not (p.returncode == 0):
7+
- raise RuntimeError(f"Writing {args.outfile} with f2py failed!\n"
8+
+ raise RuntimeError(f"Processing {fname_pyf} with f2py failed!\n"
9+
f"{out}\n"
10+
- r"{err}")
11+
+ f"{err}")
12+
13+
14+
if __name__ == "__main__":
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
TUR_LIB_LICENSE_JSON="$TERMUX_PKG_BUILDER_DIR/licenses.json"
45+
46+
source $TERMUX_SCRIPTDIR/common-files/tur_build_wheel.sh
47+
source $TERMUX_SCRIPTDIR/common-files/setup_toolchain_gcc.sh
48+
49+
termux_step_pre_configure() {
50+
if $TERMUX_ON_DEVICE_BUILD; then
51+
termux_error_exit "Package '$TERMUX_PKG_NAME' is not available for on-device builds."
52+
fi
53+
54+
_setup_toolchain_ndk_gcc_11
55+
56+
LDFLAGS+=" -Wl,--no-as-needed,-lpython${TERMUX_PYTHON_VERSION},--as-needed"
57+
58+
# FIXME: Don't know why NDK's libc++ should link against clang's libunwind,
59+
# FIXME: otherwise pybind11's `register_local_exception_translator` won't
60+
# FIXME: work properly, causing crash on `scipy.io._mmio`.
61+
mkdir -p $TERMUX_PKG_TMPDIR/_libunwind_libdir
62+
local _NDK_ARCH=$TERMUX_ARCH
63+
test $_NDK_ARCH == 'i686' && _NDK_ARCH='i386'
64+
cp $NDK/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/*/lib/linux/$_NDK_ARCH/libunwind.a \
65+
$TERMUX_PKG_TMPDIR/_libunwind_libdir/libunwind.a
66+
LDFLAGS="-L$TERMUX_PKG_TMPDIR/_libunwind_libdir -l:libunwind.a ${LDFLAGS}"
67+
}
68+
69+
termux_step_configure() {
70+
termux_setup_meson
71+
72+
cp -f $TERMUX_MESON_CROSSFILE $TERMUX_MESON_WHEEL_CROSSFILE
73+
sed -i 's|^\(\[binaries\]\)$|\1\npython = '\'$(command -v python)\''|g' \
74+
$TERMUX_MESON_WHEEL_CROSSFILE
75+
sed -i 's|^\(\[properties\]\)$|\1\nnumpy-include-dir = '\'$PYTHON_SITE_PKG/numpy/_core/include\''|g' \
76+
$TERMUX_MESON_WHEEL_CROSSFILE
77+
78+
termux_step_configure_meson
79+
}
80+
81+
termux_step_make() {
82+
pushd $TERMUX_PKG_SRCDIR
83+
PYTHONPATH= python -m build -w -n -x --config-setting builddir=$TERMUX_PKG_BUILDDIR .
84+
popd
85+
}
86+
87+
termux_step_make_install() {
88+
local _pyv="${TERMUX_PYTHON_VERSION/./}"
89+
local _whl="scipy-${TERMUX_PKG_VERSION#*:}-cp$_pyv-cp$_pyv-linux_$TERMUX_ARCH.whl"
90+
pip install --no-deps --prefix=$TERMUX_PREFIX $TERMUX_PKG_SRCDIR/dist/$_whl
91+
}
92+
93+
tur_install_wheel_license() {
94+
# Install the license of libopenblas
95+
cp $TERMUX_PREFIX/share/doc/libopenblas/copyright libopenblas-LICENSE
96+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[
2+
{
3+
"name": "openblas",
4+
"libs": [
5+
"libopenblas"
6+
],
7+
"licenses": [
8+
"libopenblas-LICENSE"
9+
]
10+
}
11+
]

0 commit comments

Comments
 (0)