Python bindings for the sparse-ir-capi library
Project description
Python bindings for sparse-ir-capi
This is a low-level binding for the sparse-ir-capi Rust library.
Requirements
- Python >= 3.10
- Rust toolchain (for building the Rust library)
- 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
# Build the package (Rust library will be built automatically)
cd python
uv build
This will:
- Automatically build the Rust sparse-ir-capi library using Cargo (via CMake)
- Copy the built library and header files to the Python package
- 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: The Rust library is built automatically during the Python package build. No separate build step is needed:
# In CI/CD scripts
cd python
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 - Compiled libraries:
pylibsparseir/*.so,pylibsparseir/*.dylib,pylibsparseir/*.dll - Cache directories:
pylibsparseir/__pycache__
Build Process Overview
The build process works as follows:
-
CMake Configuration: scikit-build-core invokes CMake, which:
- Finds the Cargo executable
- Sets up build targets for the Rust library
-
Rust Library Build: CMake calls Cargo to build
sparse-ir-capi:- Compiles the Rust library to a shared library (
.so,.dylib, or.dll) - Generates C header file (
sparseir.h) using cbindgen (via build.rs) - Copies the library and header to the
pylibsparseirdirectory
- Compiles the Rust library to a shared library (
-
Python Package Building:
uv buildoruv sync:- Packages everything into distributable wheels and source distributions
-
Installation: The built package includes the compiled shared 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 Cargo:
# Make sure Rust toolchain is installed
# Install from https://rustup.rs/
# Then retry:
cd python
uv build
Clean rebuild:
# Remove all build artifacts
uv run clean
cd ../sparse-ir-capi
cargo clean
cd ../python
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.7.4-cp313-cp313-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.7.4-cp313-cp313-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.13, 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 |
5d0085ba7781fe35bdbc81baee8528b7da2f5266f215aefa4440066d0d77313f
|
|
| MD5 |
6b272b9a7bc25d76f8a129aca5927a9a
|
|
| BLAKE2b-256 |
7e26a783c51e18fb61ede28cccdc4f9cae3880f11361c0c61a787f2a359fabd3
|
File details
Details for the file pylibsparseir-0.7.4-cp313-cp313-macosx_15_0_arm64.whl.
File metadata
- Download URL: pylibsparseir-0.7.4-cp313-cp313-macosx_15_0_arm64.whl
- Upload date:
- Size: 1.1 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 |
6934cf2cb2bff35ed74eb41878d37eefeb5239428ef466b45d5ae0e2af6ccbac
|
|
| MD5 |
315d7fb4e6f3bae1e75df55751061b71
|
|
| BLAKE2b-256 |
d99fe72860c4f3c18924484856c902a4a4b821e7951ce57fa10a585f486b72dc
|
File details
Details for the file pylibsparseir-0.7.4-cp312-cp312-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.7.4-cp312-cp312-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.12, 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 |
881f3c3bdc32d0f1befed95677e629814d316b6d0c0e43eef4daee6111050b99
|
|
| MD5 |
7526d3aee9cec3a2280b8f9701d92df7
|
|
| BLAKE2b-256 |
5ee3818b0f0bad6ca60ffea808b931a8190958d8750f61819e8cedc9ce0fb9e5
|
File details
Details for the file pylibsparseir-0.7.4-cp312-cp312-macosx_15_0_arm64.whl.
File metadata
- Download URL: pylibsparseir-0.7.4-cp312-cp312-macosx_15_0_arm64.whl
- Upload date:
- Size: 1.1 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 |
cf14d2798ef02afead028ae37c426fd80b895186f31c2e0db8fa044750345f6d
|
|
| MD5 |
a298a11bedcef94d0366c78fe843d47c
|
|
| BLAKE2b-256 |
93899030d14c419003a92342877f48f4f01b11f04e7931d426ec5fc3ebb58b6c
|
File details
Details for the file pylibsparseir-0.7.4-cp311-cp311-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.7.4-cp311-cp311-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.11, 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 |
4ca00a9b3a30888dab0ffa05c8c4475608914409bdafe9da3769bd6dcc2616b5
|
|
| MD5 |
ae671f74bce8118246d24773ee5c20e7
|
|
| BLAKE2b-256 |
44ceee9503eb2ca95978d815309fbbe89df8bb58b5deb9621282c6ef305a65c5
|
File details
Details for the file pylibsparseir-0.7.4-cp311-cp311-macosx_15_0_arm64.whl.
File metadata
- Download URL: pylibsparseir-0.7.4-cp311-cp311-macosx_15_0_arm64.whl
- Upload date:
- Size: 1.1 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 |
709ea22e92e67b6ebb16e178f21f92c48cbdfdce45209f534a19a6356db8324b
|
|
| MD5 |
8c4bc1afe1126ddca649b083f6a2e05c
|
|
| BLAKE2b-256 |
3fe4e5f7886fb4292a5677d01de017c1db231b92843e5c746880882f7644420f
|
File details
Details for the file pylibsparseir-0.7.4-cp310-cp310-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pylibsparseir-0.7.4-cp310-cp310-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.10, 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 |
d988284742b63e7b858a80597c746cbdeda99c4d28245317944d948f8c93c5e2
|
|
| MD5 |
b2aa43bbed697190c0348a181ea57fe7
|
|
| BLAKE2b-256 |
a249f265dc30146e0a32480743d936fe3aae9d4850fa6f38e34b1b5c1fe485d4
|
File details
Details for the file pylibsparseir-0.7.4-cp310-cp310-macosx_15_0_arm64.whl.
File metadata
- Download URL: pylibsparseir-0.7.4-cp310-cp310-macosx_15_0_arm64.whl
- Upload date:
- Size: 1.1 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 |
005d296f7f87d1112edd1ce49164bdf543a13284887092b44d0a2ef81f898abd
|
|
| MD5 |
8c078ea0ad1843921408b046dad448a2
|
|
| BLAKE2b-256 |
cc4309a4c6892c9a9b46dcfc86fd8963bd14728b48e8c4f9894b2d2240ba0461
|