Installation
APbase is distributed with compiled numerical extensions. Install the package for your language.
Requirements
- CPython 3.12, 3.13, or 3.14
numpy(2.0+),pyproj,shapely(installed automatically as dependencies)- Prebuilt wheels for Linux on
x86_64(glibc 2.28+), macOS onarm64(14+) andx86_64(15+), and Windows onx86_64. No source distribution is published, so other platforms and Python versions cannot install the package.
- Rust 1.85+ (edition 2024)
- Linux on
x86_64(x86_64-unknown-linux-gnu), macOS on Apple Silicon (aarch64-apple-darwin) and Intel (x86_64-apple-darwin), or Windows onx86_64with the GNU toolchain (x86_64-pc-windows-gnu); the MSVC toolchain is not supported yet - GEOS 3.12 or newer and PROJ 9.6.2 or newer (see the note below for an older PROJ), plus the Fortran, OpenMP, and BLAS runtime used by the native kernels
Install
pip install apbase
To install the development version from the repository instead:
pip install git+https://github.com/ap-base/apbase-python.git
Install the system libraries, then add the crate. On Linux (Ubuntu/Debian):
sudo apt install gfortran libopenblas-dev libgeos-dev libproj-dev pkg-config
cargo add apbase
On macOS, with Homebrew:
brew install gcc openblas geos proj pkgconf
cargo add apbase
On Windows, install MSYS2 and, in its MINGW64 shell:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-openblas \
mingw-w64-x86_64-geos mingw-w64-x86_64-proj mingw-w64-x86_64-pkgconf
Then build with the GNU Rust toolchain, with C:\msys64\mingw64\bin first on
PATH:
rustup toolchain install stable-x86_64-pc-windows-gnu
rustup default stable-x86_64-pc-windows-gnu
$env:PKG_CONFIG = "pkgconf"
cargo add apbase
Built programs need the DLLs from mingw64\bin (libgfortran, libgomp,
OpenBLAS, GEOS, PROJ) on PATH or next to the executable.
Instead of cargo add, you can declare it in Cargo.toml:
[dependencies]
apbase = "0.2.0"
The Fortran kernels ship inside the crate as a static library, so no Fortran compiler runs during the build. The Fortran and OpenBLAS packages above are needed only for the link step, which looks for libgfortran, libgomp, and OpenBLAS.
Note
If the system PROJ is older than 9.6.2, the proj-sys dependency builds PROJ
from source, which also needs cmake, sqlite3, libsqlite3-dev, and
libtiff-dev. Each GitHub
release of apbase-rust
also carries the packaged apbase-<version>.crate.
Three build-time environment variables change what is linked:
APBASE_BLAS_LIBS takes space-separated BLAS/LAPACK libraries to link instead
of OpenBLAS (-L<dir> entries add a search directory),
APBASE_FORTRAN_LIB_DIR points to the directory with libgfortran and libgomp
when the linker does not find them, and APBASE_NATIVE_LIB_DIR points to a
directory with your own libapbase_native.a for development builds.
Optional extras
The targets argument of IDW, Kriging, and CoKriging also accepts a
GeoDataFrame or GeoSeries of points when geopandas is installed. You can
skip this extra when passing plain NumPy arrays:
pip install geopandas
The Rust crate has no optional extras. Boundaries are passed as WKT, WKB, or a
geos::Geometry, and targets as ndarray arrays, slices of [x, y] pairs,
point geos::Geometry values, or a fitted Grid.
Verify the install
Build a tiny map to confirm the native kernels load and run:
import numpy as np
import apbase
rng = np.random.default_rng(0)
x, y = rng.uniform(0, 100, 50), rng.uniform(0, 100, 50)
result = apbase.create_map(x, y, x + y, resolution=10.0)
print(result.method, result.z.size)
fn main() -> Result<(), Box<dyn std::error::Error>> {
let x: Vec<f64> = (0..50).map(|i| (i * 37 % 100) as f64).collect();
let y: Vec<f64> = (0..50).map(|i| (i * 61 % 100) as f64).collect();
let z: Vec<f64> = x.iter().zip(&y).map(|(a, b)| a + b).collect();
let result = apbase::create_map(&x, &y, &z, apbase::MapOptions::new(10.0))?;
println!("{} {}", result.method, result.z.len());
Ok(())
}
cargo run --release
Using it in production
See Production and cloud deployment for thread configuration and worker sizing.
A Rust service built with cargo build --release links the native kernels
statically, but the runtime image still needs the shared libraries they depend
on: the Fortran, OpenMP, and BLAS runtime (libgfortran5, libgomp1, and
libopenblas0 on Debian/Ubuntu), the GEOS C library (libgeos-c1t64 on
Ubuntu 24.04), and PROJ when it was linked from the system. A PROJ built from
source is linked statically and needs only libsqlite3-0 at run time.