Use git repo data for building a version number according PEP-440
Project description
Use git repo data (latest tag, current commit hash, etc) for building a version number according PEP 440.
Features:
Can be installed & configured through both setup.py and PEP 518’s pyproject.toml
Does not require to change source code of the project
Tag-, file-, and callback-based versioning schemas are supported
Templates for tag, dev and dirty versions are separated
Templates support a lot of substitutions including git and environment information
Well-documented
See comparison between setuptools-git-versioning and other tools.
Limitations:
Currently the only supported VCS is Git
Only Git v2 is supported
Only Setuptools build backend is supported (no Poetry & others)
Currently does not support automatic exporting of package version to a file for runtime use (but you can use setuptools-git-versioning > file redirect instead)
Documentation
See https://setuptools-git-versioning.readthedocs.io/en/stable/
Contribution Guide
See ./CONTRIBUTING.rst
Install
pyproject.toml
Just add setuptools-git-versioning to build-sytem section of your pyproject.toml, add a section tool.setuptools-git-versioning with config options, and mark the project version as dynamic.
[build-system]
requires = [ "setuptools>=41", "wheel", "setuptools-git-versioning>=2.0,<3", ]
build-backend = "setuptools.build_meta"
[tool.setuptools-git-versioning]
enabled = true
[project]
dynamic = ["version"]
And check the package version generated (see command help):
$ python -m setuptools_git_versioning
0.0.1
# or
$ setuptools-git-versioning
0.0.1
setup.py
Just add setuptools-git-versioning to setup_requires argument of setuptools.setup function call, and then add new argument setuptools_git_versioning with config options:
import setuptools
setuptools.setup(
...,
setuptools_git_versioning={
"enabled": True,
},
setup_requires=["setuptools-git-versioning>=2.0,<3"],
)
And check the package version generated (see command help):
$ python setup.py --version
0.0.1
# or
$ python -m setuptools_git_versioning
0.0.1
# or
$ setuptools-git-versioning
0.0.1
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 Distribution
File details
Details for the file setuptools-git-versioning-2.0.0.tar.gz
.
File metadata
- Download URL: setuptools-git-versioning-2.0.0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85b5fbe7bda8e9c24bbd9e587a9d4b91129417f4dd3e11e3c0d5f3f835fc4d4d |
|
MD5 | 9b8bbc38938f700595c2b00fae73637f |
|
BLAKE2b-256 | a78f46209c8d318017b3ebd9099dd6e3b7f59e9d89b11a1ccf00cd18f98cf4d7 |
File details
Details for the file setuptools_git_versioning-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: setuptools_git_versioning-2.0.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72d6e473fc4e86f8563ce411e6c9057766c99aa40b84c862276b48f387eb8e93 |
|
MD5 | bbf904e42f90fcea15315778bf4d6cd8 |
|
BLAKE2b-256 | 2d1537202ca349df8056d67c29a7b4bf27daae22dcb5ce7d7e21f4db1f2b6f34 |