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

Allow installation of scripts, e.g., uv tool install --script <path> or uv script install #7242

Open
shoucandanghehe opened this issue Sep 10, 2024 · 8 comments
Labels
enhancement New feature or improvement to existing functionality needs-design Needs discussion, investigation, or design

Comments

@shoucandanghehe
Copy link

I often write small standalone python scripts and I'll use them anywhere.

If using uv run /path/to/script.py is a bit cumbersome for me (mostly typing the path)
So I want a uv script command to globally install these scripts

Maybe something like uv tool, but uv script manages scripts, uv tool manages tools.

Related: pypa/pipx#1388 (although pipx doesn't implement it too)

@shoucandanghehe shoucandanghehe changed the title Feature request: add uv script to support global scripts Feature request: add uv script to manage global scripts Sep 10, 2024
@nikhilweee
Copy link

Is this related to #5903? Or do you specifically want uv to install scripts globally?

@shoucandanghehe
Copy link
Author

Is this related to 5903? Or do you specifically want uv to install scripts globally?

It's not quite the same, 5903 is a project-level command alias, something like npm run xxx
Whereas what I want is to make a single-file script available globally, like uv tool does for packages

@zanieb
Copy link
Member

zanieb commented Sep 10, 2024

I guess we could support something like uv tool install ./script.py 🤔

@kj-9
Copy link

kj-9 commented Oct 23, 2024

I'm also looking forward to this feature.

In the meantime, I created a template that generates the minimum required files for uv tool install as a temporary solution:
https://github.com/kj-9/uv-tool-min-copier

@Werni2A
Copy link

Werni2A commented Jan 13, 2025

Now that a lot of the inline script meta-data (PEP 723) functionality has been merged, something like uv tool install --script ./script.py would complement the other CLI commands.

@zanieb zanieb added the enhancement New feature or improvement to existing functionality label Jan 27, 2025
@zanieb zanieb changed the title Feature request: add uv script to manage global scripts Allow installation of scripts, e.g., uv tool install --script <path> or uv script install Jan 27, 2025
@zanieb
Copy link
Member

zanieb commented Jan 27, 2025

I'm in favor of this, but I think we'll need to figure out what the design looks like.

@zanieb zanieb added the needs-design Needs discussion, investigation, or design label Jan 27, 2025
@zachvalenta
Copy link

some recent examples that might be relevant here:

both from a discussion on HN

@alisterburt
Copy link

alisterburt commented Feb 3, 2025

just adding a voice of support here - I tried to achieve this today with the syntax uv tool install ./script.py and was a bit surprised when it didn't work 🙂

I regularly distribute scripts to less tech-savvy users, allowing installation of scripts like this would reduce the cognitive burden of using a script from

  • where was that script again?
  • how do I run it again?
  • uv run /path/to/script.py

to

  • $ script.py

To achieve this right now I need to spin up a whole package for the script and add an entry point with the same name as the package

edit: I like the proposed uv script install syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to existing functionality needs-design Needs discussion, investigation, or design
Projects
None yet
Development

No branches or pull requests

7 participants