Skip to content

feat!: update dependencies (including PyO3) - #592

Open
BatmanAoD wants to merge 19 commits into
mainfrom
update-core-deps
Open

feat!: update dependencies (including PyO3)#592
BatmanAoD wants to merge 19 commits into
mainfrom
update-core-deps

Conversation

@BatmanAoD

@BatmanAoD BatmanAoD commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Note: updating PyO3 is a build-breaking change

Resolves #590

@windsurf-bot windsurf-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 🤙

💡 To request another review, post a new comment with "/windsurf-review".

@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://rigetti.github.io/qcs-sdk-rust/pr-preview/pr-592/

Built to branch qcs-sdk-python-docs at 2026-08-15 00:50 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

jselig-rigetti
jselig-rigetti previously approved these changes Jul 31, 2026
@BatmanAoD
BatmanAoD requested a review from erichulburd as a code owner August 11, 2026 21:15
@BatmanAoD
BatmanAoD force-pushed the update-core-deps branch 2 times, most recently from dfe5514 to a975de5 Compare August 12, 2026 03:16
BatmanAoD and others added 2 commits August 11, 2026 22:25
Two problems with the switch to uv, both of which only appear on a fresh checkout:

Scope VIRTUAL_ENV to the cargo-make tasks that need it, rather than setting it
globally. PyO3's build script reads VIRTUAL_ENV, so a global value pointed every
cargo build at a virtual environment that does not exist yet, breaking both the
pure-Rust `ci-flow` and `check-generated-python-files`:

    error: failed to run the Python interpreter at .../.venv/bin/python

Make libpython discoverable. `stub_gen` is a binary rather than an
`extension-module` cdylib, so it links against libpython and must find it at load
time. `ensure-venv` exports the interpreter's LIBDIR on LD_LIBRARY_PATH, but that
export does not survive from the `install-python-deps` task, as each cargo-make
task is its own process:

    stub_gen: error while loading shared libraries: libpython3.13.so.1.0

So `generate-stubs` sources `ensure-venv` directly, and CI publishes the same
environment job-wide — which is what `actions/setup-python` provided before it
was removed here as redundant.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The v1 action is a Node 20 action being force-run on Node 24, and intermittently
fails while downloading protoc:

    Error: self-signed certificate; if the root CA is installed locally, try
    running Node.js with --use-system-ca

v3 matches against protobuf's post-3.20 release names, so the pinned '3.20.1' no
longer resolves; 21.0 is its immediate successor and is what release-python.yml
already pins for its own v3 usage.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@BatmanAoD
BatmanAoD dismissed jselig-rigetti’s stale review August 12, 2026 04:37

significant changes, largely from LLM

@BatmanAoD BatmanAoD changed the title feat: update dependencies feat!: update dependencies (including PyO3) Aug 12, 2026
Comment thread .github/workflows/checks.yml Outdated
Comment thread .github/workflows/checks.yml Outdated
Comment thread .github/workflows/checks.yml Outdated
Comment thread .github/workflows/checks.yml
Comment thread .github/workflows/checks.yml Outdated
Comment thread crates/lib/Makefile.toml Outdated
Comment thread crates/lib/Makefile.toml Outdated
Comment thread crates/lib/Makefile.toml Outdated
Comment thread crates/lib/Makefile.toml Outdated
Comment thread scripts/ensure-venv Outdated
@BatmanAoD BatmanAoD mentioned this pull request Aug 12, 2026
BatmanAoD and others added 2 commits August 14, 2026 13:10
The `format` task previously targeted `python/qcs_sdk` — which is generated —
and `tests`, the Rust integration-test directory, so the actual Python sources
had never been formatted. This is the result of pointing it at them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@BatmanAoD
BatmanAoD force-pushed the update-core-deps branch 2 times, most recently from f4e34c7 to 839f5a2 Compare August 14, 2026 19:23
init_submodule("qcs_sdk._qcs_sdk", py, m)?;

