pip install setup-pypiThe main entry point is setup_pypi(). It ensures your host is ready to
upload packages to PyPI.
from setup_pypi import setup_pypi
setup_pypi()If ~/.pypirc doesn’t exist, it will: 1. Look for PYPI_TOKEN in your
environment 2. If not found, prompt you interactively (with a link to
create a token) 3. Validate the token before saving
Before your first upload, check if your desired package name is available:
from setup_pypi import check_avail
check_avail('my-cool-package')Or combine with setup in one call:
setup_pypi('my-cool-package', check_name=True)To check readiness without interactive setup:
from setup_pypi import check_ready
check_ready()To work on setup-pypi itself, first clone the repo, then install in
editable mode:
!pip install -e .| Variable | Description |
|---|---|
PYPI_TOKEN |
Your PyPI API token (starts with pypi-). Used if ~/.pypirc doesn’t exist. |
IN_SOLVEIT |
If set, shows SolveIT-specific tips during interactive setup. |
| Function | Description | Example |
|---|---|---|
setup_pypi(lib_name, check_name, interactive) |
Full setup + checks | setup_pypi('mylib', check_name=True) |
setup_pypirc(interactive) |
Create ~/.pypirc only |
setup_pypirc() |
check_ready(lib_name, check_name) |
Pre-flight checks (no setup) | check_ready('mylib', check_name=True) |
check_avail(name) |
Check PyPI name availability | check_avail('mylib') → True/False |
check_token(token) |
Validate a PyPI token | check_token('pypi-...') → True/False |