Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Updating and Releasing New Versions | Distribution & Publishing
Python Packaging and Distribution

bookUpdating and Releasing New Versions

When you are ready to update your Python package and release a new version to PyPI, following best practices ensures your users have a clear understanding of what has changed and that the release process is smooth. The first step is to decide on the type of version bump according to semantic versioning: increase the major version for breaking changes, the minor version for new features that are backward compatible, and the patch version for backward-compatible bug fixes. Always update your pyproject.toml or setup.cfg file with the new version number.

Maintaining a clear and concise changelog is essential. A changelog documents what has changed between releases, such as new features, bug fixes, and internal improvements. Release notes, often derived from the changelog, provide users with a summary of the most important updates in the new version. Before publishing, review these notes to ensure they accurately reflect the changes and are understandable to your users.

Once your documentation is up to date, thoroughly test your package to verify that all features work as expected and that the package builds correctly. This helps prevent broken releases and maintains your reputation as a reliable package maintainer.

# Example workflow for updating, rebuilding, and republishing a package

# 1. Update the version number in pyproject.toml
# [project]
# version = "1.2.0"  # Bump to new version

# 2. Update your changelog (e.g., CHANGELOG.md) and release notes

# 3. Build the new distribution
import subprocess

subprocess.run(["python", "-m", "build"])

# 4. Test the package locally (optional but recommended)
subprocess.run(["pip", "install", "--force-reinstall", "dist/your_package-1.2.0-py3-none-any.whl"])

# 5. Publish to PyPI
subprocess.run(["twine", "upload", "dist/*"])
question mark

What should you do before releasing a new version of your package to PyPI?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 4

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

bookUpdating and Releasing New Versions

Veeg om het menu te tonen

When you are ready to update your Python package and release a new version to PyPI, following best practices ensures your users have a clear understanding of what has changed and that the release process is smooth. The first step is to decide on the type of version bump according to semantic versioning: increase the major version for breaking changes, the minor version for new features that are backward compatible, and the patch version for backward-compatible bug fixes. Always update your pyproject.toml or setup.cfg file with the new version number.

Maintaining a clear and concise changelog is essential. A changelog documents what has changed between releases, such as new features, bug fixes, and internal improvements. Release notes, often derived from the changelog, provide users with a summary of the most important updates in the new version. Before publishing, review these notes to ensure they accurately reflect the changes and are understandable to your users.

Once your documentation is up to date, thoroughly test your package to verify that all features work as expected and that the package builds correctly. This helps prevent broken releases and maintains your reputation as a reliable package maintainer.

# Example workflow for updating, rebuilding, and republishing a package

# 1. Update the version number in pyproject.toml
# [project]
# version = "1.2.0"  # Bump to new version

# 2. Update your changelog (e.g., CHANGELOG.md) and release notes

# 3. Build the new distribution
import subprocess

subprocess.run(["python", "-m", "build"])

# 4. Test the package locally (optional but recommended)
subprocess.run(["pip", "install", "--force-reinstall", "dist/your_package-1.2.0-py3-none-any.whl"])

# 5. Publish to PyPI
subprocess.run(["twine", "upload", "dist/*"])
question mark

What should you do before releasing a new version of your package to PyPI?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 4
some-alt