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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

pylibsparseir-0.7.3-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.3-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.3-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylibsparseir-0.7.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7a94a5cb4c7434824ec1e6069a580d7bd3de2a355cba4bba6e326f69844b1a11
MD5 0b2a842b0e1379f5b81c36a93733e97c
BLAKE2b-256 dfa1ba3080d9607f0811eb2ce03520cc528695d213ad9646ce7a44ad7097c004

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.7.3-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5f040ebb082624e6665f67126d7670609abb3abdf8f59b08d7c2faf1aaee9222
MD5 b426495d46e9d107a3a740f979bc35c1
BLAKE2b-256 6aa722a7d62ffb4d7b9a0d351e3578e5865e60cbfce1f00826d31e5d6e49c034

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.7.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fbd50e23a58ca9b648baa7bf52b5c2c0c92cb55f05101b44bee27e70697c8a31
MD5 e6f53dc067c1d72bae47910068c03b8d
BLAKE2b-256 13cbe58177ca89c5c5acc43efd2cf256add85b6a0dd0370247bd46367002e90a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.7.3-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ad7f624684a8eba70e9de665e567ec188d275b4136ee2ec12aced2cd30d41b99
MD5 5595a88ebff80982de37445b4fb64f2d
BLAKE2b-256 81c7c0a9b036b811bb1fcdb4c3acf96b3326145f5ad65e21bb55cdc95126271a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.7.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d86994fc0cc2a60faedcf1d56274bd60bc3d55718ab738d3fd7ffa072bd9701a
MD5 5d5a43c65f2bce16265ca38ed6293ddb
BLAKE2b-256 d08b2c97154459820fdd9fcab76e44d3f798b94d232121211835264176304560

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.7.3-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 27025b9b9ab498cb1003c9291bcd4df85e78b32ad3481352caccdabb05efdca5
MD5 47b5d000ad0fdc24a8a20f1a0c2bf30b
BLAKE2b-256 a7e17d5af31b34913902b305216e7febfb942fbea94a0ba5b144d7cfe67a8ab8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.7.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 52ca69631e325b6488abee15828681ccdffa7d797b2c2a2fd34586c734d6dacc
MD5 c360669e5f90da9e5fc407100106cfec
BLAKE2b-256 a534744c85863e492cb31fd4d8d3b2981099714cedee951a1a63042981a0eb2a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pylibsparseir-0.7.3-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f0a0c1bcc57dd4ee770185154d0d1b12c88069efcff4203c721d903a60637742
MD5 5d199129b45947aa6d5231bec1a6ec4b
BLAKE2b-256 fa98eb0503ba60a69ee9e45db8feea5dc1125f698212da37fae8b8559b8e3d36

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