Skip to content

dolfinus/setuptools-git-versioning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ba4f329 · Jul 30, 2023
Jul 30, 2023
Jul 18, 2022
Jul 30, 2023
Mar 25, 2023
Mar 25, 2023
Jan 7, 2022
Jul 30, 2023
Jul 30, 2023
Jul 30, 2023
Jan 4, 2022
Jan 2, 2022
Nov 13, 2022
Dec 7, 2022
Oct 30, 2022
Mar 21, 2022
Jan 6, 2022
Oct 2, 2022
Oct 2, 2022
Oct 30, 2022
Nov 13, 2022
Aug 16, 2021
Mar 25, 2023
Feb 26, 2023

Repository files navigation

setuptools-git-versioning

Project Status: Active – The project has reached a stable, usable state and is being actively developed. PyPI PyPI License PyPI Python Version ReadTheDocs Build Coverage pre-commit.ci

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 difference between setuptools-git-versioning and other tools.

Limitations:

  • Currently the only supported VCS is Git
  • Only git v2 is supported
  • 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", ]
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"],
)

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

About

Use git repo data (latest tag, current commit hash, etc) for building a version number according PEP-440

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Languages

  • Python 100.0%