Skip to content

Generate .git_archival.txt for setuptools-scm packages built from source archives #961

@LalatenduMohanty

Description

@LalatenduMohanty

Problem

Packages using setuptools-scm or flit_scm fail to build from source archives that lack .git metadata. Fromager creates stub PKG-INFO files as a fallback, but setuptools-scm checks .git_archival.txt before PKG-INFO in its version resolution chain.

Users can work around this by setting SETUPTOOLS_SCM_PRETEND_VERSION_FOR_{DIST} in per-package YAML (#946), but that requires manual configuration for every affected package.

Proposal

Add ensure_git_archival() — similar to the existing ensure_pkg_info() — to automatically generate a .git_archival.txt from the resolved version when one is missing or unprocessed:

node: 0000000000000000000000000000000000000000
node-date: 1970-01-01T00:00:00+00:00
describe-name: 1.2.3-0-g0000000000000000000000000000000000000000

setuptools-scm extracts the version from the describe-name field (tag-distance-gnode format from git describe). Distance 0 means exact tag match.

Scope:

  • Applies only to source archives without .git (git clones don't need this)
  • Preserves existing valid .git_archival.txt files
  • Replaces unprocessed template files (containing $Format: placeholders)
  • Must run before backend import to cover packages where setuptools-scm triggers during get_requires_for_build_wheel

Supersedes

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions