Skip to main content

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)
  • uv (for building and managing Python dependencies)
  • 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 --locked

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:

  1. CMake Configuration: scikit-build-core invokes CMake, which:

    • Finds the Cargo executable
    • Sets up build targets for the Rust library
  2. 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 pylibsparseir directory
  3. Python Package Building: uv build or uv sync --locked:

    • Packages everything into distributable wheels and source distributions
  4. 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, 3.14

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

Release files for pylibsparseir 0.9.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pylibsparseir 0.9.1
File
pylibsparseir-0.9.1-cp314-cp314-manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64 Details
pylibsparseir-0.9.1-cp314-cp314-macosx_15_0_arm64.whl CPython 3.14 CPython 3.14 macOS 15.0+ ARM64 Details
pylibsparseir-0.9.1-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details
pylibsparseir-0.9.1-cp313-cp313-macosx_15_0_arm64.whl CPython 3.13 CPython 3.13 macOS 15.0+ ARM64 Details
pylibsparseir-0.9.1-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details
pylibsparseir-0.9.1-cp312-cp312-macosx_15_0_arm64.whl CPython 3.12 CPython 3.12 macOS 15.0+ ARM64 Details
pylibsparseir-0.9.1-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details
pylibsparseir-0.9.1-cp311-cp311-macosx_15_0_arm64.whl CPython 3.11 CPython 3.11 macOS 15.0+ ARM64 Details
pylibsparseir-0.9.1-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details
pylibsparseir-0.9.1-cp310-cp310-macosx_15_0_arm64.whl CPython 3.10 CPython 3.10 macOS 15.0+ ARM64 Details

Total release size: 13.3 MB

Release files / pylibsparseir-0.9.1-cp314-cp314-manylinux_2_28_x86_64.whl

Download URL pylibsparseir-0.9.1-cp314-cp314-manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.14 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
aaaca14e51ea966143288189d71e21a1501ac4ad3b20b2f7890904869dd78988
BLAKE2b-256 checksum
How to use checksums
6b36de287c274963a0b88020f4d6829e01b7b1326f2ade48c81ed0619edf0487
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pylibsparseir-0.9.1-cp314-cp314-macosx_15_0_arm64.whl

Download URL pylibsparseir-0.9.1-cp314-cp314-macosx_15_0_arm64.whl
Size 992.3 kB
Tags CPython 3.14 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
357377187221293f79bbb0bcf598994947a1e9440e60735ad87d25de7e151772
BLAKE2b-256 checksum
How to use checksums
a22395f6e6f00d70a86e2aa7a7485639c56b29318b8d9e5310f2fd9cb69fc74e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pylibsparseir-0.9.1-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL pylibsparseir-0.9.1-cp313-cp313-manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
d76bf65a148588d6efe0c79d6c3a01808f9b4ac0de24cd528f1a15ce7836cd6a
BLAKE2b-256 checksum
How to use checksums
3609d3f121ca769ebc3b86748b777e29fb078199e04f9f8c069d87ba3068dd45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pylibsparseir-0.9.1-cp313-cp313-macosx_15_0_arm64.whl

Download URL pylibsparseir-0.9.1-cp313-cp313-macosx_15_0_arm64.whl
Size 992.3 kB
Tags CPython 3.13 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
f1e7160b29fc5c4fa1ddc0c13ecd129d2285dffd5eade6e14ee1214de95a40d3
BLAKE2b-256 checksum
How to use checksums
44c57b4d1d0a06d7a9aa564bde0d349c86e9773d75fe50d029ead37fb31c2142
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pylibsparseir-0.9.1-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL pylibsparseir-0.9.1-cp312-cp312-manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f84dda04c45224104c678c3f77f3628e3806d542265e20b5b8f745523c8755b2
BLAKE2b-256 checksum
How to use checksums
3877bbf538839af52c82d5713d1975e5ef45ee22060a1089c81edbfc77db3957
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pylibsparseir-0.9.1-cp312-cp312-macosx_15_0_arm64.whl

Download URL pylibsparseir-0.9.1-cp312-cp312-macosx_15_0_arm64.whl
Size 992.3 kB
Tags CPython 3.12 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
3ebb4905bf38be61efce94810fb51a3737a65e523f35645885d468f77782e060
BLAKE2b-256 checksum
How to use checksums
ef11b862663daee098530e61a2ac6ebe49435effcb37f142386e62c0e8be1d11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pylibsparseir-0.9.1-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL pylibsparseir-0.9.1-cp311-cp311-manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e67dad8a0059c5820e1b7fe4e53e53b15e6083cbc81c426870c1933edd8b1755
BLAKE2b-256 checksum
How to use checksums
bcc66655d62c0266e61a0166b180df920f901ffb1e8aaff2d6fd07ea8f3773d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pylibsparseir-0.9.1-cp311-cp311-macosx_15_0_arm64.whl

Download URL pylibsparseir-0.9.1-cp311-cp311-macosx_15_0_arm64.whl
Size 992.3 kB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
dde959bd4e216dfde979b1c29561671270d03fa615c7dc80b3f3c1df0b09165b
BLAKE2b-256 checksum
How to use checksums
e73c7d951645322a447475669696ecbaf76b0287b3f4f8070417a5f9f79c3fa8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pylibsparseir-0.9.1-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL pylibsparseir-0.9.1-cp310-cp310-manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9681cd1d1fdfaac9709c9c7f75393db677653329c29bae41caef7bb99623d108
BLAKE2b-256 checksum
How to use checksums
4aa42959d39b653243f3755c9cd38c3f894addb9fe76a2328b80e7da7047bd0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pylibsparseir-0.9.1-cp310-cp310-macosx_15_0_arm64.whl

Download URL pylibsparseir-0.9.1-cp310-cp310-macosx_15_0_arm64.whl
Size 992.3 kB
Tags CPython 3.10 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
2d91176d6337c1aa95688ed3bc06de9a4a8ac72609218bfabd0ad907ca56c721
BLAKE2b-256 checksum
How to use checksums
a0cabf2b96fab0da8a661268bb8aad1d7027129a986a3ab744dbd854ac001b36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.9.1 This release

10 release files

0.9.0

10 release files

0.8.4

8 release files

0.8.3

8 release files

0.8.2

8 release files

0.8.0

8 release files

0.7.5

8 release files

0.7.4

8 release files

0.7.3

8 release files

0.6.0

16 release files

0.5.2

16 release files

0.1.0

16 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page