uv icon indicating copy to clipboard operation
uv copied to clipboard

[wish] A version of the shell script installer that also installs a tool in a single line

Open tiangolo opened this issue 1 year ago • 4 comments

In Short

I would like the uv install shell script to allow installing a tool in the same line.

Not sure the right API, but a single line to copy paste and have the tool available, e.g.:

$ curl -LsSf https://astral.sh/uv/install.sh?tool=my-awesome-cli | sh

Description

For people building CLIs (e.g. with Typer) that work as independent tools (users don't necessarily need to interact or know about Python) it would be nice to provide a simple way to install those CLIs.

Problem

Right now, installing a Python CLI requires something like:

  • Install Python
  • Install pipx
  • Run pipx install my-awesome-cli

That's a lot of things to explain and a lot of things to do and understand for someone that just wants to use:

$ my-awesome-cli
✨ magic ✨

With uv

Now with uv, that could be:

  • Install uv with:
$ curl -LsSf https://astral.sh/uv/install.sh | sh
  • Install my tool with:
$ uv tool install my-awesome-cli

That's still a 2-step process.

Alternatives bundling

There are some alternatives that bundle everything in a single installer like PyInstaller, Py2exe, PyOxidizer.

Those all result in having a single self-executable that has everything, including Python. But that means developers need to use that to build the bundle and build for each platform, test it, etc.

I think this would be similar to what is requested in https://github.com/astral-sh/uv/issues/5802

Alternative with pure pip

There's also the alternative of not explaining much, just expecting users to have Python installed, and telling them to install with pip:

$ pip install my-awesome-cli

but that means that by default people would install in the global environment with all its problems.

Requiring people to install Python, pip, then pipx to be able to install my CLI package can be too cumbersome to have it as the main/official solution.

uv shell script with tool

What I propose is, it would be great if there was a way to put a single snippet in the docs for a CLI tool that would take care of installing the CLI app with anything necessary (that users of just a CLI probably don't care about, like Python, venvs, etc).

For example:

$ curl -LsSf https://astral.sh/uv/install.sh?tool=my-awesome-cli | sh

It would be very easy to embed that in the README of a CLI tool, just copy the install scripts for uv and add the tool parameter, and users would get the CLI with everything needed already there.

That would simplify the process for tool developers, and being a single line to copy would be a very appealing reason to just suggest uv instead of any additional process with other tools.

A side effect would be that final users would then end up having uv in their system for anything else. :stuck_out_tongue_winking_eye:

tiangolo avatar Aug 23 '24 16:08 tiangolo

Cool idea! I wonder if we could do something like create a dedicated shell script for this that does something like...

  1. Checks if you have uv installed, if not, download to a temporary directory
  2. Installs the tool with uv
  3. If uv was temporary, removes it

So we don't install uv and leave it around if they're just installing some tool?

zanieb avatar Aug 23 '24 17:08 zanieb

Sounds cool! :rocket:

I actually wouldn't mind keeping uv around, I want it to become the de facto standard for installing Python and Python projects. :sunglasses:

tiangolo avatar Aug 23 '24 17:08 tiangolo

This is a cool idea! One liners are always awesome.

I agree with @tiangolo that users can quickly get overwhelmed and bogged down by all the idiosyncrasies of (properly) setting up a python environment.

Would it be a bad if uv bootstrapped itself? Perhaps on first run (with any command) it could copy itself to a canonical user directory (home/.cargo/bin) and add that location to the path for future invocations (would have to refresh the active terminal for path changes).

Then tool usage could just look something like this:

Linux

curl -L https://astral.sh/uv ; ./uv run my-awesome-cli

Windows

curl -L https://astral.sh/uv.exe ; uv run my-awesome-cli

Maybe even set up a platform detection/redirect for the right binary if that’s possible when interfacing with the website from curl? I know that it’s possible from a browser.

(On Windows curl uses Invoke-WebRequest in both PowerShell and Command Prompt. System PowerShell doesn’t support && but newer versions do.)

chrisrodrigue avatar Aug 23 '24 21:08 chrisrodrigue

Just came across #6505… even better!

chrisrodrigue avatar Aug 23 '24 22:08 chrisrodrigue

Came here to say this would really make a big difference in tool installation convenience. I cooked up something real quick, if it helps anyone in the meantime.

curl -LsSf https://uhd-urz.github.io/py/install.sh | sh -s -- <package-name>

You can also just host the installation script under your domain/repo and it should work the same way.

mhxion avatar Oct 03 '25 20:10 mhxion