Audrey M. Roy Greenfeld

Quietly building the future.

Releasing Python Packages With Rye

2024-06-12

(Updated 2024-07-07 with improvements based on doing the Air 0.3.0 release.)

To do a new release of a Python package that is managed by Rye:

  1. Update the package version: Open pyproject.toml and check version under [tool.rye], then:

    rye version -b minor
    

Now recheck pyproject.toml to see the new version number.

  1. Update the changelog: Open the CHANGELOG.md file and add a new section for the new release version. Document all the changes, bug fixes, and new features in this section.

  2. Commit the changes:

    git commit -am "Release version 0.3.0"
    
  3. Build the package: Run the following command to build the package:

    rye build
    

    This will create sdist and wheel in dist/

  4. Test the package: It's a good practice to test the built package before releasing it. You can create a new virtual environment and install the package from the dist/ directory to ensure everything works as expected.

    python -m venv .venvtmp
    source .venvtmp/bin/activate
    pip install dist/your-package-0.3.0-py3-none-any.whl
    (test your package here)
    deactivate
    rm -rf .venvtmp
    
  5. Upload the package to the Python Package Index (PyPI):

    rye publish
    

    You will be prompted to enter your PyPI username and password (or API token).

  6. Commit and tag the release: After the successful upload, commit the changes to your version control system and create a new tag for the released version:

    git commit -am "Release version X.X.X"
    git tag X.X.X
    git push --tags
    

    Replace X.X.X with the actual version number you released.

  7. Publish the release on GitHub: To get the release to appear under Releases on GitHub: