python Bindings for the Rust Crate QPalRust
Project description
pyQPal — Python Bindings for QPal
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
Release history Release notifications | RSS feed
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyqpal-0.1.0-cp312-cp312-manylinux_2_35_x86_64.whl.
File metadata
- Download URL: pyqpal-0.1.0-cp312-cp312-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.12, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc910bc39cbbe354ea9a2f839cb969880c735f60d8be2133536022d5b276e294
|
|
| MD5 |
4838da9707b807c200e785d00a624fdc
|
|
| BLAKE2b-256 |
550756675aba1a9c588805a748be909bf8eba93bd98c7cdfa8cc18e1381b67db
|