Skip to content

Commit 3230ef6

Browse files
Add ability to use pythonw.exe (closes #4)
1 parent 36d5ae9 commit 3230ef6

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name = "pyenv-py"
33
version = "0.2.2"
44
edition = "2021"
55

6+
[features]
7+
pythonw = []
8+
69
[[bin]]
710
name = "py"
811
path = "src/main.rs"

src/main.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,19 @@ fn main() {
180180
.position(|v| v.components().nth_back(1).unwrap().as_os_str() != "versions"),
181181
};
182182

183-
let python_binary = match version_idx_opt {
183+
let binary_name = if cfg!(feature = "pythonw") {
184+
"pythonw"
185+
} else {
186+
"python"
187+
};
188+
189+
let binary_path = match version_idx_opt {
184190
Some(version_idx) => find_binary_on_paths(
185-
"python",
191+
binary_name,
186192
vec![py_bin_locs[version_idx].to_owned()].into_iter(),
187193
)
188194
.unwrap_or_else(|| {
189-
eprintln!("Unable to find python binary");
195+
eprintln!("Unable to find '{}' binary", binary_name);
190196
process::exit(1);
191197
}),
192198

@@ -198,10 +204,10 @@ fn main() {
198204

199205
ctrlc::set_handler(move || {}).expect("Unable to set Ctrl-C handler");
200206

201-
let status = Command::new(python_binary)
207+
let status = Command::new(binary_path)
202208
.args(py_call_args)
203209
.status()
204-
.expect("Unable to execute the binary");
210+
.unwrap_or_else(|_| panic!("Unable to execute '{}' binary", binary_name));
205211

206212
exit_with_child_status(status);
207213
}

0 commit comments

Comments
 (0)