From 29e89248bfe74ca8d9d539c7ae441fac24c05330 Mon Sep 17 00:00:00 2001 From: aszlig Date: Thu, 2 Aug 2018 01:41:36 +0200 Subject: [PATCH] beets: Fix building plugins with Python 3 Since the switch to using python3Packages in commit 72934aa94e322eb3d5be277d667466643f78e706, the plugins no longer build because they end up with a mix of Python 2 and Python 3 packages. The reason for this is that the Beets package itself uses callPackage to reference the plugins, however the overrides are not applied there and thus the plugins end up getting pythonPackages from the top-level which is Python 2 and beets with Python 3 dependencies. Unfortunately this is not the only reason for the builds to fail, because both plugins did not actually support Python 3. For the copyartifacts plugin, the fix is rather easy because we only need to advance to two more recent commits from upstream, which already contain fixes for Python 3. The alternatives plugin on the other hand is not maintained anymore, but there is a fork at https://github.com/wisp3rwind/beets-alternatives which has a bunch of fixes. In 2e4aded366914d625a2f31208e8ac8548cb43a7e I already backported one of these fixes to the version from https://github.com/geigerzaehler/beets-alternatives, but for Python 3 support it's a bit more complicated than just one little fix. So instead of adding another series of patches which replicate the code base of the fork and become a maintenance burden, I opted to directly switch to the fork and remove the patch on our side. Signed-off-by: aszlig Cc: @domenkozar, @pjones, @Profpatsch --- .../beets/alternatives-beets-1.4.6.patch | 30 ------------------- .../tools/audio/beets/alternatives-plugin.nix | 14 ++++----- .../audio/beets/copyartifacts-plugin.nix | 4 +-- pkgs/tools/audio/beets/default.nix | 6 ++-- 4 files changed, 11 insertions(+), 43 deletions(-) delete mode 100644 pkgs/tools/audio/beets/alternatives-beets-1.4.6.patch diff --git a/pkgs/tools/audio/beets/alternatives-beets-1.4.6.patch b/pkgs/tools/audio/beets/alternatives-beets-1.4.6.patch deleted file mode 100644 index 652e0e4a94b0..000000000000 --- a/pkgs/tools/audio/beets/alternatives-beets-1.4.6.patch +++ /dev/null @@ -1,30 +0,0 @@ -diff --git a/test/helper.py b/test/helper.py -index c216226..d409c09 100644 ---- a/test/helper.py -+++ b/test/helper.py -@@ -11,6 +11,7 @@ import beets - from beets import plugins - from beets import ui - from beets.library import Item -+from beets.util import MoveOperation - - from beetsplug import alternatives - from beetsplug import convert -@@ -183,7 +184,7 @@ class TestHelper(Assertions): - item = Item.from_path(os.path.join(self.fixture_dir, 'min.' + ext)) - item.add(self.lib) - item.update(values) -- item.move(copy=True) -+ item.move(operation=MoveOperation.COPY) - item.write() - album = self.lib.add_album([item]) - album.albumartist = item.artist -@@ -201,7 +202,7 @@ class TestHelper(Assertions): - item = Item.from_path(os.path.join(self.fixture_dir, 'min.mp3')) - item.add(self.lib) - item.update(values) -- item.move(copy=True) -+ item.move(operation=MoveOperation.COPY) - item.write() - return item - diff --git a/pkgs/tools/audio/beets/alternatives-plugin.nix b/pkgs/tools/audio/beets/alternatives-plugin.nix index f808e90281e6..a3e7f9a63d65 100644 --- a/pkgs/tools/audio/beets/alternatives-plugin.nix +++ b/pkgs/tools/audio/beets/alternatives-plugin.nix @@ -6,24 +6,20 @@ pythonPackages.buildPythonApplication rec { src = fetchFromGitHub { repo = "beets-alternatives"; - owner = "geigerzaehler"; - rev = "v${version}"; - sha256 = "10za6h59pxa13y8i4amqhc6392csml0dl771lssv6b6a98kamsy7"; + owner = "wisp3rwind"; + # This is 0.8.2 with fixes against Beets 1.4.6 and Python 3 compatibility. + rev = "331eb406786a2d4dc3dd721a534225b087474b1e"; + sha256 = "1avds2x5sp72c89l1j52pszprm85g9sm750jh1dhnyvgcbk91cb5"; }; - patches = [ ./alternatives-beets-1.4.6.patch ]; - postPatch = '' - sed -i -e '/install_requires/,/\]/{/beets/d}' setup.py - sed -i -e '/test_suite/d' setup.py + sed -i -e '/long_description/d' setup.py ''; nativeBuildInputs = [ beets pythonPackages.nose ]; checkPhase = "nosetests"; - propagatedBuildInputs = with pythonPackages; [ futures ]; - meta = { description = "Beets plugin to manage external files"; homepage = https://github.com/geigerzaehler/beets-alternatives; diff --git a/pkgs/tools/audio/beets/copyartifacts-plugin.nix b/pkgs/tools/audio/beets/copyartifacts-plugin.nix index 6f84e98d23e8..3c9cc5639a8f 100644 --- a/pkgs/tools/audio/beets/copyartifacts-plugin.nix +++ b/pkgs/tools/audio/beets/copyartifacts-plugin.nix @@ -6,8 +6,8 @@ pythonPackages.buildPythonApplication rec { src = fetchFromGitHub { repo = "beets-copyartifacts"; owner = "sbarakat"; - rev = "4a5d347c858d25641c8a0eb7d8cb1a2cac10252a"; - sha256 = "0bn6fci480ilghrdhpsjxxq29dxgni22sv1qalz770xy130g1zk3"; + rev = "d0bb75c8fc8fe125e8191d73de7ade6212aec0fd"; + sha256 = "19b4lqq1p45n348ssmql60jylw2fw7vfj9j22nly5qj5qx51j3g5"; }; postPatch = '' diff --git a/pkgs/tools/audio/beets/default.nix b/pkgs/tools/audio/beets/default.nix index 5c7ced40afb6..8f0cc6c4f5c6 100644 --- a/pkgs/tools/audio/beets/default.nix +++ b/pkgs/tools/audio/beets/default.nix @@ -91,9 +91,11 @@ let doInstallCheck = false; }); + pluginArgs = externalTestArgs // { inherit pythonPackages; }; + plugins = { - alternatives = callPackage ./alternatives-plugin.nix externalTestArgs; - copyartifacts = callPackage ./copyartifacts-plugin.nix externalTestArgs; + alternatives = callPackage ./alternatives-plugin.nix pluginArgs; + copyartifacts = callPackage ./copyartifacts-plugin.nix pluginArgs; }; in pythonPackages.buildPythonApplication rec {