m.add("__version__", env!("CARGO_PKG_VERSION"))?;
m.setattr("__doc__", PACKAGE_DOC)?;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBD: do this, or just return to having a handwritten __init__.py?

Comment on lines +30 to +41
/// Rewrite `import a.b.c` as `from a.b import c` in generated stubs, where the stub refers
/// to the module as `c`.
///
/// `pyo3_stub_gen` writes the `from ... import ...` form only for modules under our own
/// package, and a plain `import a.b.c` for every other module — but it refers to types in
/// those modules by the last component alone, as in `program.Program`. A dotted `import`
/// binds only the leftmost name, so those references are undefined. This affects any type
/// we borrow from `quil` or `qcs_api_client_common`.
///
/// Only imports whose fully-qualified path is never used are rewritten, which leaves
/// correct cases such as `import collections.abc` (used as `collections.abc.Sequence`)
/// alone.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to know before merging whether this actually makes sense

@asaites asaites left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've only reviewed the Makefile.toml, but I had several thoughts, so I reckoned I'd share them immediately. I'll have a look at the rest of the PR soon.

Comment thread crates/lib/Makefile.toml Outdated
Comment thread crates/lib/Makefile.toml Outdated
Comment thread crates/lib/Makefile.toml Outdated
Comment thread crates/lib/Makefile.toml
fi
uv sync --active --group dev
'''

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some other repos we have that use uv, we just use uv run, for example:

[tasks.stubtest]
dependencies = ["install-python-package"]
description = "Validate type stubs using stubtest"
cwd = "python"
command = "uv"
args = [
    "run", "--group", "dev",
    "stubtest",
    "--allowlist", "stubtest-allowlist",
    "--ignore-disjoint-bases",
    "qcs_api_client_common",
]

If uv is installed in a virtual env, it'll print a warning that the environment used by uv run is the project's environment (.venv/), but that can be safely ignored. Using --active potentially bypasses the local .venv

We probably should just let uv be managed by the host, as we would with other tools (so we don't really care if uv is a binary installed via homebrew, a module in a virtual environment, an alias to pipx, etc.). That said, in at least one other project, we explicitly require that we're running in a virtual environment and install uv into it:

[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.upgrade-pip]
dependencies = ["check-venv"]
description = "Upgrade pip to ensure it supports depency groups"
command = "pip"
args = ["install", "--upgrade", "pip"]

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

Realistically, I think the virtual environment check only makes sense if we're going to install/upgrade pip and uv ourselves from the Makefile.toml, and I am inclined to say we shouldn't (or at least not by default); instead, we should just let uv do its thing and call it a day. In CI, we should ensure the right tools are installed, and for developers, we should tell them what tools they need (though I'm not opposed to a convenience task to handle that install -- which we could then call during CI a setup phase).

Comment thread crates/lib/Makefile.toml Outdated
Comment thread crates/lib/Makefile.toml Outdated
Comment thread crates/lib/Makefile.toml Outdated
Comment thread crates/lib/Makefile.toml Outdated
args = ["run", "maturin", "develop"]
dependencies = ["install-python-deps", "generate-stubs"]
command = "uv"
args = ["run", "--active", "maturin", "develop", "--uv"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that it's already running from uv, do we really need this flag?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would maturin know that it's running inside of a uv run without this flag?

Comment thread crates/lib/Makefile.toml Outdated
Comment thread crates/lib/Makefile.toml Outdated
command = "poetry"
args = ["run", "black", "python/qcs_sdk", "tests"]
command = "uv"
args = ["run", "--active", "black", "tests_py", "scripts"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An aside to this PR, we should probably use ruff for this instead.

@BatmanAoD
BatmanAoD force-pushed the update-core-deps branch 2 times, most recently from 53fd9f0 to b78a5f5 Compare August 15, 2026 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

We should update rigetti-pyo3 and related dependencies

4 participants