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.7.5-cp313-cp313-manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

pylibsparseir-0.7.5-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.7.5-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylibsparseir-0.7.5-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8f58fa2b77e9fe25233cca9beaa7e9bcbf8b11edb00d007f8b02e58596d44db1
MD5 2784d64b877e85b5b04aa425c29a5366
BLAKE2b-256 d126553af56360e426252196e935fc873f8aab0bfa3505d5e6ed7db6a42e491b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.7.5-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 7c1942cdb39846d89573f4aa1f85364cddf9854ec67e43c50d956d7d9864e6bd
MD5 b3046739dafaaa3063c6e76ea4b2a053
BLAKE2b-256 7d7bf9118067bef8d6e784abd996683bbf2bed104cc039171327b07cef2759e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.7.5-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 859994abf368aaeae0805d3e5c058ba1a717bbb5bb0d58c9520493ae69da5af9
MD5 65bbe9ae74dfb22642e42fbcbc0e0909
BLAKE2b-256 401f7922b181f82e086997aa3a273213c2b0334212d3089c8ce7e554ca9572ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.7.5-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c408cb4f37ffe75b9406638efeeabde1d0213ed230ac648671f2f71affe419a6
MD5 3ff1e046e64405922aa4da2160c966a3
BLAKE2b-256 0ae84c0809b4c2970dfacf6d516570ecb3dcb9f18fc2351a9e86745e36ce5af1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.7.5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b4c1e26c56a3716148063264f9b936d62fc9fea1a8e186569271ac914e8715a2
MD5 5550a66499d869b0b51720a1221e0b74
BLAKE2b-256 a0a95b498cda3a5d7ae7444d425664fde7e8233115a39ee9ff5272522f43313c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.7.5-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 0f4eb3bcf0c3cf8aa535e8a28fb3b792e91d2784657eaba426e9be09bfb52002
MD5 9377ec344cd45efc4fe4174a8d85e823
BLAKE2b-256 95965b64415ea855d219f61de877cab84dab2d6433d440a9ebed0b936c53a877

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.7.5-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e52251dfd076b32e037688e011355d1fef9903855cb8cb330ae19edb1b481d01
MD5 b37266fdd5f67412657b9ccaff614f48
BLAKE2b-256 df3f61f2c0a6e08e8efeb211f4a7c570cef87061a6fa5e558753be98ddfef7e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.7.5-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 8a3006fdbed974a635b70ad35324e2b5abf82f4f1dd5befa95da0ccf328630b1
MD5 6986f76393f514c6125a263f8affee30
BLAKE2b-256 17ec88255b9a7706af55b58c425a7f2a6ce2fa3cddd678c4010aede527fc3017

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