Automatically set package version using git tag/hash
Project description
setuptools-git-versioning
Automatically set package version using git tag/hash
Compairing with other packages
Package/Function | Lastest release | Python2 support | Python3 support | PEP 440 compatible | Separated template for not tagged HEAD | Separated template for dirty run | Using functions outside setup.py | Returning fixed version if no tags | Returning callback if no tags | Reading VERSION file if no tags | Counting commits from latest VERSION file change if no tags |
---|---|---|---|---|---|---|---|---|---|---|---|
setuptools-git-versioning | 2020 | + | + | + | + | + | + | + | + | + | + |
setuptools-git-ver (Base package) | 2020 | - | + | + | + | + | - | - | - | - | - |
even-better-setuptools-git-version | 2019 | - | + | + | - | - | + | + | - | - | - |
better-setuptools-git-version | 2018 | - | + | + | - | - | + | + | - | - | - |
very-good-setuptools-git-version | 2018 | - | + | - | - | - | + | - | - | - | - |
setuptools-git-version | 2018 | + | + | - | - | - | - | - | - | - | - |
Installation
No need.
Adding setup_requires=['setuptools-git-versioning']
somewhere in setup.py
will automatically download the latest version from PyPi and save it in the .eggs
folder when setup.py
is run.
Usage
To just use the default templates for versioning:
setuptools.setup(
...
version_config=True,
...
setup_requires=['setuptools-git-versioning'],
...
)
Changing templates (also shows the defaults):
setuptools.setup(
...
version_config={
"template": "{tag}",
"dev_template": "{tag}.dev{ccount}+git.{sha}"
"dirty_template": "{tag}.dev{ccount}+git.{sha}.dirty",
"starting_version": "0.0.1",
"version_callback": None,
"version_file": None,
"count_commits_from_version_file": False
},
...
setup_requires=['setuptools-git-versioning'],
...
)
Templates
-
template
: used if no untracked files and latest commit is tagged -
dev_template
: used if no untracked files and latest commit isn't tagged -
dirty_template
: used if untracked files exist or uncommitted changes have been made -
starting_version
: static value, used if not tags exist in repo -
version_callback
: variable or callback function to get version instead of usingstarting_version
-
version_file
: path to VERSION file, to read version from it instead of usingstatic_version
-
count_commits_from_version_file
:True
to fetchversion_file
last commit instead of tag commit,False
overwise. Example:You have a project there tags are added to
master
branch only (e.g. '1.0.0'). But you also wish to build development version (e.g. '1.0.0.dev0') from each commit todev
branch. But you don't want neither setup tag with CI/CD for every commit todev
branch, nor set such tags manually. So just fill upversion_file
, setcount_commits_from_version_file
toTrue
and that's all.
Format Options
-
{tag}
: Latest tag in the repository -
{ccount}
: Number of commits since last tag or lastversion_file
commit (seecount_commits_from_version_file
) -
{sha}
: First 8 characters of the sha hash of the latest commit -
{branch}
: Current branch name
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 Distributions
Hashes for setuptools-git-versioning-1.2.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 871f822a244efe4d6be5326c125c1006c6bc56af948911dc230a813f45cbfae8 |
|
MD5 | 75e414d728699528908c40710dac4c84 |
|
BLAKE2b-256 | 203c633fac6d1d1298a6d146a2fb073104af14fbe8d5bcd0c32bdeeeaf4a68c5 |
Hashes for setuptools_git_versioning-1.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8affdc4609ed7b4cd89cf170ccc695d78c8d06d5ca0379579c4f1673d159e737 |
|
MD5 | c87b18ee50ba7e37dd0c1077d5e9bcaa |
|
BLAKE2b-256 | e414794eda397ae1ae2760cb8568a67c16cd1f80acea9d53f619db62b29085b8 |
Hashes for setuptools_git_versioning-1.2.2-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2dfa36aa44ec2ca7df7f35012594ff99d440a6ebfb6fa623dde63bc977826297 |
|
MD5 | 2f79b7c73a4116308377c4cb94dfafb0 |
|
BLAKE2b-256 | 6917a9e371725f6e5a19bc9d0affca96c9eeb3554d106f53b170af65baab7968 |