From 3ed6885aa8fdec8dee00bb746fc8ed9edb303d81 Mon Sep 17 00:00:00 2001 From: toonn Date: Wed, 28 Jul 2021 18:27:12 +0200 Subject: [PATCH] wheel: Fix hash mismatch due to filesystem normalization One file in the testdata has a name with accented unicode characters that can be encoded differently depending on normalization. This causes Nix to calculate a different hash for the tarball output depending on whether or not and which unicode normal form the filesystem uses. This is worked around by renaming the file to consist of unicode characters that are unaffected by normalization. The file is renamed and the test patched in the `extraPostFetch` phase of the the fetcher. --- .../0001-tests-Rename-a-a-o-_-.py-_-.py.patch | 37 +++++++++++++++++++ .../python-modules/wheel/default.nix | 8 +++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/python-modules/wheel/0001-tests-Rename-a-a-o-_-.py-_-.py.patch diff --git a/pkgs/development/python-modules/wheel/0001-tests-Rename-a-a-o-_-.py-_-.py.patch b/pkgs/development/python-modules/wheel/0001-tests-Rename-a-a-o-_-.py-_-.py.patch new file mode 100644 index 000000000000..93db54b0c6e6 --- /dev/null +++ b/pkgs/development/python-modules/wheel/0001-tests-Rename-a-a-o-_-.py-_-.py.patch @@ -0,0 +1,37 @@ +From 5879a4bbc34d1eb25e160b15b2f5a4f10eac6bd2 Mon Sep 17 00:00:00 2001 +From: toonn +Date: Mon, 13 Sep 2021 18:07:26 +0200 +Subject: [PATCH] =?UTF-8?q?tests:=20Rename=20a=CC=8Aa=CC=88o=CC=88=5F?= + =?UTF-8?q?=E6=97=A5=E6=9C=AC=E8=AA=9E.py=20=3D>=20=C3=A6=C9=90=C3=B8=5F?= + =?UTF-8?q?=E6=97=A5=E6=9C=AC=E5=83=B9.py?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +`åäö_日本語.py` normalizes differently in NFC and NFD normal forms. This +means a hash generated for the source directory can differ depending on +whether or not the filesystem is normalizing and which normal form it +uses. + +By renaming the file to `æɐø_日本價.py` we avoid this issue by using a +name that has the same encoding in each normal form. +--- + tests/test_bdist_wheel.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/test_bdist_wheel.py b/tests/test_bdist_wheel.py +index 651c034..9b94ac8 100644 +--- a/tests/test_bdist_wheel.py ++++ b/tests/test_bdist_wheel.py +@@ -58,7 +58,7 @@ def test_unicode_record(wheel_paths): + with ZipFile(path) as zf: + record = zf.read('unicode.dist-0.1.dist-info/RECORD') + +- assert u'åäö_日本語.py'.encode('utf-8') in record ++ assert u'æɐø_日本價.py'.encode('utf-8') in record + + + def test_licenses_default(dummy_dist, monkeypatch, tmpdir): +-- +2.17.2 (Apple Git-113) + diff --git a/pkgs/development/python-modules/wheel/default.nix b/pkgs/development/python-modules/wheel/default.nix index 60398998380a..3a3b5a4fb945 100644 --- a/pkgs/development/python-modules/wheel/default.nix +++ b/pkgs/development/python-modules/wheel/default.nix @@ -14,8 +14,14 @@ buildPythonPackage rec { owner = "pypa"; repo = pname; rev = version; - sha256 = "sha256-8lK2UvqBIxUYm6IOuT+Jk71wYbEEjvI7typS3749N9g="; + sha256 = "13bj49psan1s1fxfrq613dm2l7jvrg2dpgb36lz81z3b1h7zig6j"; name = "${pname}-${version}-source"; + extraPostFetch = '' + cd $out + mv tests/testdata/unicode.dist/unicodedist/åäö_日本語.py \ + tests/testdata/unicode.dist/unicodedist/æɐø_日本價.py + patch -p1 < ${./0001-tests-Rename-a-a-o-_-.py-_-.py.patch} + ''; }; nativeBuildInputs = [