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

feat(7430) - Add support to spawn python REPL with uvx python or uvx python@<version> #7491

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mikeleppane
Copy link
Contributor

@mikeleppane mikeleppane commented Sep 18, 2024

Summary

This PR adds support to spawn Python REPL with the following commands:

uvx python # or
uvx [email protected] # or
uvx [email protected]

Test Plan

I added a few snapshot tests to the crates/uv/tests/tool_run.rs.

CI passes

Manual Tests

cargo run -- tool run python                                                                                                                                  ░▒▓ 99% 󰁹
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.42s
     Running `target/debug/uv tool run python`
Python 3.12.1 (main, Jan  8 2024, 05:57:25) [Clang 17.0.6 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
cargo run -- tool run [email protected]                                                                                                                           ░▒▓ 99% 󰁹
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.21s
     Running `target/debug/uv tool run '[email protected]'`
Python 3.9.20 (main, Sep  9 2024, 22:13:21)
[Clang 18.1.8 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
cargo run -- tool run [email protected]                                                                                                                        ░▒▓ 99% 
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.24s
     Running `target/debug/uv tool run '[email protected]'`
Python 3.13.0rc2 (main, Sep  9 2024, 22:13:26) [Clang 18.1.8 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
cargo run -- tool run [email protected]                                                                                                                         ░▒▓ 99% 
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.41s
     Running `target/debug/uv tool run '[email protected]'`
Python 3.13.0b3 (main, Sep 12 2024, 19:13:56) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Remarks/Questions

  • uvx python@latest does not work, and I'm unsure how to handle this. Is this a valid alternative?
  • uvx python launches REPL from system env? Is that correct? Or should it take the default interpreter from the virtual environment?
  • uv tool run has many options when running uvx python. E.g. --python?
  • Do you think we should document this change somewhere? If so, what would be the correct place?

Related to issue #7430

@mikeleppane mikeleppane marked this pull request as draft September 18, 2024 11:38
@mikeleppane mikeleppane changed the title feat(7430) - Add support to spawn python interpreter with uvx python or uvx python<version> feat(7430) - Add support to spawn python REPL with uvx python or uvx python<version> Sep 18, 2024
@mikeleppane mikeleppane marked this pull request as ready for review September 18, 2024 12:52
@mikeleppane mikeleppane changed the title feat(7430) - Add support to spawn python REPL with uvx python or uvx python<version> feat(7430) - Add support to spawn python REPL with uvx python or uvx python@<version> Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant