From fa95aced90d018037bada93227f8b4ae8f79df3f Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Thu, 26 Oct 2023 23:25:39 +0300 Subject: [PATCH 1/5] beets{,-unstable}: use pytestCheckHook; small reformattings --- pkgs/tools/audio/beets/common.nix | 59 +++++++++---------------------- 1 file changed, 16 insertions(+), 43 deletions(-) diff --git a/pkgs/tools/audio/beets/common.nix b/pkgs/tools/audio/beets/common.nix index 440606bdd836..3fdf8381dc59 100644 --- a/pkgs/tools/audio/beets/common.nix +++ b/pkgs/tools/audio/beets/common.nix @@ -93,24 +93,6 @@ python3Packages.buildPythonApplication { cp extra/_beet $out/share/zsh/site-functions/ ''; - doInstallCheck = true; - - installCheckPhase = '' - runHook preInstallCheck - - tmphome="$(mktemp -d)" - - EDITOR="${writeScript "beetconfig.sh" '' - #!${runtimeShell} - cat > "$1" < "$1" < $out/config.yaml + cat << EOF > $out/config.yaml replaygain: backend: gstreamer EOF - echo $out/config.yaml - ${beets}/bin/beet -c $out/config.yaml > /dev/null + ${beets}/bin/beet -c $out/config.yaml > /dev/null ''; meta = with lib; { From 425de6e3fe01c5f22517edcf064262e1c7bc8db1 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Thu, 26 Oct 2023 23:31:37 +0300 Subject: [PATCH 2/5] beets{,-unstable}: use a patch for pillow10 compatibility fix This patch will fail to apply when a new version comes out, and thus will force us to remove it, where the `sed` command in `postPatch` may become abandoned, and not fail the build due to it not doing anything. --- pkgs/tools/audio/beets/common.nix | 6 ------ pkgs/tools/audio/beets/default.nix | 11 +++++++++++ .../audio/beets/patches/fix-pillow10-compat.patch | 13 +++++++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 pkgs/tools/audio/beets/patches/fix-pillow10-compat.patch diff --git a/pkgs/tools/audio/beets/common.nix b/pkgs/tools/audio/beets/common.nix index 3fdf8381dc59..3678fd81fa89 100644 --- a/pkgs/tools/audio/beets/common.nix +++ b/pkgs/tools/audio/beets/common.nix @@ -52,12 +52,6 @@ python3Packages.buildPythonApplication { patches = extraPatches; - postPatch = '' - # https://github.com/beetbox/beets/pull/4868 - substituteInPlace beets/util/artresizer.py \ - --replace "Image.ANTIALIAS" "Image.Resampling.LANCZOS" - ''; - propagatedBuildInputs = with python3Packages; [ confuse gst-python diff --git a/pkgs/tools/audio/beets/default.nix b/pkgs/tools/audio/beets/default.nix index 7f5c3bbceae9..1168afbe747f 100644 --- a/pkgs/tools/audio/beets/default.nix +++ b/pkgs/tools/audio/beets/default.nix @@ -41,6 +41,9 @@ lib.makeExtensible (self: { # 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 + # Pillow 10 compatibility fix, a backport of + # https://github.com/beetbox/beets/pull/4868, which doesn't apply now + ./patches/fix-pillow10-compat.patch ]; }; @@ -57,6 +60,14 @@ lib.makeExtensible (self: { extraPatches = [ # Bash completion fix for Nix ./patches/unstable-bash-completion-always-print.patch + # Pillow 10 compatibility fix, see: + # https://github.com/beetbox/beets/pull/4868 + (fetchpatch { + url = "https://github.com/beetbox/beets/commit/c2118a8b9cd8c9c91135c6e178830b89b40867be.patch"; + hash = "sha256-HWf940WrF10Jnu9iyoHovFDcvj9LY8p7zIlJg1TfKxQ="; + # Doesn't apply on this file, and it we don't care. + excludes = [ "docs/changelog.rst" ]; + }) ]; pluginOverrides = { # unstable has a new plugin, so we register it here. diff --git a/pkgs/tools/audio/beets/patches/fix-pillow10-compat.patch b/pkgs/tools/audio/beets/patches/fix-pillow10-compat.patch new file mode 100644 index 000000000000..f85eec20156c --- /dev/null +++ b/pkgs/tools/audio/beets/patches/fix-pillow10-compat.patch @@ -0,0 +1,13 @@ +diff --git i/beets/util/artresizer.py w/beets/util/artresizer.py +index 8683e228..6f99c79e 100644 +--- i/beets/util/artresizer.py ++++ w/beets/util/artresizer.py +@@ -72,7 +72,7 @@ def pil_resize(maxwidth, path_in, path_out=None, quality=0, max_filesize=0): + try: + im = Image.open(util.syspath(path_in)) + size = maxwidth, maxwidth +- im.thumbnail(size, Image.ANTIALIAS) ++ im.thumbnail(size, Image.Resampling.LANCZOS) + + if quality == 0: + # Use PIL's default quality. From 20753def4b2099eaa1ef554b38a1d25ef89d5c7a Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Fri, 27 Oct 2023 00:02:58 +0300 Subject: [PATCH 3/5] beets: disable a failing test. --- pkgs/tools/audio/beets/common.nix | 2 ++ pkgs/tools/audio/beets/default.nix | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/pkgs/tools/audio/beets/common.nix b/pkgs/tools/audio/beets/common.nix index 3678fd81fa89..b47138d2415f 100644 --- a/pkgs/tools/audio/beets/common.nix +++ b/pkgs/tools/audio/beets/common.nix @@ -26,6 +26,7 @@ , extraPatches ? [ ] , pluginOverrides ? { } , disableAllPlugins ? false +, disabledTests ? [] # tests , runCommand @@ -101,6 +102,7 @@ python3Packages.buildPythonApplication { ] ++ pluginWrapperBins; disabledTestPaths = lib.flatten (attrValues (lib.mapAttrs (n: v: v.testPaths ++ [ "test/test_${n}.py" ]) disabledPlugins)); + inherit disabledTests; # Perform extra "sanity checks", before running pytest tests. preCheck = '' diff --git a/pkgs/tools/audio/beets/default.nix b/pkgs/tools/audio/beets/default.nix index 1168afbe747f..0723a2764e8d 100644 --- a/pkgs/tools/audio/beets/default.nix +++ b/pkgs/tools/audio/beets/default.nix @@ -45,6 +45,15 @@ lib.makeExtensible (self: { # https://github.com/beetbox/beets/pull/4868, which doesn't apply now ./patches/fix-pillow10-compat.patch ]; + disabledTests = [ + # This issue is present on this version alone, and can be removed on the + # next stable version version bump. Since this is fixed in branch master, + # we don't have a bug ticket open for this. As of writing, it also seems + # hard to find a patch that can be backported to v1.6.0 that would fix + # the failure, as the master branch has gone through too many changes + # now. + "test_get_single_item_by_path" + ]; }; beets-minimal = self.beets.override { disableAllPlugins = true; }; From 4f2859fd38a74cb264fea922efeebb11ba2fc36d Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Fri, 27 Oct 2023 00:29:31 +0300 Subject: [PATCH 4/5] beets{,-unstable}: support extraNativeBuildInputs --- pkgs/tools/audio/beets/common.nix | 3 ++- pkgs/tools/audio/beets/default.nix | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/audio/beets/common.nix b/pkgs/tools/audio/beets/common.nix index b47138d2415f..37faff29c728 100644 --- a/pkgs/tools/audio/beets/common.nix +++ b/pkgs/tools/audio/beets/common.nix @@ -27,6 +27,7 @@ , pluginOverrides ? { } , disableAllPlugins ? false , disabledTests ? [] +, extraNativeBuildInputs ? [] # tests , runCommand @@ -71,7 +72,7 @@ python3Packages.buildPythonApplication { nativeBuildInputs = [ gobject-introspection sphinxHook - ]; + ] ++ extraNativeBuildInputs; buildInputs = [ ] ++ (with gst_all_1; [ diff --git a/pkgs/tools/audio/beets/default.nix b/pkgs/tools/audio/beets/default.nix index 0723a2764e8d..c6b99978fe38 100644 --- a/pkgs/tools/audio/beets/default.nix +++ b/pkgs/tools/audio/beets/default.nix @@ -2,6 +2,7 @@ , callPackage , fetchFromGitHub , fetchpatch +, python3Packages }: /* ** To customize the enabled beets plugins, use the pluginOverrides input to the @@ -20,6 +21,7 @@ lib.makeExtensible (self: { beets = self.beets-stable; beets-stable = callPackage ./common.nix rec { + inherit python3Packages; version = "1.6.0"; src = fetchFromGitHub { owner = "beetbox"; @@ -59,6 +61,7 @@ lib.makeExtensible (self: { beets-minimal = self.beets.override { disableAllPlugins = true; }; beets-unstable = callPackage ./common.nix { + inherit python3Packages; version = "unstable-2023-07-05"; src = fetchFromGitHub { owner = "beetbox"; From 1772a2ac206a9c4b6f293128fac626895074481f Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Thu, 26 Oct 2023 23:51:27 +0300 Subject: [PATCH 5/5] beets-unstable: unstable-2023-07-05 -> unstable-2023-10-26 --- pkgs/tools/audio/beets/default.nix | 22 ++++----- ...nstable-bash-completion-always-print.patch | 46 ++++++++++--------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/pkgs/tools/audio/beets/default.nix b/pkgs/tools/audio/beets/default.nix index c6b99978fe38..c78ccced9a80 100644 --- a/pkgs/tools/audio/beets/default.nix +++ b/pkgs/tools/audio/beets/default.nix @@ -62,29 +62,27 @@ lib.makeExtensible (self: { beets-unstable = callPackage ./common.nix { inherit python3Packages; - version = "unstable-2023-07-05"; + version = "unstable-2023-10-26"; src = fetchFromGitHub { owner = "beetbox"; repo = "beets"; - rev = "9481402b3c20739ca0b879d19adbfca22ccd6a44"; - hash = "sha256-AKmozMNVchysoQcUWd90Ic6bQBKQgylVn0E3i85dGb8="; + rev = "6655760732100f5387fad2d2890c015ee5039981"; + hash = "sha256-Nz9BHtacYpJMLmB3f9WFg6GvMa+BuUhiNbJ9cyannek="; }; extraPatches = [ # Bash completion fix for Nix ./patches/unstable-bash-completion-always-print.patch - # Pillow 10 compatibility fix, see: - # https://github.com/beetbox/beets/pull/4868 - (fetchpatch { - url = "https://github.com/beetbox/beets/commit/c2118a8b9cd8c9c91135c6e178830b89b40867be.patch"; - hash = "sha256-HWf940WrF10Jnu9iyoHovFDcvj9LY8p7zIlJg1TfKxQ="; - # Doesn't apply on this file, and it we don't care. - excludes = [ "docs/changelog.rst" ]; - }) ]; pluginOverrides = { - # unstable has a new plugin, so we register it here. + # unstable has new plugins, so we register them here. limit = { builtin = true; }; + substitute = { builtin = true; }; + advancedrewrite = { builtin = true; }; + autobpm = { builtin = true; }; }; + extraNativeBuildInputs = [ + python3Packages.pydata-sphinx-theme + ]; }; alternatives = callPackage ./plugins/alternatives.nix { beets = self.beets-minimal; }; 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 index 395f40f92c98..96b175117572 100644 --- a/pkgs/tools/audio/beets/patches/unstable-bash-completion-always-print.patch +++ b/pkgs/tools/audio/beets/patches/unstable-bash-completion-always-print.patch @@ -1,34 +1,36 @@ -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) +diff --git i/beets/ui/commands.py w/beets/ui/commands.py +index ad4f7821..5077191d 100755 +--- i/beets/ui/commands.py ++++ w/beets/ui/commands.py +@@ -2381,22 +2381,6 @@ default_commands.append(config_cmd) def print_completion(*args): for line in completion_script(default_commands + plugins.commands()): - print_(line, end='') + 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.') +- 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', +- 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', +- b"/opt/local/share/bash-completion/bash_completion", - # Homebrew (before bash-completion2) -- b'/usr/local/etc/bash_completion', +- 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) +diff --git i/test/test_ui.py w/test/test_ui.py +index cae86148..faf266a8 100644 +--- i/test/test_ui.py ++++ w/test/test_ui.py +@@ -1434,12 +1434,7 @@ class CompletionTest(_common.TestCase, TestHelper): + ) # Load bash_completion library. - for path in commands.BASH_COMPLETION_PATHS: @@ -36,8 +38,8 @@ index f66917dc..f3d934c6 100644 - bash_completion = path - break - else: -- self.skipTest('bash-completion script not found') -+ self.skipTest('bash-completion script not found') +- self.skipTest("bash-completion script not found") ++ self.skipTest("bash-completion script not found") try: - with open(util.syspath(bash_completion), 'rb') as f: + with open(util.syspath(bash_completion), "rb") as f: tester.stdin.writelines(f)