Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow --gui-script on Unix #9787

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions crates/uv/src/commands/project/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1404,10 +1404,7 @@ impl RunCommand {
} else if script {
return Ok(Self::PythonScript(target.clone().into(), args.to_vec()));
} else if gui_script {
if cfg!(windows) {
return Ok(Self::PythonGuiScript(target.clone().into(), args.to_vec()));
}
anyhow::bail!("`--gui-script` is only supported on Windows. Did you mean `--script`?");
return Ok(Self::PythonGuiScript(target.clone().into(), args.to_vec()));
}

let metadata = target_path.metadata();
Expand Down
19 changes: 13 additions & 6 deletions crates/uv/tests/it/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2895,7 +2895,7 @@ fn run_script_explicit_directory() -> Result<()> {

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

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

#[test]
#[cfg(not(windows))]
fn run_gui_script_not_supported() -> Result<()> {
fn run_gui_script_explicit_unix() -> Result<()> {
let context = TestContext::new("3.12");
let test_script = context.temp_dir.child("script");
test_script.write_str(indoc! { r#"
# /// script
# requires-python = ">=3.11"
# dependencies = []
# ///
print("Hello")
import sys
import os

executable = os.path.basename(sys.executable).lower()
print(f"Using executable: {executable}", file=sys.stderr)
"#})?;

uv_snapshot!(context.filters(), context.run().arg("--gui-script").arg("script"), @r###"
success: false
exit_code: 2
success: true
exit_code: 0
----- stdout -----

----- stderr -----
error: `--gui-script` is only supported on Windows. Did you mean `--script`?
Reading inline script metadata from `script`
Resolved in [TIME]
Audited in [TIME]
Using executable: python3
"###);

Ok(())
Expand Down
Loading