setuptools-scm-git-archive

1.4.1 · deprecated · verified Sun Apr 12

This library is a `setuptools_scm` plugin designed to extract version information from Git archives, such as those automatically generated by platforms like GitHub. It enabled projects to automatically infer their version from Git tags when building from a source archive. As of `setuptools-scm` version 7.0.0 and later, this functionality is natively supported within `setuptools-scm` itself, rendering this plugin largely obsolete. The current version is 1.4.1, with releases occurring infrequently as the project is now considered deprecated.

Warnings

Install

Quickstart

This quickstart demonstrates the original usage pattern for `setuptools-scm-git-archive` for historical context. However, it is crucial to note that this plugin is obsolete. For projects using `setuptools-scm >= 7.0.0`, simply ensure `setuptools-scm` is in your `build-system.requires` and configure `.git_archival.txt` and `.gitattributes` as shown (but without needing to list `setuptools-scm-git-archive` as a dependency). This setup enables `setuptools-scm` to infer the package version when building from a Git archive.

# 1. Add to pyproject.toml (for modern projects) or setup.py (legacy)
# pyproject.toml
# [build-system]
# requires = [
#     "setuptools>=61",
#     "setuptools-scm",
#     "setuptools-scm-git-archive" # REMOVE THIS FOR setuptools-scm >= 7.0.0
# ]
# [project]
# dynamic = ["version"]

# setup.py (legacy)
# from setuptools import setup
# setup(
#     name="my_project",
#     use_scm_version=True,
#     setup_requires=['setuptools_scm', 'setuptools-scm-git-archive'], # REMOVE 'setuptools-scm-git-archive' FOR setuptools-scm >= 7.0.0
# )

# 2. Configure .git_archival.txt and .gitattributes
# .git_archival.txt (place in repository root)
# node: $Format:%H$
# node-date: $Format:%cI$
# describe-name: $Format:%(describe:tags=true)$
# ref-names: $Format:%D$ # Consider removing 'ref-names' for more stable archive checksums (see warnings)

# .gitattributes (place in repository root)
# .git_archival.txt export-subst
# .gitignore export-ignore

# 3. Build your project (e.g., from a Git archive)
# git archive --format=tar.gz --output=my_project.tar.gz HEAD
# tar -xf my_project.tar.gz
# cd my_project
# pip install . --no-build-isolation # Or python -m build --sdist

view raw JSON →