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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pylibsparseir-0.9.0-cp314-cp314-manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

pylibsparseir-0.9.0-cp314-cp314-macosx_15_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

pylibsparseir-0.9.0-cp313-cp313-manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

pylibsparseir-0.9.0-cp313-cp313-macosx_15_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

pylibsparseir-0.9.0-cp312-cp312-manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

pylibsparseir-0.9.0-cp312-cp312-macosx_15_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

pylibsparseir-0.9.0-cp311-cp311-manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

pylibsparseir-0.9.0-cp311-cp311-macosx_15_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

pylibsparseir-0.9.0-cp310-cp310-manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

pylibsparseir-0.9.0-cp310-cp310-macosx_15_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

Details for the file pylibsparseir-0.9.0-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylibsparseir-0.9.0-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 79c02de1cc188f067ff342048f365cd8c221a193fe7bdc368e7b98c62ce646d3
MD5 701252a49ca9cc5cc648ee0f692c106b
BLAKE2b-256 ab04ce3432b11e886099884a1c54a06feceb9d5fa3758f872146e3634e669639

See more details on using hashes here.

File details

Details for the file pylibsparseir-0.9.0-cp314-cp314-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pylibsparseir-0.9.0-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 37e48b07732ef822feb42e46fc9e3abef4ac099fe155b45cecbdc582c6971984
MD5 67f77f6815ec7422a9402d11fc4c500f
BLAKE2b-256 5bd0f26a479bef46c232ff9e5059f20f14dcfa3565cb76f1d374c0a683bc8f0c

See more details on using hashes here.

File details

Details for the file pylibsparseir-0.9.0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylibsparseir-0.9.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5bff0356bdb0a284bd57440cb0f359e2b09ff0695e64d30c90825568b50a4331
MD5 ea6fcf0d6ccb8f44852682c7df90e630
BLAKE2b-256 76427c68ad12de7c623063d9f0965e1e07c1837d697d954cd2299f83ec8fe37d

See more details on using hashes here.

File details

Details for the file pylibsparseir-0.9.0-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pylibsparseir-0.9.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 6496106ed1c0514f29682cdea327c944ac2bdf734d9ff0bbef652c32ea363838
MD5 801caf5a3f0a5f96adae357ef29c79aa
BLAKE2b-256 82e55139bcae940ad663ec7d1315e3394fb11ae65dc0e8391e98faf81a31246c

See more details on using hashes here.

File details

Details for the file pylibsparseir-0.9.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylibsparseir-0.9.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4ff70ddab683f6c063873b3827992bd40b6e5ee11d0f57f060f2f4439afa59d4
MD5 d5e2fbdee64419e2b3c3227a78c3e7ed
BLAKE2b-256 2e2d190f9760612ee3491d79553ec99b28deb13cadba89dc96f10d42c6aa266c

See more details on using hashes here.

File details

Details for the file pylibsparseir-0.9.0-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pylibsparseir-0.9.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 26135b9e161da41efe7c087cf8dec422bc3640a82c65896af1388bdef37ef17c
MD5 f3463f5d9aee13ed2437c39ef5e7ca79
BLAKE2b-256 dfff75caa995bd55fa45dfe21ac6d20e98a6728164cfbb7553eebe411a2adc50

See more details on using hashes here.

File details

Details for the file pylibsparseir-0.9.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylibsparseir-0.9.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 740df5e53d1b4804fac917292be3395d3a4618518a9f7bcf6f8efd3bfbd10559
MD5 ee259203f6a3d8e78f43bfcf6844c047
BLAKE2b-256 11d217cd572580aba98c4b5b419259511d9025668c508f9ba64a0e05d1a18d92

See more details on using hashes here.

File details

Details for the file pylibsparseir-0.9.0-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pylibsparseir-0.9.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 a9c868127b6a3a5d171b6407959a4a5197c3085a05d448e39c84fb3cab85c711
MD5 bd794525c4ff37a16334726cf74b32da
BLAKE2b-256 08fdca5de2cc4303b287bd7ceecb301421ab68a7d01f4df78f751d48e83e3e2d

See more details on using hashes here.

File details

Details for the file pylibsparseir-0.9.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylibsparseir-0.9.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1171d30381d69a121b79ea63ad338d4d80143a2127c3fa36d1ca2fb930e57166
MD5 c2f988fd565bf3adc2dd877f03cfdf40
BLAKE2b-256 36e54b7c7358097f777a62730437d1057d0444048059199659e3d8fead9ee397

See more details on using hashes here.

File details

Details for the file pylibsparseir-0.9.0-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pylibsparseir-0.9.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 0ca9cf9b7e0caf879541a44c9b5516517cfb1e9c0e9cc6d3e9c482cc92fac18d
MD5 cbeb2748415c3fb949f8e3e3ad0916d0
BLAKE2b-256 9160aa9007373a6a7d845d0670023a13748dec155b6b94dcb42cba22b7fb6aec

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.9.0 This release

10 files

0.8.4

8 files

0.8.3

8 files

0.8.2

8 files

0.8.0

8 files

0.7.5

8 files

0.7.4

8 files

0.7.3

8 files

0.6.0

16 files

0.5.2

16 files

0.1.0

16 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page