summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 1f190619eb9dee99432fed18867e6d3bb98578a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Maintainer: Claudia Pellegrino <aur ät cpellegrino.de>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>
# Contributor: Douglas Soares de Andrade <dsa@aur.archlinux.org>
# Contributor: Angel 'angvp' Velasquez <angvp[at]archlinux.com.ve>

pkgname=python-numpy1
pkgver=1.26.4
pkgrel=6
pkgdesc="Scientific tools for Python"
arch=('x86_64')
license=('LicenseRef-custom')
url="https://www.numpy.org/"
depends=('cblas' 'lapack' 'python')
optdepends=('blas-openblas: faster linear algebra')
makedepends=(
  'python-build'
  'python-installer'
  'python-pyproject-patcher'
  'meson-python'
  'cmake'
  'gcc-fortran'
  'cython'
)
checkdepends=('python-pytest' 'python-hypothesis' 'python-setuptools')
provides=("python-numpy=$pkgver")
conflicts=('python-numpy')
source=("https://github.com/numpy/numpy/releases/download/v$pkgver/numpy-$pkgver.tar.gz"
        'github-pr-26364.patch'
        'python-3.14.patch'
        'tests-skipif-python-3.13.patch')
sha512sums=('f7121ab4099fa0686f9c095d456baa4a5869d651d7b7a06385f885f329cf08f11024b5df5e7b4ee705970062a8102ec4f709512eabbfd5c9fccce4ef83b9c208'
            'ee5b380c3530b7a466433c899bff084ff27c8eb5c18aee6638a069867ffc8d8fe4b4c3ccb98800284867f975edb9755c2fd4b21ffe723956fc0117957d52ef7b'
            '2f6067a7aafd6a8e45fdf0ffc5f96c8b65998ace2cafa776a327242a17efbc3f837a4c465b22acd2ce7b097cc23a7ef4a6a11e84e9eb2f73c4af9de4c2775d6f'
            'a5d850792fc26540735a44df6defffa814b2163a59420a72746e3ca6e9588cdd837bf4f7e4a37cbd13eb3d502808e16f5e61956066051ce0175dad1948ee2999')

prepare() {
  cd numpy-$pkgver

  # Unpin the build system requirement to meson-python, so this package
  # can be compatible to extra/meson-python, which is already on 0.18.0.
  # The pin was never relevant for Linux anyway, as the reason upstream
  # originally added the pin was to shotgun-debug a macOS build issue [1].
  #
  # Also unpin the Cython build system requirement, whose upper bound
  # was silently removed upstream [2].
  #
  # [1]: https://github.com/numpy/numpy/pull/26365/files#r1586347845
  # [2]: https://github.com/numpy/numpy/pull/23838
  #
  python << 'EOF'
from pyproject_patcher import patch_in_place
with patch_in_place('pyproject.toml') as toml:
    toml.build_system_requires.strip_constraint('Cython')
    toml.build_system_requires.strip_constraint('meson-python')
EOF

  # https://github.com/numpy/numpy/pull/26364
  echo >&2 'Applying patch to backport Python 3.13 compatibility'
  patch -p1 < ../github-pr-26364.patch

  # https://github.com/python/cpython/issues/81283
  echo >&2 'Patching out tests failing on Python 3.13 due to gh-81283'
  patch -p1 < ../tests-skipif-python-3.13.patch

  # https://github.com/numpy/numpy/commit/8df09df7365539a092c9f4534ef8b8295b679de6
  echo >&2 'Applying patch to backport Python 3.14 compatibility'
  patch -p1 < ../python-3.14.patch
}

build() {
  cd numpy-$pkgver
  CFLAGS+=" -ffat-lto-objects" \
  CXXFLAGS+=" -ffat-lto-objects" \
  python -m build --wheel --no-isolation \
    -Csetup-args="-Dblas=cblas" \
    -Csetup-args="-Dlapack=lapack"
}

check() {
  local site_packages
  site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd numpy-$pkgver
  python -m installer --destdir="$PWD/tmp_install" dist/*.whl
  cd "$PWD/tmp_install"
  PATH="$PWD/usr/bin:$PATH" PYTHONPATH="$PWD/$site_packages:$PYTHONPATH" \
    python -c 'import sys; import numpy; sys.exit(not numpy.test())'
}

package() {
  cd numpy-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  install -D -m644 LICENSE.txt -t "$pkgdir"/usr/share/licenses/python-numpy1/
}