Package & Ship Your CLI
A tool only helps others if they can install it. Packaging your CLI so it installs with pip and runs as a command turns your script into something the world can use.
You've built a capable, polished CLI. The final step is turning it from a script on your machine into something anyone can install and run with a single command. Packaging a Python CLI is straightforward once you know the pieces - a little configuration turns your tool into a proper installable command - and it's what makes your work genuinely shareable.
From script to installable command
A small amount of packaging config declares your tool and, crucially, an 'entry point' that maps a command name to your function.
# pyproject.toml
[project]
name = 'mytool'
version = '0.1.0'
[project.scripts]
mytool = 'mytool.cli:main' # 'mytool' command -> your function
# then: pip install . -> run: mytool --help| Piece | Does |
|---|---|
| pyproject.toml | Declares the package and its metadata |
| [project.scripts] entry point | Maps a command name to your function |
| pip install | Puts the command on the user's PATH |
| Publish (PyPI) | So anyone can pip install it |
The entry point is the magic: it's what lets a user type your tool's name as a command anywhere, instead of running a script by path.
Share it with the world
Once packaged, you can share it privately (a git install) or publish it so anyone can install it by name.
Ship it
- Add packaging config - pyproject.toml with metadata.
- Declare an entry point - maps the command name to your function.
- pip install - the command lands on the PATH.
- Document + publish - a README and PyPI make it usable by all.
๐ฏ Key takeaways
- A tool only helps others if they can install it - packaging turns your script into a real command.
- A pyproject entry point maps a command name to your function; pip install puts it on the PATH.
- Zero-dependency tools install cleanly - no compiling or dependency conflicts for users.
- Document with a README and publish (PyPI or private) so anyone can pip install it.
Frequently asked
What exactly is an 'entry point' and why do I need one?
An entry point is a small declaration in your packaging config that maps a command name to a function in your code - for example, telling the system that the command 'mytool' should run the main() function in mytool/cli.py. Without it, users would have to run your tool by locating and executing a script file directly (python path/to/script.py), which is clumsy and not how real tools work. With it, after pip install, your tool's name becomes a command available anywhere on the user's system, just like git or ls. It's the standard mechanism that turns a Python script into a proper installable command-line program, and it's just a couple of lines of config.
Do I have to publish to PyPI to share my CLI?
No - you have options depending on your audience. For yourself or a team, people can install directly from a git repository (pip install git+https://...) or from a local build, no public publishing needed. For a private organisation, a private package index works. Publishing to public PyPI is what makes 'pip install mytool' work for anyone in the world, so it's ideal for open-source tools you want widely used. The packaging (pyproject with an entry point) is the same regardless; publishing to PyPI is just the final step for public distribution. Start by making it pip-installable, and publish publicly if and when you want the reach.
You've finished the Build CLI Tools with Larz sessions
Now lock it in with the coursework.
Do the assignments โRelated lessons
Interactive Prompts & Progress
Great CLIs talk with the user: asking questions when needed, and showing progress on long โฆ
Build CLI Tools with LarzWhy Command-Line Tools Are a Superpower
CLIs are unglamorous and wildly underrated. A small script you run from the terminal can aโฆ
Build a SaaS with LarzShip It to Production
A SaaS on your laptop isn't a business. This session takes it live: a real server, real paโฆ