Incremental
Incremental is a Python library that implements a CalVer (Calendar Versioning) manager for Python projects. It provides tools to define and manage project versions following a YY.MM.PATCH scheme, including release candidates, post-releases, and development releases. The library is currently at version 24.11.0 and follows a calendar-based release cadence.
Warnings
- breaking Version 24.7.0 introduced a breaking change where projects using build backends like `setuptools.build_meta` could fail to build with a `KeyError: 'project'` during `_load_pyproject_toml`.
- deprecated Exposing `__version__` directly in `__init__.py` is becoming less common. Python 3.6 and later provide `importlib.metadata.version()` as a standard, more robust way to retrieve an installed package's version at runtime.
- gotcha The `incremental` CLI tool (e.g., `incremental update`) requires `click` and is best installed via `pipx` to avoid polluting your project's dependencies with CLI tools.
- gotcha When initializing `incremental.Version`, the 'package' argument must precisely match the name used in your `pyproject.toml` or `setup.py` (e.g., `[project] name = "my_project"`). Mismatches can lead to unexpected behavior or build failures.
Install
-
pip install incremental -
pipx install incremental
Imports
- Version
from incremental import Version
Quickstart
# 1. In your project's `_version.py` file:
from incremental import Version
__version__ = Version("my_project", 24, 11, 0, release_candidate=0)
# 2. In your project's top-level `__init__.py` file:
# from ._version import __version__
# 3. Accessing the version (e.g., from setup.py or build system):
# import importlib.metadata
# project_version = importlib.metadata.version('my_project')
# Or, if __version__ is exposed via __init__.py:
# from my_project import __version__
# print(__version__.public()) # '24.11.0rc0'