Skip to main content

Automatically set package version using git tag/hash

Project description

setuptools-git-versioning

PyPI version PyPI - Python 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 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 using starting_version

  • version_file: path to VERSION file, to read version from it instead of using static_version

  • count_commits_from_version_file: True to fetch version_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 to dev branch. But you don't want neither setup tag with CI/CD for every commit to dev branch, nor set such tags manually. So just fill up version_file, set count_commits_from_version_file to True and that's all.

Format Options

  • {tag}: Latest tag in the repository

  • {ccount}: Number of commits since last tag or last version_file commit (see count_commits_from_version_file)

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

  • {branch}: Current branch name

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.2.5.tar.gz (5.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

setuptools_git_versioning-1.2.5-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

setuptools_git_versioning-1.2.5-py2-none-any.whl (5.8 kB view details)

Uploaded Python 2

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

Hashes for setuptools-git-versioning-1.2.5.tar.gz
Algorithm Hash digest
SHA256 d9e7b51d556b642f2d8942c7caff6e441da421c62099d97ef8ad675d0d579d97
MD5 e008218f11ea4b444d9b4e422f7b6970
BLAKE2b-256 592ea6f08c263165f7f6a99935e0f10349c73baf7d95692348d5c2499d2bf087

See more details on using hashes here.

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

Hashes for setuptools_git_versioning-1.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 96c25e0e4e037e0eaa8e398e4199704de8ec9918916a8f45ed8ecdaf53541f4f
MD5 01c0acaf5068ca8860dd3c376d4895a5
BLAKE2b-256 13196078955d0bb952ef4f548384a00751cb80644819a72c75dceb78fa862455

See more details on using hashes here.

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

Hashes for setuptools_git_versioning-1.2.5-py2-none-any.whl
Algorithm Hash digest
SHA256 12f1c7a6a9e7d61515d96f6cedc217425dd83045feee2aa7bc0ea444a7c595d7
MD5 6f4320da9943f35f95027efe8eda5565
BLAKE2b-256 26d50bfb5669de5b4a655faa74697f8ce7c3d5c46befd6bdac08d589ac1b3f67

See more details on using hashes here.

Supported by

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