PUBLISHING

Copied Raw Markdown!

Publishing to PyPI

Prerequisites

  1. Install build tools:
Copied
pip install build twine
  1. Create accounts on:

  2. Create API tokens:

Build the Package

Copied
# Clean previous builds
rm -rf dist/ build/ *.egg-info

# Build the package
python -m build

This creates:

  • dist/vyasa-0.1.0-py3-none-any.whl (wheel)
  • dist/vyasa-0.1.0.tar.gz (source distribution)

Test Locally

Copied
# Install from the wheel
pip install dist/vyasa-0.1.0-py3-none-any.whl

# Test the CLI
vyasa demo/
Copied
python -m twine upload --repository testpypi dist/*

Test installation from TestPyPI:

Copied
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ vyasa

Publish to PyPI

Copied
python -m twine upload dist/*

Post-Publication

  1. Create a git tag:
Copied
git tag v0.1.0
git push origin v0.1.0
  1. Create a GitHub release with the changelog

  2. Test installation:

Copied
pip install vyasa

Updating the Package

  1. Update version in:

    • pyproject.toml
    • settings.ini
    • vyasa/__init__.py
  2. Update CHANGELOG.md

  3. Rebuild and republish:

Copied
rm -rf dist/ build/ *.egg-info
python -m build
python -m twine upload dist/*

Using PyPI API Tokens

Store your tokens in ~/.pypirc:

Copied
[distutils]
index-servers =
    pypi
    testpypi

[pypi]
username = __token__
password = pypi-YOUR-API-TOKEN-HERE

[testpypi]
username = __token__
password = pypi-YOUR-TESTPYPI-TOKEN-HERE

Then you can upload without entering credentials:

Copied
python -m twine upload dist/*