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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

pylibsparseir-0.8.2-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.2-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.2-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylibsparseir-0.8.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d9db201b32581f9cd0074989a3afb2838fb468d07c463988a764fee393eeca78
MD5 79f2cba0332c375db5db86d56c56ec4f
BLAKE2b-256 13538fe84b30769fa3de85b9f8fbc492785307397166a08a2a417e29e03a1e16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.8.2-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1da147742a94a24ad021d268e623431c2fab930e6518582d54c1d6184ba70ae7
MD5 ec4996b6fd9b17b165a851da608d2fb6
BLAKE2b-256 c97c993f0246b786a9e1e4cbbd3dd482faa7bb7a7de94d863e63073b9965e04f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.8.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5d1f8e8dcce8707330c55221e48917b099403da9632ab708c3ff4a03eb27c84e
MD5 3219ef372b25c19b28482f0de7a94c6e
BLAKE2b-256 29f1d1080243e47e441b5408f85ab20c0e3c758cc0c449416b4d0bde16f0cfa8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.8.2-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 78fa1b2845bcae05ccca54cc0ea2633b58022f668876567282ee3423afd001af
MD5 b02df5b126f94eb09fafe9c57d958359
BLAKE2b-256 69e5599d5661eb928ab535c04b52879fe68f75397d3c3c99697fa5617a21465b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.8.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6607492488795649471ab5f4ca632a59368c4224ae3f1bf8e15f41e39d67063e
MD5 65492a8c0e9d2f643cd92b6344efe879
BLAKE2b-256 0319d0796e6b091f2ad133434b467f8f941a9a49307c18289006af6f3ea54ae4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.8.2-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ec2cffec9f7b6d282872c455c3916fdc370b76639296c04a5ac1132bfb634f41
MD5 2bd6280fee2018d7ddd4ef816783e509
BLAKE2b-256 45e5f5c42342b83274a48c9f3f0475d373cce531bdc92dcee4fb41d788e0cf30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.8.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4f60874591847266f9fae9ea04efb665c97fb2347a80bdacbbeedbf548effadb
MD5 b15fe49e37d9435988c3b1c7c38661f3
BLAKE2b-256 d1c68b3572a907baf9605900d22c5a5647cc8f596e3ad1bcdaf21da1ce1dfd78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.8.2-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9fe3cb3fd7186fa35a25c0db673d427cbd6f9110c31fbcd87fbf8d0df61b7c0d
MD5 47341b475237bdd0a8cc1a8761c44428
BLAKE2b-256 4f906ffedfbcbb48485c2fee6007e30f065774a5d76d1c8dcbc201e0f8ec1bf5

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