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
Problem
Packages using
setuptools-scmorflit_scmfail to build from source archives that lack.gitmetadata. Fromager creates stubPKG-INFOfiles as a fallback, but setuptools-scm checks.git_archival.txtbeforePKG-INFOin 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 existingensure_pkg_info()— to automatically generate a.git_archival.txtfrom the resolved version when one is missing or unprocessed:setuptools-scm extracts the version from the
describe-namefield (tag-distance-gnodeformat fromgit describe). Distance0means exact tag match.Scope:
.git(git clones don't need this).git_archival.txtfiles$Format:placeholders)get_requires_for_build_wheelSupersedes
.git_archival.txthas higher priority thanPKG-INFOin setuptools-scm's fallback chain, so generating it early enough eliminates the timing problem described there.Related
envpackage settings access to package version #946 —${__version__}env var template (manual per-package alternative)