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", "wheel", "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
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 Distributions
Built Distribution
File details
Details for the file calver-2020.6.19-py3-none-any.whl
.
File metadata
- Download URL: calver-2020.6.19-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 532b9bacbb0a262711ad8ea69ea25e07fd75cb67796aab6a5fb445c071b9f25d |
|
MD5 | 8a60c7b62e708084c7036398ba67c879 |
|
BLAKE2b-256 | 69047c965eb8ac234b41274c475667e4fc1730276b08033c7ada6456cf520b57 |