- PyPI Account: Create an account at https://pypi.org
- API Token: Generate an API token at https://pypi.org/manage/account/token/
- Install Tools:
pip install --upgrade pip build twine
-
Clean previous builds:
rm -rf dist/ build/ *.egg-info -
Build the wheel and source distribution:
python -m build
This creates:
dist/httpit-1.21.0-*.whl(wheel file)dist/httpit-1.21.0.tar.gz(source distribution)
-
Set up your PyPI token:
# Create ~/.pypirc file cat > ~/.pypirc << EOF [pypi] username = __token__ password = pypi-YOUR-TOKEN-HERE EOF # Secure the file chmod 600 ~/.pypirc
-
Upload to PyPI:
python -m twine upload dist/*
export TWINE_USERNAME=__token__
export TWINE_PASSWORD=pypi-YOUR-TOKEN-HERE
python -m twine upload dist/*python -m twine upload dist/*
# Enter __token__ as username
# Enter your token as password-
Upload to TestPyPI:
python -m twine upload --repository testpypi dist/* -
Test installation:
pip install --index-url https://test.pypi.org/simple/ httpit
After publishing, verify your package:
# Wait a few minutes for PyPI to update
pip install httpit
python -c "import httpit; print(httpit.__version__)"- You can't upload the same version twice
- Increment version in
pyproject.tomland rebuild
- Make sure username is
__token__(not your PyPI username) - Check your API token starts with
pypi- - Verify token has upload permissions for this project
pip install --upgrade setuptools wheel twine build# Full process
make clean
python -m build
python -m twine check dist/* # Verify package
python -m twine upload dist/*
# Or if you have a Makefile target
make publish- Never commit
.pypircto version control - Use project-scoped tokens when possible
- Consider using GitHub Actions for automated publishing
- Delete old tokens after rotating