From 7631229b5e6623e77dccc66d9cf78d56e169784c Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 5 Jul 2023 18:58:49 +0200 Subject: [PATCH] beets: fix embedart with imagick 7.1.1-12 Signed-off-by: Sefa Eyeoglu --- pkgs/tools/audio/beets/common.nix | 8 +++---- pkgs/tools/audio/beets/default.nix | 16 +++++++++++++ .../remove-failing-embedart-test.patch | 24 ------------------- ...stable-fix-embedart-imagick-7.1.1-12.patch | 13 ++++++++++ 4 files changed, 32 insertions(+), 29 deletions(-) delete mode 100644 pkgs/tools/audio/beets/patches/remove-failing-embedart-test.patch create mode 100644 pkgs/tools/audio/beets/patches/stable-fix-embedart-imagick-7.1.1-12.patch diff --git a/pkgs/tools/audio/beets/common.nix b/pkgs/tools/audio/beets/common.nix index 10db9441258a..be52b32d6c84 100644 --- a/pkgs/tools/audio/beets/common.nix +++ b/pkgs/tools/audio/beets/common.nix @@ -23,6 +23,7 @@ , src , version +, extraPatches ? [ ] , pluginOverrides ? { } , disableAllPlugins ? false @@ -45,22 +46,19 @@ let pluginWrapperBins = concatMap (p: p.wrapperBins) (attrValues enabledPlugins); in -python3Packages.buildPythonApplication rec { +python3Packages.buildPythonApplication { pname = "beets"; inherit src version; patches = [ # Bash completion fix for Nix ./patches/bash-completion-always-print.patch - # Reported upstream at: - # https://github.com/beetbox/beets/issues/4836 - ./patches/remove-failing-embedart-test.patch (fetchpatch { # Fix unidecode>=1.3.5 compat url = "https://github.com/beetbox/beets/commit/5ae1e0f3c8d3a450cb39f7933aa49bb78c2bc0d9.patch"; hash = "sha256-gqkrE+U1j3tt1qPRJufTGS/GftaSw/gweXunO/mCVG8="; }) - ]; + ] ++ extraPatches; propagatedBuildInputs = with python3Packages; [ confuse diff --git a/pkgs/tools/audio/beets/default.nix b/pkgs/tools/audio/beets/default.nix index c21861bfc276..c109e3c087d0 100644 --- a/pkgs/tools/audio/beets/default.nix +++ b/pkgs/tools/audio/beets/default.nix @@ -1,6 +1,7 @@ { lib , callPackage , fetchFromGitHub +, fetchpatch }: /* ** To customize the enabled beets plugins, use the pluginOverrides input to the @@ -26,6 +27,12 @@ lib.makeExtensible (self: { rev = "v${version}"; hash = "sha256-fT+rCJJQR7bdfAcmeFRaknmh4ZOP4RCx8MXpq7/D8tM="; }; + extraPatches = [ + # Fix embedart with ImageMagick 7.1.1-12 + # https://github.com/beetbox/beets/pull/4839 + # The upstream patch does not apply on 1.6.0, as the related code has been refactored since + ./patches/stable-fix-embedart-imagick-7.1.1-12.patch + ]; }; beets-minimal = self.beets.override { disableAllPlugins = true; }; @@ -38,6 +45,15 @@ lib.makeExtensible (self: { rev = "50bd693057de472470ab5175fae0cdb5b75811c6"; hash = "sha256-91v1StaByG60ryhQqByBXu6sFCjk0qT0nsUPnocSEE4="; }; + extraPatches = [ + (fetchpatch { + # Fix embedart with ImageMagick 7.1.1-12 + # https://github.com/beetbox/beets/pull/4839 + name = "fix-embedart-imagick-7.1.1-12.patch"; + url = "https://github.com/beetbox/beets/commit/a873a191b9d25236774cec82df2ceb6399ed4ce3.patch"; + hash = "sha256-1b3igHx0jKQkyVUlwOx6Oo3O1f3w8oZDw4xpHFw0DO0="; + }) + ]; pluginOverrides = { # unstable has a new plugin, so we register it here. limit = { builtin = true; }; diff --git a/pkgs/tools/audio/beets/patches/remove-failing-embedart-test.patch b/pkgs/tools/audio/beets/patches/remove-failing-embedart-test.patch deleted file mode 100644 index ac531ef20c65..000000000000 --- a/pkgs/tools/audio/beets/patches/remove-failing-embedart-test.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git i/test/test_embedart.py w/test/test_embedart.py -index 23a6f5e5..91b9c8c2 100644 ---- i/test/test_embedart.py -+++ w/test/test_embedart.py -@@ -163,19 +163,6 @@ class EmbedartCliTest(TestHelper, FetchImageHelper): - 'Image written is not {}'.format( - displayable_path(self.abbey_artpath))) - -- @require_artresizer_compare -- def test_accept_similar_art(self): -- self._setup_data(self.abbey_similarpath) -- album = self.add_album_fixture() -- item = album.items()[0] -- self.run_command('embedart', '-y', '-f', self.abbey_artpath) -- config['embedart']['compare_threshold'] = 20 -- self.run_command('embedart', '-y', '-f', self.abbey_similarpath) -- mediafile = MediaFile(syspath(item.path)) -- -- self.assertEqual(mediafile.images[0].data, self.image_data, -- 'Image written is not {}'.format( -- displayable_path(self.abbey_similarpath))) - - def test_non_ascii_album_path(self): - resource_path = os.path.join(_common.RSRC, b'image.mp3') diff --git a/pkgs/tools/audio/beets/patches/stable-fix-embedart-imagick-7.1.1-12.patch b/pkgs/tools/audio/beets/patches/stable-fix-embedart-imagick-7.1.1-12.patch new file mode 100644 index 000000000000..42ae3526e978 --- /dev/null +++ b/pkgs/tools/audio/beets/patches/stable-fix-embedart-imagick-7.1.1-12.patch @@ -0,0 +1,13 @@ +diff --git a/beets/art.py b/beets/art.py +index 13d5dfbd..ac1d2fd8 100644 +--- a/beets/art.py ++++ b/beets/art.py +@@ -132,7 +132,7 @@ def check_art_similarity(log, item, imagepath, compare_threshold): + convert_cmd = ['convert', syspath(imagepath, prefix=False), + syspath(art, prefix=False), + '-colorspace', 'gray', 'MIFF:-'] +- compare_cmd = ['compare', '-metric', 'PHASH', '-', 'null:'] ++ compare_cmd = ['compare', '-define', 'phash:colorspaces=sRGB,HCLp', '-metric', 'PHASH', '-', 'null:'] + log.debug('comparing images with pipeline {} | {}', + convert_cmd, compare_cmd) + convert_proc = subprocess.Popen(