Metadata-Version: 2.4
Name: pyQPal
Version: 0.1.1
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Summary: python Bindings for the Rust Crate QPalRust
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# pyQPal — Python Bindings for QPal

[![License](https://img.shields.io/badge/License-BSD_2--Clause-orange.svg)](../../../../LICENSE)

Python bindings for the [QPal](https://github.com/sse-labs/QPal) quantum program analysis library. Exposes OpenQASM 2/3 parsing and gate list extraction via a native Rust extension built with [PyO3](https://pyo3.rs/) and [maturin](https://www.maturin.rs/).

## Installation

### From a pre-built wheel

```bash
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.

