feat!: update dependencies (including PyO3) - #592
Conversation
6cc9b68 to
adff512
Compare
|
adff512 to
1b6cf97
Compare
1b6cf97 to
ce8982c
Compare
dfe5514 to
a975de5
Compare
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>
a975de5 to
9d60064
Compare
significant changes, largely from LLM
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>
f4e34c7 to
839f5a2
Compare
839f5a2 to
db9de57
Compare
| init_submodule("qcs_sdk._qcs_sdk", py, m)?; | ||
|
|
||
| m.add("__version__", env!("CARGO_PKG_VERSION"))?; | ||
| m.setattr("__doc__", PACKAGE_DOC)?; |
There was a problem hiding this comment.
TBD: do this, or just return to having a handwritten __init__.py?
| /// 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. |
There was a problem hiding this comment.
I want to know before merging whether this actually makes sense
25f4e64 to
23b328d
Compare
asaites
left a comment
There was a problem hiding this comment.
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.
| fi | ||
| uv sync --active --group dev | ||
| ''' | ||
|
|
There was a problem hiding this comment.
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).
| args = ["run", "maturin", "develop"] | ||
| dependencies = ["install-python-deps", "generate-stubs"] | ||
| command = "uv" | ||
| args = ["run", "--active", "maturin", "develop", "--uv"] |
There was a problem hiding this comment.
Given that it's already running from uv, do we really need this flag?
There was a problem hiding this comment.
How would maturin know that it's running inside of a uv run without this flag?
| command = "poetry" | ||
| args = ["run", "black", "python/qcs_sdk", "tests"] | ||
| command = "uv" | ||
| args = ["run", "--active", "black", "tests_py", "scripts"] |
There was a problem hiding this comment.
An aside to this PR, we should probably use ruff for this instead.
53fd9f0 to
b78a5f5
Compare
b78a5f5 to
daf26b7
Compare
Note: updating PyO3 is a build-breaking change
Resolves #590