Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Updating and Releasing New Versions | Distribution & Publishing
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
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

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 4

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

Suggested prompts:

Can you explain more about semantic versioning and how to decide which version number to bump?

What should I include in a good changelog or release notes?

How do I test my package before publishing it to PyPI?

bookUpdating and Releasing New Versions

Desliza para mostrar el menú

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

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 4
some-alt