156.2. numpy-2.5.3
N-dimensional array library for Python
| Version | 2.5.3, release 1 |
| Shelf | sci-libs — Numerical and scientific-data libraries, and the unprefixed core Python science stack |
| Phase | 41_system (System), 55 of 1047 in build order |
| Licence | BSD-3-Clause AND 0BSD AND MIT AND Zlib AND CC0-1.0 |
| Homepage | https://pypi.org/project/numpy/ |
| Build time | 3.8 SBU |
| Installed size | 25.3 MiB in 608 files |
| Recipe | ports/core/sci-libs/numpy/kpkgbuild |
About
NumPy is Python’s N-dimensional array type and the numerical routines built on it. It is the base of the scientific Python stack in KDOS: scipy, matplotlib, pandas and astropy import it, and so do the Python parts of gnuradio, opencv, gdal and blender. It is built from source with meson through pip, and its linear algebra goes to openblas.
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/sci-libs.txt:
The array type, and what makes the shipped python a calculator. No wheels exist for musl+3.14, so this is a from-source meson build; openblas is what the linear algebra lands on rather than numpy's bundled reference kernels.
Sources
numpy-2.5.3.tar.gz(19.8 MiB)
sha256df2d5874ff183595a4ba404edd04f6bd9b5505c1d7708573f6a6c17489a67563
upstream: https://files.pythonhosted.org/packages/source/n/numpy/numpy-2.5.3.tar.gz
archive copy: sources-4/sci-libs--numpy-2.5.3.tar.gz
Dependencies
Depends on: python3, python3-setuptools, python3-pip, python3-meson-python, python3-cython, meson, ninja, openblas.
Required by (40): astropy, bcnc, blender, boost, coolprop, cura, freecad, gdal, gnuradio, gr-funcube, gr-iqbal, ifcopenshell, inkscape, linuxcnc, matplotlib, netgen, onnxruntime, opencv, openimageio, pandas, piper, python3-contourpy, python3-h5py, python3-iminuit, python3-jplephem, python3-pyerfa, python3-pyqtgraph, python3-pyside6, python3-sgp4, python3-shapely, python3-wxpython, qgis, scipy, selenium-webdriver-at-spi, sideband, skyfield, uhd, uranium, urh, veusz.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install numpy'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/sci-libs/numpy.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/sci-libs/numpy
echo 'df2d5874ff183595a4ba404edd04f6bd9b5505c1d7708573f6a6c17489a67563 numpy-2.5.3.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/numpy
SRC=$SRC_ROOT/numpy-2.5.3
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf numpy-2.5.3.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
export CFLAGS="${CFLAGS/-O2/-O3}" CXXFLAGS="${CXXFLAGS/-O2/-O3}"
pip3 install --ignore-installed --no-deps --no-index --no-build-isolation --root=$PKG --prefix=/usr \
-Csetup-args=-Dcpu-baseline=none \
-Csetup-args=-Dblas=openblas \
-Csetup-args=-Dlapack=openblas \
-Csetup-args=-Dallow-noblas=false \
.
find "$PKG"/usr/lib/python3*/site-packages/numpy -type d -name tests -prune -exec rm -rf {} +
The switches, and why each is set:
export CFLAGS="${CFLAGS/-O2/-O3}" CXXFLAGS="${CXXFLAGS/-O2/-O3}"— Compile at-O3. meson’s release optimisation is-O3, but meson puts the exportedCFLAGSafter its own, so the tree’s-O2would win; this is the form Every port gives for a hot port.--no-build-isolation— Build with the meson-python, Cython and setuptools already in the build root rather than ones pip would fetch into a temporary environment; the build has no network.-Csetup-args=-Dcpu-baseline=none— Assume no processor feature beyond what the compiler targets. NumPy’s default,min, is x86-64 v2 on x86_64, which would make the package refuse to import on an older processor. The faster code paths are not lost:cpu-dispatchstays at its defaultmax, so NumPy still compiles its SIMD kernels for every newer level and picks among them at run time. This is the rule in Every port.-Csetup-args=-Dblas=openblas,-Csetup-args=-Dlapack=openblas— Link openblas for BLAS and LAPACK by name, instead of taking whichever library NumPy’s search order finds first.-Csetup-args=-Dallow-noblas=false— Fail the build when no BLAS is found. Upstream’s default is to build with its own slow fallback routines instead, which would ship a NumPy whose matrix products run without OpenBLAS and say nothing.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/numpy, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf numpy-2.5.3-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/numpy, and runs the triggers its paths call for.
Contents
Installed programs: f2py, numpy-config.
Installed directories: /usr/lib/python3.14/site-packages/numpy, /usr/lib/python3.14/site-packages/numpy-2.5.3.dist-info, /usr/share/licenses/numpy.
Short descriptions
numpy.pc |
NumPy is the fundamental package for scientific computing with Python. |
Notes
The meson that configures NumPy is not the meson port. pyproject.toml names vendored-meson/meson/meson.py, a copy NumPy carries with its own changes for its CPU feature handling, and meson-python runs that one.
Upstream installs its test suites into the package (--tags=…,tests,… in pyproject.toml). The find … -name tests -prune -exec rm -rf after the install removes every tests directory under numpy/ from the package.