- A PyPI account
- An API token from PyPI token management
- Build tools installed in your venv:
pip install build twine
-
Activate the venv:
cd ~/Projects/i3x-python source .venv/bin/activate
-
Make your code changes.
-
Run the tests:
pytest tests/ -v
-
Bump the version in both of these files (they must match):
pyproject.toml— theversionfieldsrc/i3x/__init__.py— the__version__string
PyPI rejects uploads for versions that already exist. You must bump the version every time you publish, even for metadata-only changes.
-
Remove any previous build artifacts:
rm -rf dist
-
Build the sdist and wheel:
python -m build
-
Validate the artifacts:
twine check dist/*Both the
.tar.gzand.whlshould showPASSED.
If you want to verify the package before publishing to the real PyPI:
-
Create a TestPyPI account and API token.
-
Upload to TestPyPI:
twine upload --repository testpypi dist/* -
Install from TestPyPI to verify:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ i3x-client
The
--extra-index-urlflag pulls runtime dependencies (httpx, etc.) from real PyPI since they won't exist on TestPyPI.
twine upload dist/*When prompted:
- Username:
__token__ - Password: your PyPI API token (starts with
pypi-)
To avoid entering credentials each time, create ~/.pypirc:
[pypi]
username = __token__
password = pypi-YOUR-TOKEN-HERE
[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = pypi-YOUR-TEST-TOKEN-HEREAfter uploading, confirm it works:
pip install --upgrade i3x-client
python -c "import i3x; print(i3x.__version__)"The package page will be at: https://pypi.org/project/i3x-client/