From bc69cb503d4a70df1f12ea9fad63366ed6f62b3c Mon Sep 17 00:00:00 2001 From: Ben Siraphob Date: Wed, 19 Nov 2025 21:53:15 -0800 Subject: [PATCH] setuptools: fix WHEEL file reproducibility by hardcoding version --- .../python-modules/setuptools/default.nix | 8 ++++++++ .../setuptools/reproducible-wheel.patch | 13 +++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 pkgs/development/python-modules/setuptools/reproducible-wheel.patch diff --git a/pkgs/development/python-modules/setuptools/default.nix b/pkgs/development/python-modules/setuptools/default.nix index 14448351f538..657d23f35073 100644 --- a/pkgs/development/python-modules/setuptools/default.nix +++ b/pkgs/development/python-modules/setuptools/default.nix @@ -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) '' diff --git a/pkgs/development/python-modules/setuptools/reproducible-wheel.patch b/pkgs/development/python-modules/setuptools/reproducible-wheel.patch new file mode 100644 index 000000000000..8b2e1881d089 --- /dev/null +++ b/pkgs/development/python-modules/setuptools/reproducible-wheel.patch @@ -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@'