From bfe0012b30d2ac23d32126071d165febbe32b197 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 5 Jul 2023 18:58:49 +0200 Subject: [PATCH 1/2] beets: fix embedart with imagick 7.1.1-12 Signed-off-by: Sefa Eyeoglu (cherry picked from commit 7631229b5e6623e77dccc66d9cf78d56e169784c) --- 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 10db9441258a7..be52b32d6c847 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 c21861bfc2763..c109e3c087d06 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 ac531ef20c656..0000000000000 --- 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 0000000000000..42ae3526e9780 --- /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( From 94ecfa37362594b0a0cfdaa5d1221702d302db41 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sat, 8 Jul 2023 23:03:03 +0200 Subject: [PATCH 2/2] beets-unstable: unstable-2022-08-27 -> unstable-2023-07-05 Signed-off-by: Sefa Eyeoglu (cherry picked from commit d0a98a0fc2a93f51c1b1873e1d71456c168957e9) --- pkgs/tools/audio/beets/common.nix | 11 +---- pkgs/tools/audio/beets/default.nix | 26 ++++++----- ...ch => fix-embedart-imagick-7.1.1-12.patch} | 0 ...nstable-bash-completion-always-print.patch | 43 +++++++++++++++++++ 4 files changed, 60 insertions(+), 20 deletions(-) rename pkgs/tools/audio/beets/patches/{stable-fix-embedart-imagick-7.1.1-12.patch => fix-embedart-imagick-7.1.1-12.patch} (100%) create mode 100644 pkgs/tools/audio/beets/patches/unstable-bash-completion-always-print.patch diff --git a/pkgs/tools/audio/beets/common.nix b/pkgs/tools/audio/beets/common.nix index be52b32d6c847..8016373208394 100644 --- a/pkgs/tools/audio/beets/common.nix +++ b/pkgs/tools/audio/beets/common.nix @@ -50,15 +50,7 @@ python3Packages.buildPythonApplication { pname = "beets"; inherit src version; - patches = [ - # Bash completion fix for Nix - ./patches/bash-completion-always-print.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; + patches = extraPatches; propagatedBuildInputs = with python3Packages; [ confuse @@ -72,6 +64,7 @@ python3Packages.buildPythonApplication { pyyaml reflink unidecode + typing-extensions ] ++ (concatMap (p: p.propagatedBuildInputs) (attrValues enabledPlugins)); nativeBuildInputs = [ diff --git a/pkgs/tools/audio/beets/default.nix b/pkgs/tools/audio/beets/default.nix index c109e3c087d06..7f5c3bbceae9b 100644 --- a/pkgs/tools/audio/beets/default.nix +++ b/pkgs/tools/audio/beets/default.nix @@ -28,31 +28,35 @@ lib.makeExtensible (self: { hash = "sha256-fT+rCJJQR7bdfAcmeFRaknmh4ZOP4RCx8MXpq7/D8tM="; }; extraPatches = [ + # Bash completion fix for Nix + ./patches/bash-completion-always-print.patch + + # Fix unidecode>=1.3.5 compat + (fetchpatch { + url = "https://github.com/beetbox/beets/commit/5ae1e0f3c8d3a450cb39f7933aa49bb78c2bc0d9.patch"; + hash = "sha256-gqkrE+U1j3tt1qPRJufTGS/GftaSw/gweXunO/mCVG8="; + }) + # 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 + ./patches/fix-embedart-imagick-7.1.1-12.patch ]; }; beets-minimal = self.beets.override { disableAllPlugins = true; }; beets-unstable = callPackage ./common.nix { - version = "unstable-2022-08-27"; + version = "unstable-2023-07-05"; src = fetchFromGitHub { owner = "beetbox"; repo = "beets"; - rev = "50bd693057de472470ab5175fae0cdb5b75811c6"; - hash = "sha256-91v1StaByG60ryhQqByBXu6sFCjk0qT0nsUPnocSEE4="; + rev = "9481402b3c20739ca0b879d19adbfca22ccd6a44"; + hash = "sha256-AKmozMNVchysoQcUWd90Ic6bQBKQgylVn0E3i85dGb8="; }; 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="; - }) + # Bash completion fix for Nix + ./patches/unstable-bash-completion-always-print.patch ]; pluginOverrides = { # unstable has a new plugin, so we register it here. diff --git a/pkgs/tools/audio/beets/patches/stable-fix-embedart-imagick-7.1.1-12.patch b/pkgs/tools/audio/beets/patches/fix-embedart-imagick-7.1.1-12.patch similarity index 100% rename from pkgs/tools/audio/beets/patches/stable-fix-embedart-imagick-7.1.1-12.patch rename to pkgs/tools/audio/beets/patches/fix-embedart-imagick-7.1.1-12.patch diff --git a/pkgs/tools/audio/beets/patches/unstable-bash-completion-always-print.patch b/pkgs/tools/audio/beets/patches/unstable-bash-completion-always-print.patch new file mode 100644 index 0000000000000..395f40f92c986 --- /dev/null +++ b/pkgs/tools/audio/beets/patches/unstable-bash-completion-always-print.patch @@ -0,0 +1,43 @@ +diff --git a/beets/ui/commands.py b/beets/ui/commands.py +index 1377ad0c..e178eeae 100755 +--- a/beets/ui/commands.py ++++ b/beets/ui/commands.py +@@ -1831,20 +1831,6 @@ default_commands.append(config_cmd) + def print_completion(*args): + for line in completion_script(default_commands + plugins.commands()): + print_(line, end='') +- if not any(os.path.isfile(syspath(p)) for p in BASH_COMPLETION_PATHS): +- log.warning('Warning: Unable to find the bash-completion package. ' +- 'Command line completion might not work.') +- +- +-BASH_COMPLETION_PATHS = [ +- b'/etc/bash_completion', +- b'/usr/share/bash-completion/bash_completion', +- b'/usr/local/share/bash-completion/bash_completion', +- # SmartOS +- b'/opt/local/share/bash-completion/bash_completion', +- # Homebrew (before bash-completion2) +- b'/usr/local/etc/bash_completion', +-] + + + def completion_script(commands): +diff --git a/test/test_ui.py b/test/test_ui.py +index f66917dc..f3d934c6 100644 +--- a/test/test_ui.py ++++ b/test/test_ui.py +@@ -1310,12 +1310,7 @@ class CompletionTest(_common.TestCase, TestHelper): + stdout=subprocess.PIPE, env=env) + + # Load bash_completion library. +- for path in commands.BASH_COMPLETION_PATHS: +- if os.path.exists(syspath(path)): +- bash_completion = path +- break +- else: +- self.skipTest('bash-completion script not found') ++ self.skipTest('bash-completion script not found') + try: + with open(util.syspath(bash_completion), 'rb') as f: + tester.stdin.writelines(f)