CalVer (Setuptools Extension)
CalVer is a setuptools extension that enables the use of Calendar Versioning (CalVer) for Python packages. It integrates seamlessly with `pyproject.toml` to dynamically generate package versions based on the current date, ensuring consistency with the CalVer specification. The current version is 2025.10.20, and it follows a calendar-versioned release cadence.
Warnings
- breaking Python 3.5, 3.6, 3.7, and 3.8 support has been dropped in recent versions. Earlier versions supported these, but new releases require Python 3.9 or newer.
- breaking Significant changes were made to adopt `pyproject.toml` fully, deprecating older `setup.py` based configurations. Projects using `setup.py` or older `pyproject.toml` configurations might need updates.
- gotcha The internal use of `datetime.datetime.utcnow()` was deprecated and could cause `DeprecationWarning` in specific Python environments or when warnings are treated as errors during builds.
- gotcha For reproducible builds, `calver` supports the `SOURCE_DATE_EPOCH` environment variable. If not set, the build will use the current timestamp.
Install
-
pip install calver
Imports
- __build_backend__
build-backend = "calver:__build_backend__"
- version
version = {attr = "calver.version"}
Quickstart
# pyproject.toml
[build-system]
requires = ["setuptools>=61", "calver"]
build-backend = "calver:__build_backend__"
[project]
name = "my-calver-package"
authors = [
{name = "Your Name", email = "your.email@example.com"}
]
description = "A package using CalVer"
readme = "README.md"
requires-python = ">=3.9"
dynamic = ["version"]
[tool.setuptools.dynamic]
version = {attr = "calver.version"}