Skip to content

Commit 2b34916

Browse files
Fix: force pyo3 to pick up the virtual environment generated by uv rather than system Python
1 parent e9386d1 commit 2b34916

File tree

5 files changed

+155
-26
lines changed

5 files changed

+155
-26
lines changed

.wr.toml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
11
[[verification]]
22
command = "cargo"
3-
args = ["test"]
4-
5-
[[verification]]
6-
command = "uv"
7-
# We use `--all-packages` to avoid having to specify `pytest` as a dev
8-
# dependency in all packages.
9-
args = ["sync", "--all-packages"]
10-
11-
[[verification]]
12-
command = "uv"
13-
args = ["run", "pytest"]
3+
args = ["run", "--package", "verifier", "--bin", "verifier"]

Cargo.lock

Lines changed: 126 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[workspace]
2-
members = ["exercises/*/*"]
2+
members = ["exercises/*/*", "verifier"]
33
resolver = "2"
44

55
[workspace.dependencies]
66
anyhow = "1"
7+
duct = "0.13"
78
pyo3 = "0.23.3"
89
semver = "1.0.23"
910
serde = "1.0.204"

verifier/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "verifier"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
duct = { workspace = true }

verifier/src/main.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use duct::cmd;
2+
3+
fn main() -> Result<(), Box<dyn std::error::Error>> {
4+
// Create the project-specific Python virtual environment.
5+
println!("Creating the Python virtual environment...");
6+
cmd!("uv", "sync", "--all-packages").run()?;
7+
8+
println!("Testing the Rust crate...");
9+
let venv = std::env::current_dir()?.join(".venv");
10+
cmd!("cargo", "test")
11+
// Tell `pyo3` where to find the project-specific
12+
// virtual environment.
13+
.env("VIRTUAL_ENV", venv)
14+
.run()?;
15+
println!("Testing the Python package...");
16+
cmd!("uv", "run", "pytest").run()?;
17+
18+
Ok(())
19+
}

0 commit comments

Comments
 (0)