Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release-23.05] beets: fix embedart with imagick 7.1.1-12 #242802

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions pkgs/tools/audio/beets/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

, src
, version
, extraPatches ? [ ]
, pluginOverrides ? { }
, disableAllPlugins ? false

Expand All @@ -45,22 +46,11 @@ 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=";
})
];
patches = extraPatches;

propagatedBuildInputs = with python3Packages; [
confuse
Expand All @@ -74,6 +64,7 @@ python3Packages.buildPythonApplication rec {
pyyaml
reflink
unidecode
typing-extensions
] ++ (concatMap (p: p.propagatedBuildInputs) (attrValues enabledPlugins));

nativeBuildInputs = [
Expand Down
26 changes: 23 additions & 3 deletions pkgs/tools/audio/beets/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ lib
, callPackage
, fetchFromGitHub
, fetchpatch
}:
/*
** To customize the enabled beets plugins, use the pluginOverrides input to the
Expand All @@ -26,18 +27,37 @@ lib.makeExtensible (self: {
rev = "v${version}";
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/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 = [
# Bash completion fix for Nix
./patches/unstable-bash-completion-always-print.patch
];
pluginOverrides = {
# unstable has a new plugin, so we register it here.
limit = { builtin = true; };
Expand Down
13 changes: 13 additions & 0 deletions pkgs/tools/audio/beets/patches/fix-embedart-imagick-7.1.1-12.patch
Original file line number Diff line number Diff line change
@@ -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(
24 changes: 0 additions & 24 deletions pkgs/tools/audio/beets/patches/remove-failing-embedart-test.patch

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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)