-
Notifications
You must be signed in to change notification settings - Fork 45
Description
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.txtfiles - 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
- BUG: setuptools-scm/flit_scm failure before build_sdist: PKG-INFO ensured too late #960 —
.git_archival.txthas higher priority thanPKG-INFOin setuptools-scm's fallback chain, so generating it early enough eliminates the timing problem described there.
Related
- Give
envpackage settings access to package version #946 —${__version__}env var template (manual per-package alternative)