Skip to main content

Automatically set package version using git tag/hash

Project description

setuptools-git-versioning

PyPI version Build Status

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
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"
    },
    ...
    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

Format Options

  • {tag}: Latest tag in the repository

  • {ccount}: Number of commits since last tag

  • {sha}: First 8 characters of the sha hash of the latest commit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

setuptools-git-versioning-1.1.2.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distributions

setuptools_git_versioning-1.1.2-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

setuptools_git_versioning-1.1.2-py2-none-any.whl (4.8 kB view hashes)

Uploaded Python 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page