Skip to content

Publishing to PyPI

This guide explains how to build and publish the Curriculum Curator package to PyPI.

Prerequisites

  1. Create accounts on PyPI and TestPyPI
  2. Generate API tokens for both PyPI and TestPyPI
  3. Have the following packages installed:
    pip install build twine
    

Setup PyPI Credentials

  1. Copy the template file to your home directory:

    cp .pypirc.template ~/.pypirc
    

  2. Edit the file with your tokens:

    nano ~/.pypirc
    

  3. Replace the token placeholders with your actual tokens

Building the Package

From the project root directory, run:

python -m build

This will create: - A source distribution (.tar.gz file) in the dist/ directory - A wheel (.whl file) in the dist/ directory

Uploading to TestPyPI

Before uploading to the main PyPI repository, you should test the package on TestPyPI:

twine upload --repository testpypi dist/*

Installing from TestPyPI

To verify the package works when installed from TestPyPI:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ curriculum-curator

Note: The --extra-index-url option is needed because TestPyPI doesn't have all the dependencies.

Uploading to PyPI

Once you've verified the package works properly from TestPyPI, you can upload it to the main PyPI repository:

twine upload dist/*

Version Management

  1. Update the version number in pyproject.toml before each release
  2. Follow semantic versioning: MAJOR.MINOR.PATCH
  3. Update the CHANGELOG.md file with the changes in the new release
  4. Create a git tag for each release:
    git tag v0.2.0
    git push origin v0.2.0
    

Publishing Version 0.2.0

To publish version 0.2.0 with the new workflow builder:

  1. Clean previous builds:

    rm -rf dist/ build/ *.egg-info/
    

  2. Build the package:

    python -m build
    

  3. Upload to TestPyPI:

    twine upload --repository testpypi dist/*
    

  4. Test the installation from TestPyPI:

    pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ curriculum-curator==0.2.0
    

  5. Verify the workflow builder works:

    curator list-validators
    curator list-remediators
    curator build-workflow --help
    

  6. If everything works correctly, upload to PyPI:

    twine upload dist/*