nixpkgs/pkgs/tools/audio/beets/default.nix

288 lines
9.5 KiB
Nix
Raw Normal View History

{ stdenv, fetchFromGitHub, writeScript, glibcLocales, diffPlugins
, pythonPackages, imagemagick, gobject-introspection, gst_all_1
, runtimeShell
, fetchpatch
beets: Run tests for external plugins In order to run the tests for the external plugins of beets, we need to have beets itself as a dependency. So in order to do that, we now pass beets without plugins and tests to the nativeBuildInputs of the plugins so that we can run them. As soon as the plugins are built they become part of the final beets, which also has tests enabled, so disabling the tests for beets derivation that is used for external plugin tests is a non-issue here because they're going to be executed anyway. Enabling tests for the alternatives plugin is pretty straightforward, but in order to run tests for the copyartifacts plugin, we need to bump the source code to the latest Git master. The reason for this is that the version that was in use until now required to have the beets source directory alongside of the copyartifacts source code, but we already have beets available as a normal dependency. Updating copyartifacts to latest master largely consists of unit test changes and a few Python 3 compatibility changes. However, one change has the biggest stat, which is sbarakat/beets-copyartifacts@1a0c281da0be7251f414397960a83d60dc3a1520. Fortunately, the last change is just moving the implementation to a newer API from upstream beets and by the looks of the implementation it seems to break support for moving files. However, reverting this commit also reveals that moving files was already broken before, so it wouldn't matter much whether we have this version bump or not. Tested with the following command: nix-build -E '(import ./. {}).beets.override { enableAlternatives = true; enableCopyArtifacts = true; }' Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @domenkozar, @pjones, @Profpatsch, @michalrus
2017-09-02 01:03:03 +01:00
# Attributes needed for tests of the external plugins
, callPackage, beets
2019-11-18 05:13:12 +00:00
, enableAbsubmit ? stdenv.lib.elem stdenv.hostPlatform.system essentia-extractor.meta.platforms, essentia-extractor ? null
, enableAcousticbrainz ? true
, enableAcoustid ? true
, enableBadfiles ? true, flac ? null, mp3val ? null
, enableConvert ? true, ffmpeg_3 ? null
, enableDiscogs ? true
, enableEmbyupdate ? true
, enableFetchart ? true
2017-06-28 21:27:17 +01:00
, enableGmusic ? true
, enableKeyfinder ? true, keyfinder-cli ? null
2017-06-28 21:27:17 +01:00
, enableKodiupdate ? true
, enableLastfm ? true
2019-09-23 05:23:56 +01:00
, enableLoadext ? true
, enableMpd ? true
2019-09-23 05:23:56 +01:00
, enablePlaylist ? true
, enableReplaygain ? true, bs1770gain ? null
, enableSonosUpdate ? true
2019-09-23 05:23:56 +01:00
, enableSubsonicupdate ? true
, enableThumbnails ? true
, enableWeb ? true
# External plugins
2016-09-10 00:43:42 +01:00
, enableAlternatives ? false
, enableCheck ? false, liboggz ? null
2016-09-10 00:43:42 +01:00
, enableCopyArtifacts ? false
2020-08-07 22:05:13 +01:00
, enableExtraFiles ? false
, bashInteractive, bash-completion
}:
2019-11-18 05:13:12 +00:00
assert enableAbsubmit -> essentia-extractor != null;
assert enableAcoustid -> pythonPackages.pyacoustid != null;
assert enableBadfiles -> flac != null && mp3val != null;
assert enableCheck -> flac != null && mp3val != null && liboggz != null;
assert enableConvert -> ffmpeg_3 != null;
assert enableDiscogs -> pythonPackages.discogs_client != null;
assert enableFetchart -> pythonPackages.responses != null;
2017-06-28 21:27:17 +01:00
assert enableGmusic -> pythonPackages.gmusicapi != null;
assert enableKeyfinder -> keyfinder-cli != null;
assert enableLastfm -> pythonPackages.pylast != null;
2017-06-28 21:27:17 +01:00
assert enableMpd -> pythonPackages.mpd2 != null;
assert enableReplaygain -> bs1770gain != null;
assert enableSonosUpdate -> pythonPackages.soco != null;
assert enableThumbnails -> pythonPackages.pyxdg != null;
assert enableWeb -> pythonPackages.flask != null;
with stdenv.lib;
let
optionalPlugins = {
2019-11-18 05:13:12 +00:00
absubmit = enableAbsubmit;
acousticbrainz = enableAcousticbrainz;
badfiles = enableBadfiles;
chroma = enableAcoustid;
convert = enableConvert;
discogs = enableDiscogs;
embyupdate = enableEmbyupdate;
fetchart = enableFetchart;
2017-06-28 21:27:17 +01:00
gmusic = enableGmusic;
keyfinder = enableKeyfinder;
2017-06-28 21:27:17 +01:00
kodiupdate = enableKodiupdate;
lastgenre = enableLastfm;
lastimport = enableLastfm;
2019-09-23 05:23:56 +01:00
loadext = enableLoadext;
mpdstats = enableMpd;
mpdupdate = enableMpd;
2019-09-23 05:23:56 +01:00
playlist = enablePlaylist;
replaygain = enableReplaygain;
sonosupdate = enableSonosUpdate;
2019-09-23 05:23:56 +01:00
subsonicupdate = enableSubsonicupdate;
thumbnails = enableThumbnails;
web = enableWeb;
};
pluginsWithoutDeps = [
2019-11-18 05:13:12 +00:00
"beatport" "bench" "bpd" "bpm" "bucket" "cue" "duplicates" "edit" "embedart"
"export" "filefilter" "freedesktop" "fromfilename" "ftintitle" "fuzzy"
"hook" "ihate" "importadded" "importfeeds" "info" "inline" "ipfs" "lyrics"
"mbcollection" "mbsubmit" "mbsync" "metasync" "missing" "permissions" "play"
"plexupdate" "random" "rewrite" "scrub" "smartplaylist" "spotify" "the"
"types" "zero"
];
enabledOptionalPlugins = attrNames (filterAttrs (_: id) optionalPlugins);
allPlugins = pluginsWithoutDeps ++ attrNames optionalPlugins;
allEnabledPlugins = pluginsWithoutDeps ++ enabledOptionalPlugins;
testShell = "${bashInteractive}/bin/bash --norc";
completion = "${bash-completion}/share/bash-completion/bash_completion";
beets: Run tests for external plugins In order to run the tests for the external plugins of beets, we need to have beets itself as a dependency. So in order to do that, we now pass beets without plugins and tests to the nativeBuildInputs of the plugins so that we can run them. As soon as the plugins are built they become part of the final beets, which also has tests enabled, so disabling the tests for beets derivation that is used for external plugin tests is a non-issue here because they're going to be executed anyway. Enabling tests for the alternatives plugin is pretty straightforward, but in order to run tests for the copyartifacts plugin, we need to bump the source code to the latest Git master. The reason for this is that the version that was in use until now required to have the beets source directory alongside of the copyartifacts source code, but we already have beets available as a normal dependency. Updating copyartifacts to latest master largely consists of unit test changes and a few Python 3 compatibility changes. However, one change has the biggest stat, which is sbarakat/beets-copyartifacts@1a0c281da0be7251f414397960a83d60dc3a1520. Fortunately, the last change is just moving the implementation to a newer API from upstream beets and by the looks of the implementation it seems to break support for moving files. However, reverting this commit also reveals that moving files was already broken before, so it wouldn't matter much whether we have this version bump or not. Tested with the following command: nix-build -E '(import ./. {}).beets.override { enableAlternatives = true; enableCopyArtifacts = true; }' Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @domenkozar, @pjones, @Profpatsch, @michalrus
2017-09-02 01:03:03 +01:00
# This is a stripped down beets for testing of the external plugins.
externalTestArgs.beets = (beets.override {
enableAlternatives = false;
enableCopyArtifacts = false;
2020-08-07 22:05:13 +01:00
enableExtraFiles = false;
beets: Run tests for external plugins In order to run the tests for the external plugins of beets, we need to have beets itself as a dependency. So in order to do that, we now pass beets without plugins and tests to the nativeBuildInputs of the plugins so that we can run them. As soon as the plugins are built they become part of the final beets, which also has tests enabled, so disabling the tests for beets derivation that is used for external plugin tests is a non-issue here because they're going to be executed anyway. Enabling tests for the alternatives plugin is pretty straightforward, but in order to run tests for the copyartifacts plugin, we need to bump the source code to the latest Git master. The reason for this is that the version that was in use until now required to have the beets source directory alongside of the copyartifacts source code, but we already have beets available as a normal dependency. Updating copyartifacts to latest master largely consists of unit test changes and a few Python 3 compatibility changes. However, one change has the biggest stat, which is sbarakat/beets-copyartifacts@1a0c281da0be7251f414397960a83d60dc3a1520. Fortunately, the last change is just moving the implementation to a newer API from upstream beets and by the looks of the implementation it seems to break support for moving files. However, reverting this commit also reveals that moving files was already broken before, so it wouldn't matter much whether we have this version bump or not. Tested with the following command: nix-build -E '(import ./. {}).beets.override { enableAlternatives = true; enableCopyArtifacts = true; }' Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @domenkozar, @pjones, @Profpatsch, @michalrus
2017-09-02 01:03:03 +01:00
}).overrideAttrs (stdenv.lib.const {
doInstallCheck = false;
});
pluginArgs = externalTestArgs // { inherit pythonPackages; };
beets: Run tests for external plugins In order to run the tests for the external plugins of beets, we need to have beets itself as a dependency. So in order to do that, we now pass beets without plugins and tests to the nativeBuildInputs of the plugins so that we can run them. As soon as the plugins are built they become part of the final beets, which also has tests enabled, so disabling the tests for beets derivation that is used for external plugin tests is a non-issue here because they're going to be executed anyway. Enabling tests for the alternatives plugin is pretty straightforward, but in order to run tests for the copyartifacts plugin, we need to bump the source code to the latest Git master. The reason for this is that the version that was in use until now required to have the beets source directory alongside of the copyartifacts source code, but we already have beets available as a normal dependency. Updating copyartifacts to latest master largely consists of unit test changes and a few Python 3 compatibility changes. However, one change has the biggest stat, which is sbarakat/beets-copyartifacts@1a0c281da0be7251f414397960a83d60dc3a1520. Fortunately, the last change is just moving the implementation to a newer API from upstream beets and by the looks of the implementation it seems to break support for moving files. However, reverting this commit also reveals that moving files was already broken before, so it wouldn't matter much whether we have this version bump or not. Tested with the following command: nix-build -E '(import ./. {}).beets.override { enableAlternatives = true; enableCopyArtifacts = true; }' Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @domenkozar, @pjones, @Profpatsch, @michalrus
2017-09-02 01:03:03 +01:00
plugins = {
alternatives = callPackage ./alternatives-plugin.nix pluginArgs;
check = callPackage ./check-plugin.nix pluginArgs;
copyartifacts = callPackage ./copyartifacts-plugin.nix pluginArgs;
2020-08-07 22:05:13 +01:00
extrafiles = callPackage ./extrafiles-plugin.nix pluginArgs;
beets: Run tests for external plugins In order to run the tests for the external plugins of beets, we need to have beets itself as a dependency. So in order to do that, we now pass beets without plugins and tests to the nativeBuildInputs of the plugins so that we can run them. As soon as the plugins are built they become part of the final beets, which also has tests enabled, so disabling the tests for beets derivation that is used for external plugin tests is a non-issue here because they're going to be executed anyway. Enabling tests for the alternatives plugin is pretty straightforward, but in order to run tests for the copyartifacts plugin, we need to bump the source code to the latest Git master. The reason for this is that the version that was in use until now required to have the beets source directory alongside of the copyartifacts source code, but we already have beets available as a normal dependency. Updating copyartifacts to latest master largely consists of unit test changes and a few Python 3 compatibility changes. However, one change has the biggest stat, which is sbarakat/beets-copyartifacts@1a0c281da0be7251f414397960a83d60dc3a1520. Fortunately, the last change is just moving the implementation to a newer API from upstream beets and by the looks of the implementation it seems to break support for moving files. However, reverting this commit also reveals that moving files was already broken before, so it wouldn't matter much whether we have this version bump or not. Tested with the following command: nix-build -E '(import ./. {}).beets.override { enableAlternatives = true; enableCopyArtifacts = true; }' Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @domenkozar, @pjones, @Profpatsch, @michalrus
2017-09-02 01:03:03 +01:00
};
in pythonPackages.buildPythonApplication rec {
2018-07-24 17:17:24 +01:00
pname = "beets";
2019-09-23 05:23:56 +01:00
version = "1.4.9";
src = fetchFromGitHub {
owner = "beetbox";
repo = "beets";
rev = "v${version}";
2019-09-23 05:23:56 +01:00
sha256 = "1qxdqbzvz97zgykzdwn78g2xyxmg0q2jdb12dnjnrwvhmjv67vi8";
};
propagatedBuildInputs = [
pythonPackages.six
pythonPackages.enum34
pythonPackages.jellyfish
pythonPackages.munkres
pythonPackages.musicbrainzngs
pythonPackages.mutagen
pythonPackages.pyyaml
pythonPackages.unidecode
pythonPackages.gst-python
pythonPackages.pygobject3
gobject-introspection
2019-11-18 05:13:12 +00:00
] ++ optional enableAbsubmit essentia-extractor
++ optional enableAcoustid pythonPackages.pyacoustid
++ optional (enableFetchart
|| enableEmbyupdate
2017-06-28 21:27:17 +01:00
|| enableKodiupdate
2019-09-23 05:23:56 +01:00
|| enableLoadext
|| enablePlaylist
|| enableSubsonicupdate
|| enableAcousticbrainz)
beets: Run tests for external plugins In order to run the tests for the external plugins of beets, we need to have beets itself as a dependency. So in order to do that, we now pass beets without plugins and tests to the nativeBuildInputs of the plugins so that we can run them. As soon as the plugins are built they become part of the final beets, which also has tests enabled, so disabling the tests for beets derivation that is used for external plugin tests is a non-issue here because they're going to be executed anyway. Enabling tests for the alternatives plugin is pretty straightforward, but in order to run tests for the copyartifacts plugin, we need to bump the source code to the latest Git master. The reason for this is that the version that was in use until now required to have the beets source directory alongside of the copyartifacts source code, but we already have beets available as a normal dependency. Updating copyartifacts to latest master largely consists of unit test changes and a few Python 3 compatibility changes. However, one change has the biggest stat, which is sbarakat/beets-copyartifacts@1a0c281da0be7251f414397960a83d60dc3a1520. Fortunately, the last change is just moving the implementation to a newer API from upstream beets and by the looks of the implementation it seems to break support for moving files. However, reverting this commit also reveals that moving files was already broken before, so it wouldn't matter much whether we have this version bump or not. Tested with the following command: nix-build -E '(import ./. {}).beets.override { enableAlternatives = true; enableCopyArtifacts = true; }' Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @domenkozar, @pjones, @Profpatsch, @michalrus
2017-09-02 01:03:03 +01:00
pythonPackages.requests
++ optional enableCheck plugins.check
++ optional enableConvert ffmpeg_3
beets: Run tests for external plugins In order to run the tests for the external plugins of beets, we need to have beets itself as a dependency. So in order to do that, we now pass beets without plugins and tests to the nativeBuildInputs of the plugins so that we can run them. As soon as the plugins are built they become part of the final beets, which also has tests enabled, so disabling the tests for beets derivation that is used for external plugin tests is a non-issue here because they're going to be executed anyway. Enabling tests for the alternatives plugin is pretty straightforward, but in order to run tests for the copyartifacts plugin, we need to bump the source code to the latest Git master. The reason for this is that the version that was in use until now required to have the beets source directory alongside of the copyartifacts source code, but we already have beets available as a normal dependency. Updating copyartifacts to latest master largely consists of unit test changes and a few Python 3 compatibility changes. However, one change has the biggest stat, which is sbarakat/beets-copyartifacts@1a0c281da0be7251f414397960a83d60dc3a1520. Fortunately, the last change is just moving the implementation to a newer API from upstream beets and by the looks of the implementation it seems to break support for moving files. However, reverting this commit also reveals that moving files was already broken before, so it wouldn't matter much whether we have this version bump or not. Tested with the following command: nix-build -E '(import ./. {}).beets.override { enableAlternatives = true; enableCopyArtifacts = true; }' Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @domenkozar, @pjones, @Profpatsch, @michalrus
2017-09-02 01:03:03 +01:00
++ optional enableDiscogs pythonPackages.discogs_client
++ optional enableGmusic pythonPackages.gmusicapi
++ optional enableKeyfinder keyfinder-cli
++ optional enableLastfm pythonPackages.pylast
++ optional enableMpd pythonPackages.mpd2
++ optional enableSonosUpdate pythonPackages.soco
beets: Run tests for external plugins In order to run the tests for the external plugins of beets, we need to have beets itself as a dependency. So in order to do that, we now pass beets without plugins and tests to the nativeBuildInputs of the plugins so that we can run them. As soon as the plugins are built they become part of the final beets, which also has tests enabled, so disabling the tests for beets derivation that is used for external plugin tests is a non-issue here because they're going to be executed anyway. Enabling tests for the alternatives plugin is pretty straightforward, but in order to run tests for the copyartifacts plugin, we need to bump the source code to the latest Git master. The reason for this is that the version that was in use until now required to have the beets source directory alongside of the copyartifacts source code, but we already have beets available as a normal dependency. Updating copyartifacts to latest master largely consists of unit test changes and a few Python 3 compatibility changes. However, one change has the biggest stat, which is sbarakat/beets-copyartifacts@1a0c281da0be7251f414397960a83d60dc3a1520. Fortunately, the last change is just moving the implementation to a newer API from upstream beets and by the looks of the implementation it seems to break support for moving files. However, reverting this commit also reveals that moving files was already broken before, so it wouldn't matter much whether we have this version bump or not. Tested with the following command: nix-build -E '(import ./. {}).beets.override { enableAlternatives = true; enableCopyArtifacts = true; }' Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @domenkozar, @pjones, @Profpatsch, @michalrus
2017-09-02 01:03:03 +01:00
++ optional enableThumbnails pythonPackages.pyxdg
++ optional enableWeb pythonPackages.flask
++ optional enableAlternatives plugins.alternatives
2020-08-07 22:05:13 +01:00
++ optional enableCopyArtifacts plugins.copyartifacts
++ optional enableExtraFiles plugins.extrafiles
;
2019-02-20 19:07:21 +00:00
buildInputs = [
2015-06-01 04:51:04 +01:00
imagemagick
] ++ (with gst_all_1; [
gst-plugins-base
gst-plugins-good
gst-plugins-ugly
]);
2019-02-20 19:07:21 +00:00
checkInputs = with pythonPackages; [
beautifulsoup4
mock
nose
rarfile
responses
# Although considered as plugin dependencies, they are needed for the
# tests, for disabling them via an override makes the build fail. see:
# https://github.com/beetbox/beets/blob/v1.4.9/setup.py
pylast
mpd2
discogs_client
pyxdg
2019-02-20 19:07:21 +00:00
];
patches = [
./replaygain-default-bs1770gain.patch
./keyfinder-default-bin.patch
./mutagen-1.43.patch
(fetchpatch {
# Fixes failing testcases around the werkzeug component; can dropped after 1.4.9
url = "https://github.com/beetbox/beets/commit/d43d54e21cde97f57f19486925ab56b419254cc8.patch";
sha256 = "13n2gzmcgfi0m2ycl2r1hpczgksplnkc3y6b66vg57rx5y8nnv5c";
})
# Fixes 548 tests due to breaking changes to the ast module
# https://github.com/beetbox/beets/pull/3621
# Can be dropped after 1.4.9
./compatibility-with-breaking-changes-to-the-ast-module.patch
];
postPatch = ''
sed -i -e '/assertIn.*item.*path/d' test/test_info.py
echo echo completion tests passed > test/rsrc/test_completion.sh
sed -i -e '/^BASH_COMPLETION_PATHS *=/,/^])$/ {
/^])$/i u"${completion}"
}' beets/ui/commands.py
'' + optionalString enableBadfiles ''
sed -i -e '/self\.run_command(\[/ {
s,"flac","${flac.bin}/bin/flac",
s,"mp3val","${mp3val}/bin/mp3val",
}' beetsplug/badfiles.py
'' + optionalString enableConvert ''
sed -i -e 's,\(util\.command_output(\)\([^)]\+\)),\1[b"${ffmpeg_3.bin}/bin/ffmpeg" if args[0] == b"ffmpeg" else args[0]] + \2[1:]),' beetsplug/convert.py
'' + optionalString enableReplaygain ''
sed -i -re '
s!^( *cmd *= *b?['\'''"])(bs1770gain['\'''"])!\1${bs1770gain}/bin/\2!
' beetsplug/replaygain.py
sed -i -e 's/if has_program.*bs1770gain.*:/if True:/' \
test/test_replaygain.py
'';
2018-05-13 20:30:50 +01:00
postInstall = ''
mkdir -p $out/share/zsh/site-functions
cp extra/_beet $out/share/zsh/site-functions/
'';
doCheck = true;
preCheck = ''
find beetsplug -mindepth 1 \
\! -path 'beetsplug/__init__.py' -a \
\( -name '*.py' -o -path 'beetsplug/*/__init__.py' \) -print \
| sed -n -re 's|^beetsplug/([^/.]+).*|\1|p' \
| sort -u > plugins_available
${diffPlugins allPlugins "plugins_available"}
'';
checkPhase = ''
runHook preCheck
LANG=en_US.UTF-8 \
LOCALE_ARCHIVE=${assert stdenv.isLinux; glibcLocales}/lib/locale/locale-archive \
BEETS_TEST_SHELL="${testShell}" \
BASH_COMPLETION_SCRIPT="${completion}" \
2019-02-20 19:07:21 +00:00
HOME="$(mktemp -d)" nosetests -v
runHook postCheck
'';
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
tmphome="$(mktemp -d)"
EDITOR="${writeScript "beetconfig.sh" ''
#!${runtimeShell}
cat > "$1" <<CFG
plugins: ${concatStringsSep " " allEnabledPlugins}
CFG
''}" HOME="$tmphome" "$out/bin/beet" config -e
EDITOR=true HOME="$tmphome" "$out/bin/beet" config -e
runHook postInstallCheck
'';
makeWrapperArgs = [ "--set GI_TYPELIB_PATH \"$GI_TYPELIB_PATH\"" "--set GST_PLUGIN_SYSTEM_PATH_1_0 \"$GST_PLUGIN_SYSTEM_PATH_1_0\"" ];
passthru = {
externalPlugins = plugins;
};
meta = {
description = "Music tagger and library organizer";
2020-03-25 13:27:55 +00:00
homepage = "http://beets.io";
2015-06-01 04:51:04 +01:00
license = licenses.mit;
maintainers = with maintainers; [ aszlig domenkozar pjones ];
platforms = platforms.linux;
};
}