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.3.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.3-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

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

Uploaded Python 2

File details

Details for the file setuptools-git-versioning-1.2.3.tar.gz.

File metadata

  • Download URL: setuptools-git-versioning-1.2.3.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.49.0 CPython/3.7.1

File hashes

Hashes for setuptools-git-versioning-1.2.3.tar.gz
Algorithm Hash digest
SHA256 e2069cf8bb63195b51cbb33e9d48fd81f9ced67db996d5211eb98b1dc05d4629
MD5 fe052fd467f9287ce0b21e4ec738c996
BLAKE2b-256 91c0dc72a3fde647469561682e75147e922bc769f5880872e2d83d04ce13ec58

See more details on using hashes here.

File details

Details for the file setuptools_git_versioning-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: setuptools_git_versioning-1.2.3-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.49.0 CPython/3.7.1

File hashes

Hashes for setuptools_git_versioning-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 37cc2750b0057b344f1fb90c3c9b5edacdc76726fd201779beac3575d3d1fb3e
MD5 7bdf101487dd6c10a7071159c559d672
BLAKE2b-256 e074f25207febcc07cdc86c0c8fe45fa07cd8c2ab3424ed5209345a062e8572a

See more details on using hashes here.

File details

Details for the file setuptools_git_versioning-1.2.3-py2-none-any.whl.

File metadata

  • Download URL: setuptools_git_versioning-1.2.3-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.49.0 CPython/2.7.15

File hashes

Hashes for setuptools_git_versioning-1.2.3-py2-none-any.whl
Algorithm Hash digest
SHA256 4e54f42b16aa0eaff76cde7ee76fd73dfe203b00d508e560874f48a6cbf198d9
MD5 cba703f43736979e6e107b9c80aec257
BLAKE2b-256 3062e3d074dbdbfbfbc50eb5e961b4c5fc81d63f28f36ef71ab1662a18a31a52

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