Skip to content

Commit 8538265

Browse files
committed
Fix venv invocation on windows
1 parent 6d59a8b commit 8538265

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

tests/bindings.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ where
143143
.assert()
144144
.success();
145145

146-
Command::new("./.venv/bin/pip")
146+
Command::new(venv_executable_path("pip"))
147147
.current_dir(path)
148148
.args(["install", "mypy"])
149149
.assert()
150150
.success();
151151

152-
Command::new("./.venv/bin/mypy")
152+
Command::new(venv_executable_path("mypy"))
153153
.current_dir(path)
154154
.args(args)
155155
.assert()
@@ -159,6 +159,13 @@ where
159159
)
160160
}
161161

162+
fn venv_executable_path(executable: &str) -> String {
163+
format!(
164+
"./.venv/bin/{executable}{}",
165+
if cfg!(windows) { ".exe" } else { "" }
166+
)
167+
}
168+
162169
fn install_numpy(path: &Path) {
163170
Command::new("curl")
164171
.current_dir(path)

tests/componentize.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,18 @@ fn sandbox_example() -> anyhow::Result<()> {
190190
.stdout("Component built successfully\n");
191191

192192
Command::new("python3")
193-
.current_dir(dir.path())
193+
.current_dir(&path)
194194
.args(["-m", "venv", ".venv"])
195195
.assert()
196196
.success();
197197

198-
Command::new("./.venv/bin/pip")
199-
.current_dir(dir.path())
198+
Command::new(venv_executable_path("pip"))
199+
.current_dir(&path)
200200
.args(["install", "wasmtime"])
201201
.assert()
202202
.success();
203203

204-
Command::new("../.venv/bin/python")
204+
Command::new(venv_executable_path("python"))
205205
.current_dir(&path)
206206
.args([
207207
"-m",
@@ -213,7 +213,7 @@ fn sandbox_example() -> anyhow::Result<()> {
213213
.assert()
214214
.success();
215215

216-
Command::new("../.venv/bin/python")
216+
Command::new(venv_executable_path("python"))
217217
.current_dir(&path)
218218
.args(["host.py", "2 + 2"])
219219
.assert()
@@ -298,3 +298,10 @@ fn install_numpy(path: &Path) {
298298
.assert()
299299
.success();
300300
}
301+
302+
fn venv_executable_path(executable: &str) -> String {
303+
format!(
304+
"./.venv/bin/{executable}{}",
305+
if cfg!(windows) { ".exe" } else { "" }
306+
)
307+
}

0 commit comments

Comments
 (0)