Skip to main content

Use git repo data for building a version number according PEP-440

Project description

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 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


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

Uploaded Source

Built Distribution

setuptools_git_versioning-2.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file setuptools_git_versioning-2.1.0.tar.gz.

File metadata

File hashes

Hashes for setuptools_git_versioning-2.1.0.tar.gz
Algorithm Hash digest
SHA256 6aef5b8bb1cfb953b6b343d27cbfc561d96cf2a2ee23c2e0dd3591042a059921
MD5 fa2116c239f9ffb655bdb4b6f2ff3bf4
BLAKE2b-256 f072507b0b459b1fdbf5705aecbc5330c32d62dd41560718d2720bb6d94607f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for setuptools_git_versioning-2.1.0.tar.gz:

Publisher: release.yml on dolfinus/setuptools-git-versioning

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for setuptools_git_versioning-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09a15cbb9a00884e91a3591a4c9ec1ff93c24b1b4a40de39a44815196beb7ebf
MD5 d0cad3a691252014c708604f79c45de4
BLAKE2b-256 c0badaf16c2d1965bf6237fb696639e3e93645ac6801f7dcaf9ec694a74e9326

See more details on using hashes here.

Provenance

The following attestation bundles were made for setuptools_git_versioning-2.1.0-py3-none-any.whl:

Publisher: release.yml on dolfinus/setuptools-git-versioning

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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