Add --gui-script flag for running Python scripts with pythonw.exe on … (#9152)
Addresses #6805 ## Summary This PR adds a `--gui-script` flag to `uv run` that allows running Python scripts with `pythonw.exe` on Windows, regardless of file extension. This solves the issue where users need to maintain duplicate `.py` and `.pyw` files to run the same script with and without a console window. The implementation follows the pattern established by the existing `--script` flag, but uses `pythonw.exe` instead of `python.exe` on Windows. On non-Windows platforms, the flag is present but returns an error indicating it's Windows-only functionality. Changes: - Added `--gui-script` flag (Windows-only) - Added Windows test to verify GUI script behavior - Added non-Windows test to verify proper error message - Updated CLI documentation ## Test Plan The changes are tested through: 1. New Windows-specific test that verifies: - Script runs successfully with `pythonw.exe` when using `--gui-script` - Console output is suppressed in GUI mode but visible in regular mode - Same script can be run both ways without modification 2. New non-Windows test that verifies: - Appropriate error message when `--gui-script` is used on non-Windows platforms 3. Documentation updates to clearly indicate Windows-only functionality --------- Co-authored-by: Zanie Blue <contact@zanie.dev>
This commit is contained in:
committed by
GitHub
parent
761dafd0d1
commit
f6f9179a5a
@@ -184,6 +184,10 @@ uv run [OPTIONS] [COMMAND]
|
||||
|
||||
<p>May be provided multiple times.</p>
|
||||
|
||||
</dd><dt><code>--gui-script</code></dt><dd><p>Run the given path as a Python GUI script.</p>
|
||||
|
||||
<p>Using <code>--gui-script</code> will attempt to parse the path as a PEP 723 script and run it with pythonw.exe, irrespective of its extension. Only available on Windows.</p>
|
||||
|
||||
</dd><dt><code>--help</code>, <code>-h</code></dt><dd><p>Display the concise help for this command</p>
|
||||
|
||||
</dd><dt><code>--index</code> <i>index</i></dt><dd><p>The URLs to use when resolving dependencies, in addition to the default index.</p>
|
||||
|
||||
Reference in New Issue
Block a user