Skip to content

Commit 68eedcb

Browse files
committed
Allow --gui-script on Unix
To match `uv run foo.pyw` behavior
1 parent f6f9179 commit 68eedcb

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

crates/uv/src/commands/project/run.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,10 +1404,7 @@ impl RunCommand {
14041404
} else if script {
14051405
return Ok(Self::PythonScript(target.clone().into(), args.to_vec()));
14061406
} else if gui_script {
1407-
if cfg!(windows) {
1408-
return Ok(Self::PythonGuiScript(target.clone().into(), args.to_vec()));
1409-
}
1410-
anyhow::bail!("`--gui-script` is only supported on Windows. Did you mean `--script`?");
1407+
return Ok(Self::PythonGuiScript(target.clone().into(), args.to_vec()));
14111408
}
14121409

14131410
let metadata = target_path.metadata();

crates/uv/tests/it/run.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2895,7 +2895,7 @@ fn run_script_explicit_directory() -> Result<()> {
28952895

28962896
#[test]
28972897
#[cfg(windows)]
2898-
fn run_gui_script_explicit() -> Result<()> {
2898+
fn run_gui_script_explicit_windows() -> Result<()> {
28992899
let context = TestContext::new("3.12");
29002900

29012901
let test_script = context.temp_dir.child("script");
@@ -2932,24 +2932,31 @@ fn run_gui_script_explicit() -> Result<()> {
29322932

29332933
#[test]
29342934
#[cfg(not(windows))]
2935-
fn run_gui_script_not_supported() -> Result<()> {
2935+
fn run_gui_script_explicit_unix() -> Result<()> {
29362936
let context = TestContext::new("3.12");
29372937
let test_script = context.temp_dir.child("script");
29382938
test_script.write_str(indoc! { r#"
29392939
# /// script
29402940
# requires-python = ">=3.11"
29412941
# dependencies = []
29422942
# ///
2943-
print("Hello")
2943+
import sys
2944+
import os
2945+
2946+
executable = os.path.basename(sys.executable).lower()
2947+
print(f"Using executable: {executable}", file=sys.stderr)
29442948
"#})?;
29452949

29462950
uv_snapshot!(context.filters(), context.run().arg("--gui-script").arg("script"), @r###"
2947-
success: false
2948-
exit_code: 2
2951+
success: true
2952+
exit_code: 0
29492953
----- stdout -----
29502954
29512955
----- stderr -----
2952-
error: `--gui-script` is only supported on Windows. Did you mean `--script`?
2956+
Reading inline script metadata from `script`
2957+
Resolved in [TIME]
2958+
Audited in [TIME]
2959+
Using executable: python3
29532960
"###);
29542961

29552962
Ok(())

0 commit comments

Comments
 (0)