Skip to main content

python Bindings for the Rust Crate QPalRust

Project description

pyQPal — Python Bindings for QPal

License

Python bindings for the QPal quantum program analysis library. Exposes OpenQASM 2/3 parsing and gate list extraction via a native Rust extension built with PyO3 and maturin.

Installation

From a pre-built wheel

pip install pyQPal
From source (development)
Requires Rust toolchain (edition 2024) and Python 3.8+.
# Install maturin
pip install maturin

# Build and install into the current virtual environment
maturin develop --release

# Or build a wheel
maturin build --release
Using the top-level Makefile:
make rust-python    # Build core Rust library with Python feature
make python         # Build pyQPal wheel
make develop        # Install into current venv
Usage
import py_q_pal

# Parse an OpenQASM 3 file and return the AST as a string
ast_str = py_q_pal.parse_openqasm3_tostring("circuit.qasm")
print(ast_str)

# Get the ordered list of gates
gates = py_q_pal.get_gate_list("circuit.qasm")
for g in gates:
    print(g.qubits, g.gate_name)
API Reference
Functions
- parse_openqasm3(path: str) -> Expr  Parse a QASM file and return the AST as an Expr object.
- parse_openqasm3_tostring(path: str) -> str  Parse a QASM file and return the AST as a debug string.
- get_gate_list(path: str) -> list[CompactGateData]  Parse a QASM file and return the ordered list of gates.
Classes
- CompactGateData  Represents a gate instance with fields qubits, gate_name, control_bits, and parameters.
- GateName  Enumeration of supported gate names.
- ControlBit  Represents a control qubit modifier (type, value).
Development
Iterate with hot-reload:
maturin develop
Run Rust tests for the core library:
cd ../../QPalRust && cargo test
License
BSD 2-Clause. See the LICENSE (../../../../LICENSE) file.

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.

pyqpal-0.1.1-cp313-cp313-manylinux_2_35_x86_64.whl (16.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ x86-64

pyqpal-0.1.1-cp312-cp312-manylinux_2_35_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

pyqpal-0.1.1-cp311-cp311-manylinux_2_35_x86_64.whl (16.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.35+ x86-64

pyqpal-0.1.1-cp310-cp310-manylinux_2_35_x86_64.whl (16.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.35+ x86-64

File details

Details for the file pyqpal-0.1.1-cp313-cp313-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for pyqpal-0.1.1-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 d5c6e3264eedac12738f6a751608fe0f83de3d513aae41fcf9c734602bfbae3c
MD5 3243629f67613ac0bced22648a9ddc92
BLAKE2b-256 5cc8845c66c9e4c0e371c559781205996f6dfe6d0d6ef659ddb02851f0c9cb07

See more details on using hashes here.

File details

Details for the file pyqpal-0.1.1-cp312-cp312-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for pyqpal-0.1.1-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 da702357e3d8e192bf6b9119cbe8fcf3a6ce352f67529fc828129dc420aa2ce7
MD5 229cbc9f8f9517f83b93e2fdaef440e8
BLAKE2b-256 2a0c35058f31fa79c503d5115ddf25a4c808727d9126bc8ef261dfe2a6c8282c

See more details on using hashes here.

File details

Details for the file pyqpal-0.1.1-cp311-cp311-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for pyqpal-0.1.1-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 f036dd003b58e6c4bf0f47eacae84492178d653fd5930a197e61974c09e68134
MD5 824719456599b5858d32f21fb1a0c06f
BLAKE2b-256 75bac99a0f3b53aa50cc8b230d6df69c035843744d690df536eecbb0716b9df0

See more details on using hashes here.

File details

Details for the file pyqpal-0.1.1-cp310-cp310-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for pyqpal-0.1.1-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 cb995098775309f8d9ac6f44c1a5f9779c6d41e7b23f8bb8aa51ed0ba0595ec6
MD5 b71dc91b6d20a3e3ba40488295ef5786
BLAKE2b-256 ac1d1a315852cf00fb598c7c96acb420fd8232458c8ec117b92e2c863869008f

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