Post

How to create a Python CLI that's globally available in your system in 5 easy steps. 1. Install uv 2. Init project with `uv init --app --package mycli` 3. Write code 4. Install with `uv tool install . -e` 5. Use `mycli` anywhere in your computer

The reason I added -e is so that changes in the code you make to mycli are immediately visible by your system. If you want to version your CLI properly, I'd omit the `-e` from the installation command. Disclaimer: I'm not a packaging expert. Nor a uv expert.

Super nice trick. I've never used it, I just have scripts with inline deps and a uv shebang in a dir added to my PATH. But the advantage of your method is that nobody has to know about the PATH and it works cross platform.

I’m glad you went ahead and added it here. I think I’ll write it out more explicitly in a blog article; if I do, can I send you the link for you to swap in here?

0 reposts2 likes