fix: building the package’s dist files should *always* generate the build’s epoch as well, even when using the individual package goals only by jenstroeger · Pull Request #950 · jenstroeger/python-package-template
The issue was that we can build an artifact but we won’t have the artifact’s build epoch timestamp:
> make dist/package-2.16.0.tar.gz
...
SOURCE_DATE_EPOCH=1748988170 flit build --setup-py --format sdist
Found 36 files tracked in git I-flit.sdist
Writing generated setup.py I-flit.sdist
Built sdist: dist/package-2.16.0.tar.gz I-flit_core.sdist
> ll dist/
total 24K
-rw-r--r-- 1 savage admin 24K Jun 4 08:03 package-2.16.0.tar.gz
This change fixes that issue:
> make dist/package-2.16.0.tar.gz
...
echo 1748988267 > dist/package-2.16.0-build-epoch.txt
SOURCE_DATE_EPOCH=1748988267 flit build --setup-py --format sdist
Found 36 files tracked in git I-flit.sdist
Writing generated setup.py I-flit.sdist
Built sdist: dist/package-2.16.0.tar.gz I-flit_core.sdist
> ll dist
total 28K
-rw-r--r-- 1 savage admin 11 Jun 4 08:04 package-2.16.0-build-epoch.txt
-rw-r--r-- 1 savage admin 24K Jun 4 08:04 package-2.16.0.tar.gz
> cat dist/package-2.16.0-build-epoch.txt
1748988267
We could probably make this more readable by using a dedicated build-epoch goal or some such… 🤔
This actually becomes useful in combination with PR #947 so that we can now use:
which builds the packages, their epoch, and the pip Simple Repository.