-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add uv run
command
#3074
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
Add uv run
command
#3074
Conversation
#[derive(Args)] | ||
#[allow(clippy::struct_excessive_bools)] | ||
pub(crate) struct RunArgs { | ||
/// Command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs some explanation what command means and some examples, esp. compared to
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to reserve the real documentation for when it's a little more nailed down what the interface is. I think I extend these a bit in the next pull request though.
// Spawn and wait for completion | ||
// Standard input, output, and error streams are all inherited | ||
// TODO(zanieb): Throw a nicer error message if the command is not found | ||
let mut handle = process.spawn()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use .status()
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could switch yeah, I thought I might need to do something while it's running but perhaps not?
let status = handle.wait().await?; | ||
|
||
// Exit based on the result of the command | ||
// TODO(zanieb): Do we want to exit with the code of the child process? Probably. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is important for scripts that check the output status of the python code (e.g. exit status 1 vs exit status 2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah agree that's just not built into our exit system so I want to do it separately
Some things i learned i'm gonna dump here: You can load dlopen libpython and use the c api to load libpython, and run Again on unix, you use |
Thanks for the notes! Do you see a strong benefit to doing |
Not really, |
Adds
uv run
which executes a command in your current virtual environment.This is a simple first milestone, lots of remaining work and behavior. The command is hidden.