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 >= 1.26.4
- scipy
BLAS Support
This package automatically uses SciPy's BLAS backend for optimal performance. No additional BLAS installation is required - SciPy will provide the necessary BLAS functionality.
Build
Install Dependencies and Build
# 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 automatic BLAS support via SciPy
- 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.
BLAS Configuration
The package automatically uses SciPy's BLAS backend, which provides optimized BLAS operations without requiring separate BLAS installation. The build system is configured to use SciPy's BLAS functions directly.
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 automatic BLAS support via SciPy
- Compile the C++ library with dynamic BLAS symbol lookup (for SciPy 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
Conda Build
This package can also be built and distributed via conda-forge. The conda recipe is located in conda-recipe/ and supports multiple platforms and Python versions.
Building conda packages locally:
# Install conda-build
conda install conda-build
# Build the conda package
cd python
conda build conda-recipe
# Build for specific platforms
conda build conda-recipe --platform linux-64
conda build conda-recipe --platform osx-64
conda build conda-recipe --platform osx-arm64
Supported platforms:
- Linux x86_64
- macOS Intel (x86_64)
- macOS Apple Silicon (ARM64)
Supported Python versions:
- Python 3.11, 3.12, 3.13
Supported NumPy versions:
- NumPy 2.1, 2.2, 2.3
The conda build automatically:
- Uses SciPy's BLAS backend for optimal performance
- Cleans up old shared libraries before building
- Builds platform-specific packages with proper dependencies
Performance Notes
BLAS Support
This package automatically uses SciPy's optimized BLAS backend for improved linear algebra performance:
- Automatic BLAS: Uses SciPy's BLAS functions for optimal performance
- No additional setup: SciPy provides all necessary BLAS functionality
The build system automatically configures BLAS support through SciPy. You can verify BLAS support by checking the build output for messages like:
export SPARSEIR_DEBUG=1
python -c "import pylibsparseir"
This will show:
BLAS support enabled
Registered SciPy BLAS dgemm @ 0x...
Troubleshooting
Build fails with missing source files:
# Make sure to run prepare_build.py first
python3 prepare_build.py
uv build
Clean rebuild:
# Remove all copied files and build artifacts
uv run clean
python3 prepare_build.py
uv build
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.6.0-cp313-cp313-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
712e448657ffa502dc3db6032dbd6ef8fed7db1b00a34c7a489657f9855ce709
|
|
| MD5 |
bedda97949220bc76c733c47f9ab8926
|
|
| BLAKE2b-256 |
c1f9b370fbe640221606d95ebe1f626126bcdf43e42575a502da1e75787693c7
|
File details
Details for the file pylibsparseir-0.6.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
4b929bae823aa5d3b2a415fba75bd9e917c5c73590aacb06a1c84696c8e6ed03
|
|
| MD5 |
14f83ed3bf7908b87858135688e4d9de
|
|
| BLAKE2b-256 |
862b6b8ed63966217b51ac292c35402e74a46b8318f8237154f0f50127ccb8c4
|
File details
Details for the file pylibsparseir-0.6.0-cp313-cp313-macosx_15_0_arm64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
ccca8c249a2ee28eb04891c8563c53e5b71534b1e85985005cfe971c7d8b820c
|
|
| MD5 |
75a231d65546e7c3ab1fc397db831a34
|
|
| BLAKE2b-256 |
17acee191c7238adf1f03af58f23a580f1c7f07742da9c99c4665d5aa2b39cdd
|
File details
Details for the file pylibsparseir-0.6.0-cp313-cp313-macosx_13_0_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
de36264f212c60d3981285f85a376e61e0e222cc783dceea03ab8cedc96677c7
|
|
| MD5 |
fb1b2752453fe427bd563817f73dbb23
|
|
| BLAKE2b-256 |
d62122eac40daeebc1fd594f3d9f93bb45cbc53b1d160b658ef62be5b598e6a1
|
File details
Details for the file pylibsparseir-0.6.0-cp312-cp312-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
df238c054a806325e0c46eb8c7fefb5d7f03a2af9ade8497182183379977043b
|
|
| MD5 |
22eabe5668c7522c8a146771e8cbc225
|
|
| BLAKE2b-256 |
cdcaa56bebb68fce8e024822bb60e29b1abaf0f2a19c85432c920508ed307f0d
|
File details
Details for the file pylibsparseir-0.6.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
225bfabf3c6a14d2abf02953512f49f6366e8eb31fc2cb7a42bd8bc45a1429a9
|
|
| MD5 |
1d1f7f7580415575abfed58018c35233
|
|
| BLAKE2b-256 |
e06825ef4b3cc522d295dae338543bd3a457cc9c6769d90d0a7e7b39268b0605
|
File details
Details for the file pylibsparseir-0.6.0-cp312-cp312-macosx_15_0_arm64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
814967a1e2f3653fe0954bf547c38553cd418b159f65d39ca95f1dcb77391348
|
|
| MD5 |
64bc94334818fad110160af5476152f7
|
|
| BLAKE2b-256 |
feb19927077df3060e4567ca865958fc8bc6997ebe78850a536b19a19caaa355
|
File details
Details for the file pylibsparseir-0.6.0-cp312-cp312-macosx_13_0_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
dcce338d50b223a1f483266be43b55d1dc9af3115d4704249c3c06f832b6c73b
|
|
| MD5 |
b3b5eba53df48e1bfd41ce595d686b18
|
|
| BLAKE2b-256 |
7eb55eacd2455a5af74e1312c0a51f08ebe328949c652f554b255de5ff10d86c
|
File details
Details for the file pylibsparseir-0.6.0-cp311-cp311-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
d3f997a50eafb47f82246867cd999761e277532f983d8e75c21f26076ba1caf1
|
|
| MD5 |
69bead3570e32d23713e4ef091bf26e7
|
|
| BLAKE2b-256 |
a60fa6e94a993e74d935da6b7d98502cbe5206f9819d7fd31fa972accf8b816b
|
File details
Details for the file pylibsparseir-0.6.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
8488fb49be41dce4ee6fc1f854afea41b08fe40e635e82f8714940f541b2ed7b
|
|
| MD5 |
87ba6b2593a6ebb2683ddd5a0bed3830
|
|
| BLAKE2b-256 |
064aae0d75968780c29a7204d38b57c08ee8c087a70d31ed1ad812b537cfe168
|
File details
Details for the file pylibsparseir-0.6.0-cp311-cp311-macosx_15_0_arm64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
e542e41671ee6d255d0a5f0b889c6aa426dbb468c826f7495966b9d2e9c69c9b
|
|
| MD5 |
e985e253fabad5eb3fb3fa8d6c998007
|
|
| BLAKE2b-256 |
dbe00fdda2c4d859eb7bf56def476e78717ccffb9d662d88d284da351cbac301
|
File details
Details for the file pylibsparseir-0.6.0-cp311-cp311-macosx_13_0_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
abc2420039d9974f4da4a6a0b958f950a750ade5dc3b90a619fa956f556b7e36
|
|
| MD5 |
7d0455ec6c4563d39a87f6c0822270a0
|
|
| BLAKE2b-256 |
d851de890ff871e5be43cf6e66412cef120e9f19f6906713cb034d693de198c3
|
File details
Details for the file pylibsparseir-0.6.0-cp310-cp310-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
9cba9399311c457fef06d91b24dd268235fdaab834a33dde65c09b6114775893
|
|
| MD5 |
a568058262b7ddec0efb378e8c30c277
|
|
| BLAKE2b-256 |
e774e0c77024079bd2ce5385d47f3e6f28262352a693ffb8e92a0222d178ab8d
|
File details
Details for the file pylibsparseir-0.6.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
4821a9df1378f22ddba3bbb7e794665fc75092ef1cc7d082cb295f378870116d
|
|
| MD5 |
3204c982bbdc7aa2ef60696e05ed0d44
|
|
| BLAKE2b-256 |
8c072fa64f2391c8c1c67f6d252d4a9ec779268d16239866446209991cb15594
|
File details
Details for the file pylibsparseir-0.6.0-cp310-cp310-macosx_15_0_arm64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
a7c1c410f9a8c29418611adb297a0490da116dc21a890e85c9c0e9f14dc69523
|
|
| MD5 |
431e8c43c28b81e15164c159162fc608
|
|
| BLAKE2b-256 |
21d5d08c53bd303a348a1b43fa383b342ff0a9678933d77ef9b9858ce7658600
|
File details
Details for the file pylibsparseir-0.6.0-cp310-cp310-macosx_13_0_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.6.0-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 |
ef6daca1c4e5981fc7cbb4f000c43a2e67418aa2b53ab8a8d2f3247ba93954be
|
|
| MD5 |
57d6572416678f4b1a242c0be871c2c7
|
|
| BLAKE2b-256 |
c8c86ead8fd38b0a7a87b429e82501f58fb7f4b4042678f62701e829f977e57e
|