Skip to content

Comments

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

Closed
mikeleppane wants to merge 3 commits intoastral-sh:mainfrom
mikeleppane:feat(7430)/spawn-repl-with-uvx-python
Closed

feat(7430) - Add support to spawn python REPL with uvx python or uvx python@<version>#7491
mikeleppane wants to merge 3 commits intoastral-sh:mainfrom
mikeleppane:feat(7430)/spawn-repl-with-uvx-python

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
@inoa-jboliveira
Copy link

I think I like #7677 approach better.
But this is not bad

@zanieb zanieb self-assigned this Oct 7, 2024
@mikeleppane
Copy link
Contributor Author

Hey, should I close this PR? It seems like no one's interested. Is this feature already implemented?

@zanieb
Copy link
Member

zanieb commented Nov 18, 2024

Sorry, I'm still interested but I think we might want a different approach to the implementation and haven't had the time to explore it myself to give a concrete recommendation.

@zanieb
Copy link
Member

zanieb commented Jan 29, 2025

I took this over in #11076 — your feedback would be welcome!

@zanieb zanieb closed this Jan 29, 2025
zanieb added a commit that referenced this pull request Jan 30, 2025
Supersedes #7491
Closes #7430

Thanks @mikeleppane for starting this implementation. I took a bit of a
different approach and it was easier to start over fresh, but I used
some of the test cases there.
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.

3 participants