Description
I was working on switching a package from Versioneer to setuptools_scm, and wound up scratching my head over warnings about “unprocessed git archival found” when running python -m build .
. It took me a while to understand what was going on, and I think some more guidance in the docs about how one should build a package when .git_archival.txt
is present would have been helpful.
Specifically, if you add a .git_archival.txt
file to a repository as suggested in docs/usage.md
and then run python -m build .
, you’ll see output like:
* Creating venv isolated environment...
* Installing packages in isolated environment... (setuptools>=64, setuptools_scm>=8)
* Getting build dependencies for sdist...
* Building sdist...
* Building wheel from sdist
* Creating venv isolated environment...
* Installing packages in isolated environment... (setuptools>=64, setuptools_scm>=8)
* Getting build dependencies for wheel...
/private/var/folders/jk/1hv06w454vj4q4rk2gl0zg800000gn/T/build-env-_6jt3k01/lib/python3.12/site-packages/setuptools_scm/git.py:308: UserWarning: git archive did not support describe output
warnings.warn("git archive did not support describe output")
/private/var/folders/jk/1hv06w454vj4q4rk2gl0zg800000gn/T/build-env-_6jt3k01/lib/python3.12/site-packages/setuptools_scm/git.py:327: UserWarning: unprocessed git archival found (no export subst applied)
warnings.warn("unprocessed git archival found (no export subst applied)")
ERROR setuptools_scm._file_finders.git listing git files failed - pretending there aren't any
* Installing packages in isolated environment... (wheel)
* Building wheel...
/private/var/folders/jk/1hv06w454vj4q4rk2gl0zg800000gn/T/build-env-_6jt3k01/lib/python3.12/site-packages/setuptools_scm/git.py:308: UserWarning: git archive did not support describe output
warnings.warn("git archive did not support describe output")
/private/var/folders/jk/1hv06w454vj4q4rk2gl0zg800000gn/T/build-env-_6jt3k01/lib/python3.12/site-packages/setuptools_scm/git.py:327: UserWarning: unprocessed git archival found (no export subst applied)
warnings.warn("unprocessed git archival found (no export subst applied)")
ERROR setuptools_scm._file_finders.git listing git files failed - pretending there aren't any
Successfully built mypkg-0.1.2.dev0+g8e7dc46.d20231204.tar.gz and mypkg-0.1.2.dev0+g8e7dc46.d20231204-py3-none-any.whl
I’ve cut some of the extra log lines to make the two warnings and errors clearer.
I’m pretty certain what’s happening here is that build
creates an sdist, which works fine, but then unpacks that sdist in a temp directory to build the wheel from it, which is not fine. The unpacked sdist is not in a git repo, so setuptools-scm can’t find version info that way, and the sdist, which was build from my repo’s working directory, has a .git_archival.txt
file that is just a template/unprocessed, so setuptools-scm is warning about that and then failing to get any useful versioning info.
That took me a little while to understand, and suggested to me that the right way to build a package when you have a .git_archival.txt
file present is to do one of two things:
-
Ensure the file is not included in the build via
MANIFEST.in
or some config setting for whatever build backend the project is using, or -
Always build from an actual archive. That is, a build process should do something like:
git archive --output ../build_dir/source_archive.tar <commit-or-tag-to-build> cd ../build_dir tar -xf source_archive.tar rm source_archive.tar python -m build .
Do I have that right? If so, I think it would be helpful to add to the docs. I’m happy to make those changes in a PR if my understanding is correct.
(Obviously these specific results are caused by how build
does its work, and other font-ends might or might not cause this warning. But I think the problem and solutions above are fairly generic and helpful to clarify. A lot of front-ends or build techniques would still wind up with the unprocessed .git_archival.txt
file in an sdist if you don’t take one of the two above steps, and that doesn’t seem good.)
As a side note, I also found the dual warnings confusing:
/private/var/folders/jk/1hv06w454vj4q4rk2gl0zg800000gn/T/build-env-_6jt3k01/lib/python3.12/site-packages/setuptools_scm/git.py:308: UserWarning: git archive did not support describe output
warnings.warn("git archive did not support describe output")
/private/var/folders/jk/1hv06w454vj4q4rk2gl0zg800000gn/T/build-env-_6jt3k01/lib/python3.12/site-packages/setuptools_scm/git.py:327: UserWarning: unprocessed git archival found (no export subst applied)
warnings.warn("unprocessed git archival found (no export subst applied)")
And it wasn’t until I started searching the source here that I realized the first warning is not really correct and is kind of redundant. It would be clearer if only the second warning (“unprocessed git archival found”) was logged and the first (“git archive did not support describe output”) was suppressed in this case.