qcs-sdk-python 0.21.22

Python bindings to qcs-sdk-rust
Documentation
[env]
PYTHONPATH = { script = [ "python -c 'from sysconfig import get_path; print(get_path(\"platlib\"))'" ] }
RUST_BACKTRACE = 0

[tasks.check-venv]
description = "Check if a virtual environment is activated"
script = [
    '''
    if [ -z "$VIRTUAL_ENV" ]; then
        echo "No virtual environment activated. Please activate one."
        exit 1
    else
        echo "Virtual environment is active."
    fi
    '''
]

[tasks.install-uv]
dependencies = ["check-venv"]
description = "Install dependencies using uv"
command = "pip"
args = ["install", "uv"]

[tasks.install-deps]
dependencies = ["install-uv"]
description = "Install project dependencies using uv."
script = [
    '''
    uv pip compile pyproject.toml --all-extras > requirements-dev.txt
    uv pip install -r requirements-dev.txt
    rm requirements-dev.txt
    '''
]

[tasks.maturin-develop]
dependencies = ["check-venv", "install-deps"]
description = "Build the python package and install to the active virtual environment."
command = "maturin"
args = ["develop", "--features", "pyo3-tracing-subscriber-build"]

[tasks.install-python-package]
dependencies = ["maturin-develop", "format-tracing-subscriber"]

[tasks.pre-test-docker-up]
script = [
    '''
    docker compose up -d || { echo 'Warning: `docker compose up` failed. Assuming QVM and quilc are running already.'; true; }
    '''
]

[tasks.format-tracing-subscriber]
command = "black"
args = ["qcs_sdk/_tracing_subscriber"]

[tasks.format]
command = "black"
args = ["qcs_sdk", "tests"]

[tasks.post-test]
script = [
    '''
    docker compose down || true
    '''
]

[tasks.test]
command = "pytest"
args = ["tests"]

[tasks.test-session]
command = "pytest"
args = ["tests", "--with-qcs-session"]

[tasks.test-execution]
command = "pytest"
args = ["tests", "--with-qcs-session", "--with-qcs-execution"]

[tasks.pytest-flow]
dependencies = [
    "pre-test-docker-up",
    "install-python-package",
    "test",
    "post-test",
]

[tasks.stubtest]
command = "stubtest"
# temporary - handwritten stubs will be removed by https://github.com/rigetti/qcs-sdk-rust/issues/566
ignore_errors = true
args = [
    "--allowlist",
    ".stubtest-allowlist",
    "--allowlist",
    "./qcs_sdk/_tracing_subscriber/.stubtest-allowlist",
    "qcs_sdk"
]

[tasks.stubtest-flow]
dependencies = [
    "install-python-package",
    "stubtest",
]

[tasks.dev-flow]
dependencies = ["dev-test-flow", "pytest-flow", "stubtest"]

[tasks.default]
alias = "dev-flow"

[tasks.ci-flow]
dependencies = ["pytest-flow", "stubtest"]

[tasks.docs]
dependencies = ["install-python-package"]
command = "pdoc"
args = ["-o", "build/docs", "qcs_sdk", "!qcs_sdk.qcs_sdk", "--logo", "https://qcs.rigetti.com/static/img/rigetti-logo.svg"]