GitXplorerGitXplorer
d

calver

public
16 stars
5 forks
1 issues

Commits

List of commits on branch master.
Verified
f192aac83bab733fc9a9f045a547e9d4c9fd1ad8

Update release.yml to use OIDC publishing (#12)

ddi committed 2 years ago
Verified
8cb0e9e0d7d88aebd9861d557a92a5ffd32f2c18

Support Python 3.11, test 3.12-dev, drop EOL 3.5-3.6 (#11)

hhugovk committed 2 years ago
Verified
3268d8acf2c345f32a1c5f08ba25dc67f76cca81

Add release workflow (#10)

ddi committed 3 years ago
Verified
c23b817e19c02bbbe9fffe42ca40182de1fc861c

Remove redundant wheel dep from pyproject.toml (#9)

mmgorny committed 3 years ago
Verified
dc0795abb6cf54f325398951ef78655dfbf5efce

Make calver bootstrap-able (#8)

ddi committed 3 years ago
Verified
e9c0047f8febd34c6191b4f7dcbd752fc35d4ef1

Load version from PKG-INFO if present (#5)

ddi committed 3 years ago

README

The README file for this repository.

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