anchor.diff:      werkzeug
     ] ++ optionals isPy2 [
       enum34
  -  ] ++ optionals (versionOlder pythonPackages.python.channel "3.5") [
       pathlib
     ] ++ [
       pycountry
  
positive.code:       test/test_replaygain.py
    '';
  
    preCheck = ''
      (${concatMapStrings (s: "echo \"${s}\";") allPlugins}) \
        | sort -u > plugins_defined
      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
  
      if ! mismatches="$(diff -y plugins_defined plugins_available)"; then
        echo "The the list of defined plugins (left side) doesn't match" \
             "the list of available plugins (right side):" >&2
        echo "$mismatches" >&2
        exit 1
      fi
    '';
  
    # TODO: fix LOCALE_ARCHIVE for freebsd
    checkPhase = ''
      runHook 'preCheck'
  
      LANG=en_US.UTF-8 \
      LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive \
      BEETS_TEST_SHELL="${testShell}" \
      BASH_COMPLETION_SCRIPT="${completion}" \
      HOME="$(mktemp -d)"
      nosetests -v
      mkdir -p $HOME/
  
      runHook 'postCheck'
    '';
  
    installCheckPhase = ''
      runHook 'preInstallCheck'
  
      tmphome="$(mktemp -d)"
  
      EDITOR="${writeScript "beetconfig.sh" ''
        #!${stdenv.shell}
        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'
    '';
  
    doCheck = !isPy3;
    doInstallCheck = true;
  
    meta = with lib; {
      description = "Music tagger and library organizer";
      homepage = http://beets.radbox.org;
  
negative.code: 
  let
    inherit (lib)
      optional
      optionals;
  
    completion = "${bash-completion}/share/bash-completion/bash_completion";
  
    version = "1.4.5";
  