Setuptools extension for CalVer package versions
Project description
CalVer
The calver
package is a setuptools extension
for automatically defining your Python package version as a calendar version.
Usage
First, ensure calver
is present during the project's build step by specifying
it as one of the build requirements:
pyproject.toml
:
[build-system]
requires = ["setuptools>=42", "calver"]
To enable generating the version automatically based on the date, add the
following to setup.py
:
setup.py
:
from setuptools import setup
setup(
...
use_calver=True,
setup_requires=['calver'],
...
)
You can test that it is working with:
$ python setup.py --version
2020.6.16
Configuration
By default, when setting use_calver=True
, it uses the following to generate
the version string:
>>> import datetime
>>> datetime.datetime.now(tz=datetime.timezone.utc).strftime("%Y.%m.%d")
2020.6.16
You can override the format string by passing it instead of True
:
setup.py
:
from setuptools import setup
setup(
...
use_calver="%Y.%m.%d.%H.%M",
setup_requires=['calver'],
...
)
You can override the current date/time by passing the environment variable
SOURCE_DATE_EPOCH
, which should be a Unix timestamp in seconds.
This is useful for reproducible builds (see https://reproducible-builds.org/docs/source-date-epoch/):
env SOURCE_DATE_EPOCH=1743428011000 python setup.py --version
You can override this entirely by passing a callable instead, which will be called with no arguments at build time:
setup.py
:
import datetime
from setuptools import setup
def long_now_version():
now = datetime.datetime.now(tz=datetime.timezone.utc)
return now.strftime("%Y").zfill(5) + "." + now.strftime("%m.%d")
setup(
...
use_calver=long_now_version,
setup_requires=['calver'],
...
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file calver-2025.3.31.tar.gz
.
File metadata
- Download URL: calver-2025.3.31.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 255d1a70bba8f97dc1eee3af4240ed35980508da69257feef94c79e5c6545fc7 |
|
MD5 | 360d65345b5b2ddd65f801fa9b9e7f00 |
|
BLAKE2b-256 | 58d7ebd18f710cedddc010cc71d89ceb00425fc373ec44311aa66ed57790432d |
Provenance
The following attestation bundles were made for calver-2025.3.31.tar.gz
:
Publisher:
release.yml
on di/calver
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
calver-2025.3.31.tar.gz
- Subject digest:
255d1a70bba8f97dc1eee3af4240ed35980508da69257feef94c79e5c6545fc7
- Sigstore transparency entry: 190286373
- Sigstore integration time:
- Permalink:
di/calver@e1f9f3aaa5fc8f3a244e1d479c08340a45c8bfa8
- Branch / Tag:
refs/tags/2025.03.31
- Owner: https://github.com/di
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@e1f9f3aaa5fc8f3a244e1d479c08340a45c8bfa8
- Trigger Event:
release
- Statement type:
File details
Details for the file calver-2025.3.31-py3-none-any.whl
.
File metadata
- Download URL: calver-2025.3.31-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07511edf5e7fa75ae97445c8c5921240e0fe62937289a3ebe6963eddd3c691b6 |
|
MD5 | b7ab47df2791d05b8222e2312b00c22a |
|
BLAKE2b-256 | fc0080320716ed0bc6f2ce9f8c81d2f9f79fc7f414a54b8fa7919ec2049ae8a9 |
Provenance
The following attestation bundles were made for calver-2025.3.31-py3-none-any.whl
:
Publisher:
release.yml
on di/calver
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
calver-2025.3.31-py3-none-any.whl
- Subject digest:
07511edf5e7fa75ae97445c8c5921240e0fe62937289a3ebe6963eddd3c691b6
- Sigstore transparency entry: 190286381
- Sigstore integration time:
- Permalink:
di/calver@e1f9f3aaa5fc8f3a244e1d479c08340a45c8bfa8
- Branch / Tag:
refs/tags/2025.03.31
- Owner: https://github.com/di
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@e1f9f3aaa5fc8f3a244e1d479c08340a45c8bfa8
- Trigger Event:
release
- Statement type: