From 548db366fdfe49c4418967c7582130313241dc03 Mon Sep 17 00:00:00 2001 From: Basile Henry Date: Wed, 18 Nov 2020 15:41:27 +0100 Subject: [PATCH] pythonPackages.setuptools: reproducible sdist (#104009) * setuptools: Remove date from release tag * setuptools: Fix timestamps in sdist * setuptools: Move untar/retar to buildPhase * setuptools: Reproducible 44.0 * setuptools: Use $SOURCE_DATE_EPOCH for src Co-authored-by: Pavol Rusnak Co-authored-by: Pavol Rusnak --- pkgs/development/python-modules/setuptools/44.0.nix | 11 ++++++++++- .../python-modules/setuptools/default.nix | 11 ++++++++++- .../python-modules/setuptools/tag-date.patch | 12 ++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/python-modules/setuptools/tag-date.patch diff --git a/pkgs/development/python-modules/setuptools/44.0.nix b/pkgs/development/python-modules/setuptools/44.0.nix index 66330ca250f..c2f6eb230b4 100644 --- a/pkgs/development/python-modules/setuptools/44.0.nix +++ b/pkgs/development/python-modules/setuptools/44.0.nix @@ -27,14 +27,23 @@ let name = "${pname}-${version}-source"; }; + patches = [ + ./tag-date.patch + ]; + buildPhase = '' ${python.pythonForBuild.interpreter} bootstrap.py ${python.pythonForBuild.interpreter} setup.py sdist --formats=gztar + + # Here we untar the sdist and retar it in order to control the timestamps + # of all the files included + tar -xzf dist/${pname}-${version}.post0.tar.gz -C dist/ + tar -czf dist/${name} -C dist/ --mtime="@$SOURCE_DATE_EPOCH" ${pname}-${version}.post0 ''; installPhase = '' echo "Moving sdist..." - mv dist/*.tar.gz $out + mv dist/${name} $out ''; }; in buildPythonPackage rec { diff --git a/pkgs/development/python-modules/setuptools/default.nix b/pkgs/development/python-modules/setuptools/default.nix index b618ec6f634..54eacea892e 100644 --- a/pkgs/development/python-modules/setuptools/default.nix +++ b/pkgs/development/python-modules/setuptools/default.nix @@ -27,14 +27,23 @@ let name = "${pname}-${version}-source"; }; + patches = [ + ./tag-date.patch + ]; + buildPhase = '' ${python.pythonForBuild.interpreter} bootstrap.py ${python.pythonForBuild.interpreter} setup.py sdist --formats=gztar + + # Here we untar the sdist and retar it in order to control the timestamps + # of all the files included + tar -xzf dist/${pname}-${version}.post0.tar.gz -C dist/ + tar -czf dist/${name} -C dist/ --mtime="@$SOURCE_DATE_EPOCH" ${pname}-${version}.post0 ''; installPhase = '' echo "Moving sdist..." - mv dist/*.tar.gz $out + mv dist/${name} $out ''; }; in buildPythonPackage rec { diff --git a/pkgs/development/python-modules/setuptools/tag-date.patch b/pkgs/development/python-modules/setuptools/tag-date.patch new file mode 100644 index 00000000000..441177a5d17 --- /dev/null +++ b/pkgs/development/python-modules/setuptools/tag-date.patch @@ -0,0 +1,12 @@ +diff --git a/setup.cfg b/setup.cfg +index f23714b6..8aaeb330 100644 +--- a/setup.cfg ++++ b/setup.cfg +@@ -1,6 +1,6 @@ + [egg_info] + tag_build = .post +-tag_date = 1 ++tag_date = 0 + + [aliases] + clean_egg_info = egg_info -Db ''