Skip to main content

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:

  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:

    • 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

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


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.8.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.8.0-cp313-cp313-macosx_15_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

pylibsparseir-0.8.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.8.0-cp312-cp312-macosx_15_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

pylibsparseir-0.8.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.8.0-cp311-cp311-macosx_15_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

pylibsparseir-0.8.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.8.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.8.0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylibsparseir-0.8.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d7250d854ed789c672f52626846d2295330b1853ce703f374e504789dabf59bc
MD5 55a199e4bb88248f4c4ba3b77f492884
BLAKE2b-256 0b39c85313542bcf35b2ea87a92748df8892ca1b23f27612a715439bf7d2a2cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.8.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 29d5588394ee78b47b60a0e30f51b817d286fd2d7aee270fe66f37a97a6c02a4
MD5 31bfee9b62828806e493f7945352e47d
BLAKE2b-256 325fb8b5273f98c9e288844ed230a9640bc3acc2ca5693a8015f0b9a67c67b3d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.8.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f318c4d914bd3b3b870f551d5e2972b52c09599df9b6cca85449898247a5b58d
MD5 146cc6694906a0da5a9d47eb5bff80fd
BLAKE2b-256 427f59770b2f852e3bf3a073559a99137f44f76ca80132374735cd5537ca842e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.8.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 3c735ccdfc54e4c7129f409fd6a0667faf88dd8261de15360e42d2faab69d9a6
MD5 c5abcc623dc5b41b02b9ef89e49162d8
BLAKE2b-256 e8f1a4ab298ecfb0ad63b08a127dcf3edbe28bd38e7ba81946339ce482f8e343

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.8.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 237686131585061af096a9806c08c1433a35ce2779ad57d4d66663916d82a62e
MD5 602cc2ec642a092a499b669facf27dc0
BLAKE2b-256 95a0f7437cbd5c63fa04352226c66cc09e936565f2743c043e67b78a378645db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.8.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9cf0539e9eddc4ca1bea4763d0653726769c8898942f73ea1a843cc1a37ddd65
MD5 b450c0ad2cd56aa7ad04caf58504e495
BLAKE2b-256 046f0b55268f786a2c2a03c89f5c058b159e11bc9e1aa996d073666b15718336

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.8.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f3bcfb1be295dd7927db7fcb29fa82893a11066d4dceedc829b6f31bcafaa1f8
MD5 88dad959edf2b435481db9e841aff4a1
BLAKE2b-256 825b47801c5cd7fcaaed58f3c6996021a4e2b0d42e669ed0e8ccf28fa5013e38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.8.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 3a377e716804fcb1e2444bbef9780826577dda8ee2a26b9013afadf2709f5a48
MD5 ee21d4cf194a1c4a0e3c0d39dbf11422
BLAKE2b-256 a754f5d243dbf75afb546b792d0cf5235fbacb11680fbd35e65464e0543f21b8

See more details on using hashes here.

Supported by

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