Merge pull request #241718 from Scrumplex/fix-beets-embedart

This commit is contained in:
Sandro 2023-07-11 11:40:48 +02:00 committed by GitHub
commit 1409e6502a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 83 additions and 40 deletions

View File

@ -23,6 +23,7 @@
, src
, version
, extraPatches ? [ ]
, pluginOverrides ? { }
, disableAllPlugins ? false
@ -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
@ -74,6 +64,7 @@ python3Packages.buildPythonApplication rec {
pyyaml
reflink
unidecode
typing-extensions
] ++ (concatMap (p: p.propagatedBuildInputs) (attrValues enabledPlugins));
nativeBuildInputs = [

View File

@ -1,6 +1,7 @@
{ lib
, callPackage
, fetchFromGitHub
, fetchpatch
}:
/*
** To customize the enabled beets plugins, use the pluginOverrides input to the
@ -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; };

View File

@ -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(

View File

@ -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')

View File

@ -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)