If you use uv, what are your use cases for uvx?
Posted by Zaloog1337@reddit | Python | View on Reddit | 33 comments
I really love uv
as my new All-In-One tool for python project management.
I also really like the uv tool
functionality for tools I regularly use like Harlequin or my kanban/tasks apps kanban-python
and more lately the less minimal kanban-tui
.
But I it never really clicked for me when I would use uvx
which basically installs a tool temporary and after usage removes it again (though still cached, so future uses go faster).
Currently I am on my way to release v0.4.0 of (kanban-tui)[https://github.com/Zaloog/kanban-tui] with multi board support and board-individual columns. I develop those features in a new branch and just discovered that you can use something like:
uvx --from git+https://github.com/Zaloog/kanban-tui@lg/independent-board-columns ktui demo
to install the current development status from a custom branch (or even commit) within seconds. A great way to quickly share the current progress of your work with friends or use your tool on your system already without creating a new release yet.
I am curious to hear, what are your use cases for uvx
, and what are your favourite tools to use with it?
gofiend@reddit
There are useful python apps that you want available everywhere. e.g. Aider.chat and https://github.com/xxh/xxh
rghthndsd@reddit
I'm 87% certain they're just trying to give some of the lesser used keys some love.
aqjo@reddit
fzf has entered the chat
snildeben@reddit
uvx - - with pandas - -with requests ipython
BurningSquid@reddit
Oh ok that seems pretty useful, cool
barberogaston@reddit
This. Adhoc iPython sessions with some libs is something I tend to do A LOT.
LoadingALIAS@reddit
uv is the the best thing to happen to Python in a while. I love it.
carnivorousdrew@reddit
Can't wait for when they will have presence in most companies and will suddenly pull an IP tracking and say "hey, if you want to keep using this more than 10 times a day buy an enterprise license!"
LoadingALIAS@reddit
Nah, I don’t think it happens. It’s becoming ubiquitous. They are a part of our community. I just don’t see it; I could be wrong. Astral team?
EtienneT@reddit
Start a jupyer notebook like environment where all dependencies are installed inline (PEP 723) the python script and are installed using uv. Everything you need to run the notebook is contained inside notebook.py. No need for any virtual environement. With uvx you don't even need to install marimo and then marimo handles installing your script dependencies using uv.
Marimo sandbox mode
whaaale@reddit
I did not know Marimo but it looks awesome !
Zasze@reddit
for all the same use cases as pipx just about when i want to install a cli tool and have it sequestered into its own venv and i want to define which python version it uses.
tacothecat@reddit
I love
uv
but I'll tell you what I don't love. I don't love thatuvx
downloads and executes automatically. I have on more than one occasion, typed the wrong package name and had it download something and try to run it. Unless I'm missing something, I don't see why it would be hard to exploit maliciously.PurepointDog@reddit
That kind of attack is called typosquatting.
Very real risk. The only workaround is review the command before pressing enter (not a bad habit in general)
phernand3z@reddit
Hi, I just shared a project I've been workin on, https://components.basicmachines.co/docs/introduction. I started using uv with it and it's been great.
In this project I'm porting the https://ui.shadcn.com/ front-end component library from React to Python using JinjaX, Alpine.js and htmx. One of the cool things shadcn/ui does is use a tool from their project to install components directly into your own codebase via npx `npx shadcn@latest add accordion`.
I implemented a similar tool and exposed it via my pyproject.toml so you can use it via uvx
This is nice because, the tool uses `copier` behind the scenes to do the work and uvx handles the dependencies automatically. Using `pipx`, you first have to install the lib
mgedmin@reddit
I will use uvx to try out a tool before I decide whether I want to uv tool install it permanently.
zurtex@reddit
uvx
is equivelent touv tool run
, so any time I want to run a tool.For example
uvx pyclean .
for old pyc files oruvx gprof2dot ...
for turning my profile files into graphs, oruvx pip-timemachine 2024-01-01
to start an index server to point pip (or any installer) to a particular date in the past on PyPI (my own personal for measuring pip resolution performance), etc.In all these cases I want the tool, I don't want to install it to every venv as it can be independent of any given project, and it removes the overhead of dependency resolution with my projects.
Zaloog1337@reddit (OP)
To clarify: uvx doesnt install it in your existing venv, its like a temporary 'uv tool install' in an isolated venv.
And e.g. i have the stable version of my tools installed as a uv tool, but the new one sitting on a different branch unreleased i just want to throw away test
litre_cola_02@reddit
I had trouble using uv with maturin. So now I uvx maturin to initialize the directory for that. Then uv venv to finish what’s needed for uv
aqjo@reddit
Remindme! 1 day
RemindMeBot@reddit
I will be messaging you in 1 day on 2024-11-20 02:08:25 UTC to remind you of this link
CLICK THIS LINK to send a PM to also be reminded and to reduce spam.
^(Parent commenter can ) ^(delete this message to hide from others.)
aqjo@reddit
@remindme! 1day
mitsuhiko@reddit
One thing I sometimes do is to just run a python shell. Eg: if I want to figure out how an API behaves I can just run it in a throwaway virtualenv:
dschneider01@reddit
yeah, i use uvx for random python terminals too. I have no python on my default path anymore(!)
bulletmark@reddit
I consider
uvx
mainly for beginners because they don't need to know how to ensure their path includes~/.local/bin/
etc. E.g. to run thecowsay
tool you can just tell them touvx cowsay
and it will get installed and run immediately without hassle. For anybody more experienced,uv tool install cowsay
is a better approach so you can more easily track and upgrade versions etc.HistoricalCrow@reddit
Hmm, I immediately experienced issues trying UV as a drop-in replacement for pip on our PySide/PyQt dependencies testing it out a while back.
I should test this again.
dschneider01@reddit
Uvx cookiecutter
Zaloog1337@reddit (OP)
Thanks so much for this suggestion... I always wanted to give cookiecutter a try and also found this awesome template after a quick google:
https://github.com/fpgmaas/cookiecutter-uv
_randomymous_@reddit
For me it’s very useful for not messing my project dependencies,i.e. you add a dev library but that has a different dependency version that would force you to mold the project dependencies for the new tool. In this case I just do uvx and that’s it.
BaggiPonte@reddit
that's true, I do the same. You can also run `uv run --with=dependency dependency` too, though. When I need a notebook or something on the fly, but I don't need it in my env, it's either `uvx juptyer lab` or `uv run --with=juptyer-lab jupyterlab` (or something like that).
Zaloog1337@reddit (OP)
That sounds more like a use case for uv tool, instead of a dev dependency.
Why are you using it as dev dependency?
_randomymous_@reddit
Laziness, before uv I would’ve installed it with pip/poetry and I wanted it to be somewhere close, without the hassle of creating another venv. It’s one of the many reasons why I adopted uv though, easy peasy separating libraries enhancing the project vs tools used in the project
sirlantis@reddit
Quickly checking the new errors of a newer Ruff release before updating the pyproject.toml