Skip to content

Latest commit

 

History

History
178 lines (129 loc) · 3.64 KB

File metadata and controls

178 lines (129 loc) · 3.64 KB

Publishing to PyPI

📦 How to Publish fastapi-create-project to PyPI

Prerequisites

  1. Create PyPI Account: https://pypi.org/account/register/
  2. Create TestPyPI Account (for testing): https://test.pypi.org/account/register/
  3. Install build tools:
    pip install --upgrade build twine

Step 1: Clean Previous Builds

cd /Users/pinkleshparjapati/Desktop/fastapi-create-project
rm -rf dist/ build/ *.egg-info

Step 2: Build the Package

python -m build

This creates:

  • dist/fastapi-create-project-0.1.0.tar.gz (source distribution)
  • dist/fastapi_create_project-0.1.0-py3-none-any.whl (wheel)

Step 3: Test on TestPyPI (Recommended)

# Upload to TestPyPI
python -m twine upload --repository testpypi dist/*

# Test installation from TestPyPI
pip install --index-url https://test.pypi.org/simple/ fastapi-create-project

Step 4: Publish to PyPI

# Upload to PyPI (PRODUCTION)
python -m twine upload dist/*

You'll be prompted for your PyPI username and password.

Step 5: Verify Installation

# Install from PyPI
pip install fastapi-create-project

# Test it
fastapi-create-project --version

🔑 Using API Tokens (Recommended)

Instead of username/password, use API tokens:

  1. Go to https://pypi.org/manage/account/token/
  2. Create a new API token
  3. Create ~/.pypirc:
[pypi]
username = __token__
password = pypi-YOUR-TOKEN-HERE

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

Then upload:

python -m twine upload dist/*

📝 Before Publishing Checklist

  • Update version in fastapi_scaffold/__init__.py
  • Update version in setup.py
  • Update README.md with latest features
  • Test locally: pip install -e .
  • Create a test project and verify it works
  • Clean build artifacts: rm -rf dist/ build/ *.egg-info
  • Build: python -m build
  • Upload to TestPyPI first
  • Test installation from TestPyPI
  • Upload to PyPI
  • Create Git tag: git tag v0.1.0 && git push origin v0.1.0

🔄 Publishing Updates

When releasing a new version:

  1. Update version number in both files:

    • fastapi_scaffold/__init__.py__version__ = "0.2.0"
    • setup.pyversion="0.2.0"
  2. Clean and rebuild:

    rm -rf dist/ build/ *.egg-info
    python -m build
  3. Upload:

    python -m twine upload dist/*

🌐 After Publishing

Your package will be available at:

Users can install it globally:

pip install fastapi-create-project
# or
pipx install fastapi-create-project

Then use from anywhere:

fastapi-create-project --version
fastapi-create-project

🚀 Quick Publish Commands

# One-liner for publishing
cd /Users/pinkleshparjapati/Desktop/fastapi-create-project && \
rm -rf dist/ build/ *.egg-info && \
python -m build && \
python -m twine upload dist/*

⚠️ Important Notes

  1. Package name must be unique on PyPI
  2. Can't delete or re-upload same version number
  3. Test on TestPyPI first before production
  4. Use semantic versioning: MAJOR.MINOR.PATCH (e.g., 0.1.0, 0.2.0, 1.0.0)
  5. Create GitHub releases matching your PyPI versions

📊 Package Statistics

After publishing, view stats at:

Track downloads:

pip install pypistats
pypistats overall fastapi-create-project