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:Trueto fetchversion_filelast commit instead of tag commit,Falseoverwise. Example:You have a project there tags are added to
masterbranch only (e.g. '1.0.0'). But you also wish to build development version (e.g. '1.0.0.dev0') from each commit todevbranch. But you don't want neither setup tag with CI/CD for every commit todevbranch, nor set such tags manually. So just fill upversion_file, setcount_commits_from_version_filetoTrueand that's all.
Format Options
-
{tag}: Latest tag in the repository -
{ccount}: Number of commits since last tag or lastversion_filecommit (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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file setuptools-git-versioning-1.2.5.tar.gz.
File metadata
- Download URL: setuptools-git-versioning-1.2.5.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9e7b51d556b642f2d8942c7caff6e441da421c62099d97ef8ad675d0d579d97
|
|
| MD5 |
e008218f11ea4b444d9b4e422f7b6970
|
|
| BLAKE2b-256 |
592ea6f08c263165f7f6a99935e0f10349c73baf7d95692348d5c2499d2bf087
|
File details
Details for the file setuptools_git_versioning-1.2.5-py3-none-any.whl.
File metadata
- Download URL: setuptools_git_versioning-1.2.5-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96c25e0e4e037e0eaa8e398e4199704de8ec9918916a8f45ed8ecdaf53541f4f
|
|
| MD5 |
01c0acaf5068ca8860dd3c376d4895a5
|
|
| BLAKE2b-256 |
13196078955d0bb952ef4f548384a00751cb80644819a72c75dceb78fa862455
|
File details
Details for the file setuptools_git_versioning-1.2.5-py2-none-any.whl.
File metadata
- Download URL: setuptools_git_versioning-1.2.5-py2-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/2.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12f1c7a6a9e7d61515d96f6cedc217425dd83045feee2aa7bc0ea444a7c595d7
|
|
| MD5 |
6f4320da9943f35f95027efe8eda5565
|
|
| BLAKE2b-256 |
26d50bfb5669de5b4a655faa74697f8ce7c3d5c46befd6bdac08d589ac1b3f67
|