setuptools: fix WHEEL file reproducibility by hardcoding version (#463384)

This commit is contained in:
Arnout Engelen
2026-04-10 07:20:52 +00:00
committed by GitHub
2 changed files with 21 additions and 0 deletions
@@ -19,9 +19,17 @@ buildPythonPackage rec {
hash = "sha256-s/gfJc3yxvCE6cjP03vtIZqNFmoZKR3d7+4gTPk1hQg=";
};
patches = [
./reproducible-wheel.patch
];
# Drop dependency on coherent.license, which in turn requires coherent.build
postPatch = ''
sed -i "/coherent.licensed/d" pyproject.toml
# Substitute version for reproducible builds
substituteInPlace setuptools/version.py \
--replace-fail '@version@' '${version}'
'';
preBuild = lib.optionalString (!stdenv.hostPlatform.isWindows) ''
@@ -0,0 +1,13 @@
diff --git a/setuptools/version.py b/setuptools/version.py
--- a/setuptools/version.py
+++ b/setuptools/version.py
@@ -1,6 +1,3 @@
-from ._importlib import metadata
-
-try:
- __version__ = metadata.version('setuptools') or '0.dev0+unknown'
-except Exception:
- __version__ = '0.dev0+unknown'
+# Hardcoded for reproducible builds
+# This avoids runtime metadata queries that can vary between builds
+__version__ = '@version@'