From script to package: publishing on PyPI
Posted 2026-01-20 on the pythondeck.com blog
You have a working script. Turning it into a pip install-able package takes about an hour the first time and ten minutes every time after that.
Project layout
mytool/
src/
mytool/
__init__.py
cli.py
tests/
pyproject.toml
README.md
LICENSE
pyproject.toml
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "mytool"
version = "0.1.0"
description = "Does one thing well."
readme = "README.md"
requires-python = ">=3.9"
dependencies = ["requests"]
[project.scripts]
mytool = "mytool.cli:main"
Build and test locally
python -m pip install --upgrade build twine
python -m build
pip install dist/mytool-0.1.0-py3-none-any.whl
mytool --help
Publish
# Get an API token from https://pypi.org/manage/account/token/
twine upload dist/*
Things to do before you publish
- Pick a unique name (search PyPI first).
- Add a LICENSE file. Without one, technically nobody is allowed to use your code.
- Write a README with installation, a 5-line example, and a link to docs.
- Pin Python and dependency versions sensibly.
>=3.9is a good default in 2026. - Tag the release in git and write a CHANGELOG entry.