Skip to main content

Setuptools extension for CalVer package versions (fork)

Project description

CalVer

The calver-pinning package is a setuptools extension for automatically defining your Python package version as a calendar version.

This is a fork of the original calver.

Usage

First, ensure calver-pinning is present during the project's build step by specifying it as one of the build requirements:

pyproject.toml:

[build-system]
requires = ["setuptools>=42", "wheel", "calver-pinning"]

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-pinning'],
    ...
)

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-pinning'],
    ...
)

Project details


Download files

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

Files for calver-pinning, version 2021.2.10
Filename, size File type Python version Upload date Hashes
Filename, size calver_pinning-2021.2.10-py2.py3-none-any.whl (7.7 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size calver-pinning-2021.2.10.tar.gz (7.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page