Python bindings for the libsparseir library
Project description
Python bindings for libsparseir
This is a low-level binding for the libsparseir library.
Requirements
- Python >= 3.10
- CMake (for building the C++ library)
- C++11 compatible compiler
- numpy
Optional Dependencies
- OpenBLAS (recommended for better performance)
- macOS:
brew install openblas - Ubuntu/Debian:
sudo apt install libopenblas-dev - CentOS/RHEL:
sudo yum install openblas-devel
- macOS:
Build
Install Dependencies and Build
Option 1: Automatic build (recommended)
# Build will automatically run prepare_build.py if needed
uv build
Option 2: Manual preparation
# First, prepare the build by copying necessary files from parent directory
python3 prepare_build.py
# Then build the package
uv build
This will:
- Copy source files (
src/,include/,cmake/) from the parent libsparseir directory - Build the C++ libsparseir library using CMake with BLAS support
- Create both source distribution (sdist) and wheel packages
Development Build
For development:
# Install in development mode (will auto-prepare if needed)
uv sync
Note for CI/CD: In CI environments, you must run prepare_build.py before building:
# In CI/CD scripts
cd python
python3 prepare_build.py
uv build
See .github-workflows-example.yml for a complete GitHub Actions example.
Build with OpenBLAS Support
OpenBLAS support is enabled by default in the build configuration. The build system will automatically detect OpenBLAS if it's installed in standard locations.
If OpenBLAS is installed in a custom location, you may need to set additional environment variables:
export CMAKE_PREFIX_PATH="/path/to/openblas"
python3 prepare_build.py
uv build
Clean Build Artifacts
To remove build artifacts and files copied from the parent directory:
uv run clean
This will remove:
- Build directories:
build/,dist/,*.egg-info - Copied source files:
include/,src/,cmake/(copied byprepare_build.py) - Compiled libraries:
pylibsparseir/*.so,pylibsparseir/*.dylib,pylibsparseir/*.dll - Cache directories:
pylibsparseir/__pycache__
Build Process Overview
The build process works as follows:
-
File Preparation:
prepare_build.pycopies necessary files from the parent libsparseir directory:- Source files (
../src/→src/) - Header files (
../include/→include/) - CMake configuration (
../cmake/→cmake/)
- Source files (
-
Package Building:
uv buildoruv syncuses scikit-build-core to:- Configure CMake with BLAS support enabled
- Compile the C++ library with dynamic BLAS symbol lookup (for NumPy compatibility)
- Package everything into distributable wheels and source distributions
-
Installation: The built package includes the compiled shared library and Python bindings
Why File Copying?: The prepare_build.py script copies files from the parent directory instead of using symbolic links to ensure:
- Cross-platform compatibility (Windows doesn't handle symlinks well)
- Proper inclusion in source distributions (sdist)
- Clean separation between the main C++ library and Python bindings
Performance Notes
BLAS Support
This package supports BLAS libraries for improved linear algebra performance:
- With OpenBLAS: Significant performance improvements for matrix operations
- Without BLAS: Uses Eigen's built-in implementations (still efficient, but slower for large matrices)
The build system will automatically detect and use OpenBLAS if available. You can verify BLAS support by checking the build output for messages like:
BLAS support enabled
Found OpenBLAS at: /opt/homebrew/opt/openblas
Troubleshooting
Build fails with missing source files:
# Make sure to run prepare_build.py first
python3 prepare_build.py
uv build
Build fails with "Could NOT find BLAS":
# Install OpenBLAS first
brew install openblas # macOS
sudo apt install libopenblas-dev # Ubuntu
# Then build with proper CMake path
export CMAKE_PREFIX_PATH="/path/to/openblas"
python3 prepare_build.py
uv build
OpenBLAS not detected automatically:
# Set CMake prefix path manually
export CMAKE_PREFIX_PATH="/usr/local/opt/openblas" # or your OpenBLAS path
python3 prepare_build.py
uv build
Clean rebuild:
# Remove all copied files and build artifacts
uv run clean
python3 prepare_build.py
uv build
Verify BLAS support in built package:
import pylibsparseir
# Check build logs for "BLAS support enabled" message
# BLAS symbols are resolved dynamically through NumPy at runtime
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pylibsparseir-0.5.2-cp313-cp313-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp313-cp313-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.13, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac3d455fb5336435e259e4a67268909d7646bdc74b9dde723c2977edff6e4941
|
|
| MD5 |
7b25f2905b16ef866366e2eb0381d1a0
|
|
| BLAKE2b-256 |
8a81a0396992d579f6736c862f74dbd3e6d8f3bde02f00195c521a556cfcf47b
|
File details
Details for the file pylibsparseir-0.5.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cddbf31f6d49f219fd9f8f5786a93de04b7e89484352d1429aac8e12d1359e6
|
|
| MD5 |
762ad0bc0b2e71287d64879de701b5f1
|
|
| BLAKE2b-256 |
203ae98a2de42225b11f9971015cd80d137e07d2aedc532934d78208378024ac
|
File details
Details for the file pylibsparseir-0.5.2-cp313-cp313-macosx_15_0_arm64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp313-cp313-macosx_15_0_arm64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.13, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35d154808fdab819a4b62852009ddf24f8e03e763eda798c3a6ac78498b4a9cc
|
|
| MD5 |
18b80dc22c4a52651e5b8571a5a42c22
|
|
| BLAKE2b-256 |
02df61f43113569cfbd3a71a9c34da9f79b5a8823f61f4c40c0195e0439a680d
|
File details
Details for the file pylibsparseir-0.5.2-cp313-cp313-macosx_13_0_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp313-cp313-macosx_13_0_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.13, macOS 13.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4b658b55c05505581a193a0af47cc3fbd3f663f05961ddad2af31ea4bdf68aa
|
|
| MD5 |
f933cb2eb54051d6dbbb32c86603d4cf
|
|
| BLAKE2b-256 |
805895293eef9f5769e92c4367c4a5a86d2d9e8212d1485b4932b0c60b617b13
|
File details
Details for the file pylibsparseir-0.5.2-cp312-cp312-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp312-cp312-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.12, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb5a7398012338049f62dd2194b56beca08efdd1d94ef76f30bb3336849abc1c
|
|
| MD5 |
c5edb54d86e9fb394c8d261affc58585
|
|
| BLAKE2b-256 |
43c787918dcd8be46cc3f6134466deada6f6ead985362f0a7ba88e9b85e3f48b
|
File details
Details for the file pylibsparseir-0.5.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a046ec3a4c52e7ba93533561519011cd41e25496938d435726b81a237540055e
|
|
| MD5 |
b35c5995852fb0cbf2ec37e1339e295e
|
|
| BLAKE2b-256 |
2dade9fbacfbdf8a2daf7fb3d41e728da48f0181f4534a01a85cb831fd6f01a1
|
File details
Details for the file pylibsparseir-0.5.2-cp312-cp312-macosx_15_0_arm64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp312-cp312-macosx_15_0_arm64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.12, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c02a3d037274e4d34dce0494c5caecdd313bbb6955c326b64858d033c3210c9
|
|
| MD5 |
73a421e914d4128a6d64441f36c6620b
|
|
| BLAKE2b-256 |
d2695badb4dfbee3bcd2e49fe4dd7ef3d92ed47daecc2475e45b3e2aa86c5c8d
|
File details
Details for the file pylibsparseir-0.5.2-cp312-cp312-macosx_13_0_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp312-cp312-macosx_13_0_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.12, macOS 13.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
241e219d9c5d688b6e51ed6379dd393c414565acc2d32bdbd937c6a64c1c1a86
|
|
| MD5 |
27c73fb8a1cf7298753645a54c9fce9f
|
|
| BLAKE2b-256 |
d4364259ac8c61857036b67bd93b4fd9360cfb09f21b71518dafff8bc05fb874
|
File details
Details for the file pylibsparseir-0.5.2-cp311-cp311-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp311-cp311-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.11, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e5cfb15c154227adce9186450571313e7754902f99f20f68c0c92b84f78b613
|
|
| MD5 |
2a88782343e496d153b9eb1ae0868818
|
|
| BLAKE2b-256 |
753cb23616da946704a5bb2afa3616c98b98cee9517853b19d4a45e2a0c41033
|
File details
Details for the file pylibsparseir-0.5.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb8aac7e8c3dc8aee374e36db235627151e4210d17d6b63c0ea67e0b0a3bc9ee
|
|
| MD5 |
8dff39b7b5ecd1806a32d9994b67242c
|
|
| BLAKE2b-256 |
2dc2550d0a84a3d75f7cd2d2bfadf94e0eb7ca1ae9749a07023b3b2061950ece
|
File details
Details for the file pylibsparseir-0.5.2-cp311-cp311-macosx_15_0_arm64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp311-cp311-macosx_15_0_arm64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.11, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
783784d68c2ea850f8f24809d3ad0c39c666cc05b7e39004b50d47c5ced65c2b
|
|
| MD5 |
a77f4674e9d43e0372401d2c6c014fd6
|
|
| BLAKE2b-256 |
d03f1e18c9464c383d8e156cbc97e4e37bdb623894bf0acd504369f2c4e0d484
|
File details
Details for the file pylibsparseir-0.5.2-cp311-cp311-macosx_13_0_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp311-cp311-macosx_13_0_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.11, macOS 13.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
784fccfc516dc3c1610c0f0331efcb188cbc85719e951fc94ccf080845937a0d
|
|
| MD5 |
b1a31cc3fa0d41da34fd9e209f814aac
|
|
| BLAKE2b-256 |
61c8be72e20bb48a1531a7cb5ad746c741306f9bb2b8b314fca47163792a8d23
|
File details
Details for the file pylibsparseir-0.5.2-cp310-cp310-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp310-cp310-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.10, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5afb3b2b2ecde5e98e93be1403bb8a87619ffaba2fefe9e9c75f9f64ee7d520b
|
|
| MD5 |
d82ffff172ad64372a12e479a03706ba
|
|
| BLAKE2b-256 |
f5a7b6d1e0519eeef3c0d14b031b8c20e80cdc5a3e6bbde7bd13d59b47fae20a
|
File details
Details for the file pylibsparseir-0.5.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b95963ff52d2032dd15fdc1d8e6aa11c0d71a22ccfe3005874cdd6117810aa3e
|
|
| MD5 |
6cc28e73f54ac79f8e0739a8bd0cdcf0
|
|
| BLAKE2b-256 |
6dba029ac6b2188c5c2091029dec11096f86533fcc8febaee0a5235131703924
|
File details
Details for the file pylibsparseir-0.5.2-cp310-cp310-macosx_15_0_arm64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp310-cp310-macosx_15_0_arm64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.10, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b595ef0da4e06a3e78fb22f071c64ee5aaf6358d147fa4ed17f9fa54c14a3daa
|
|
| MD5 |
2f7410ec1451b385a50276a9acad82af
|
|
| BLAKE2b-256 |
3464f6920806b58b34911f0410bd557c2ef89b56af343ba936a1a2f06151b5a0
|
File details
Details for the file pylibsparseir-0.5.2-cp310-cp310-macosx_13_0_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.5.2-cp310-cp310-macosx_13_0_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.10, macOS 13.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5166b1bac9c9d1115d8dbc2b530e33d42271a9c1a7071c279b076232d4c3522
|
|
| MD5 |
8a9eebcf37c09252197d4dc1f17c0a1d
|
|
| BLAKE2b-256 |
c5d22f41a2dabebdd4c1253628000d67b710ceb37d169443424e07f11217fda2
|