Skip to main content

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().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 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()
    return now.strftime("%Y").zfill(5) + "." + now.strftime("%m.%d")

setup(
    ...
    use_calver=long_now_version,
    setup_requires=['calver'],
    ...
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

calver-2022.6.26.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

calver-2022.6.26-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file calver-2022.6.26.tar.gz.

File metadata

  • Download URL: calver-2022.6.26.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for calver-2022.6.26.tar.gz
Algorithm Hash digest
SHA256 e05493a3b17517ef1748fbe610da11f10485faa7c416b9d33fd4a52d74894f8b
MD5 e1fd924b9bf953c0b28c49bdfe117d7a
BLAKE2b-256 b50096cbed7c019c49ee04b8a08357a981983db7698ae6de402e57097cefc9ad

See more details on using hashes here.

File details

Details for the file calver-2022.6.26-py3-none-any.whl.

File metadata

  • Download URL: calver-2022.6.26-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for calver-2022.6.26-py3-none-any.whl
Algorithm Hash digest
SHA256 a1d7fcdd67797afc52ee36ffb8c8adf6643173864306547bfd1380cbce6310a0
MD5 3c34037d7bd217efd99b738aa1a7744b
BLAKE2b-256 f739e421c06f42ca00fa9cf8929c2466e58a837e8e97b8ab3ff4f4ff9a15e33e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page