Skip to content

Commit

Permalink
anki: Enable tests (#31582)
Browse files Browse the repository at this point in the history
* anki: Enable tests

Convert package to use buildPythonApplication instead of mkDerivation

* anki: ignore tests via pytest arguments
  • Loading branch information
adisbladis authored and Mic92 committed Nov 13, 2017
1 parent 1a102a3 commit d3cb4de
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 22 deletions.
4 changes: 2 additions & 2 deletions pkgs/games/anki/beautifulsoup.nix
@@ -1,6 +1,6 @@
{ pythonPackages, isPy3k, pkgs }:
{ buildPythonPackage, isPy3k, pkgs }:

pythonPackages.buildPythonPackage rec {
buildPythonPackage rec {
name = "beautifulsoup-3.2.1";
disabled = isPy3k;

Expand Down
64 changes: 45 additions & 19 deletions pkgs/games/anki/default.nix
@@ -1,24 +1,36 @@
{ stdenv, lib, fetchurl, substituteAll, lame, mplayer
{ stdenv
, buildPythonPackage
, callPackage
, lib
, python
, fetchurl
, substituteAll
, lame
, mplayer
, libpulseaudio
, pyqt4
, sqlalchemy
, pyaudio
, httplib2
, matplotlib
, pytest
, glibcLocales
, nose
# This little flag adds a huge number of dependencies, but we assume that
# everyone wants Anki to draw plots with statistics by default.
, plotsSupport ? true
, python2Packages
}:

let
version = "2.0.47";
inherit (python2Packages) python wrapPython sqlalchemy pyaudio beautifulsoup4 httplib2 matplotlib pyqt4;
qt4 = pyqt4.qt;

# Development version of anki has bumped to beautifulsoup4
beautifulsoup = python2Packages.callPackage ./beautifulsoup.nix {
pythonPackages = python2Packages;
};
beautifulsoup = callPackage ./beautifulsoup.nix { };

in
stdenv.mkDerivation rec {
qt4 = pyqt4.qt;

in buildPythonPackage rec {
version = "2.0.47";
name = "anki-${version}";

src = fetchurl {
urls = [
"https://apps.ankiweb.net/downloads/current/${name}-source.tgz"
Expand All @@ -28,12 +40,12 @@ stdenv.mkDerivation rec {
sha256 = "067bsidqzy1zc301i2pk4biwp2kwvgk4kydp5z5s551acinkbdgv";
};

pythonPath = [ pyqt4 sqlalchemy pyaudio beautifulsoup httplib2 ]
++ lib.optional plotsSupport matplotlib;
propagatedBuildInputs = [ pyqt4 sqlalchemy pyaudio beautifulsoup httplib2 ]
++ lib.optional plotsSupport matplotlib;

buildInputs = [ python wrapPython lame mplayer libpulseaudio ];
checkInputs = [ pytest glibcLocales nose ];

phases = [ "unpackPhase" "patchPhase" "installPhase" ];
buildInputs = [ lame mplayer libpulseaudio ];

patches = [
# Disable updated version check.
Expand All @@ -46,6 +58,11 @@ stdenv.mkDerivation rec {
})
];

buildPhase = ''
# Dummy build phase
# Anki does not use setup.py
'';

postPatch = ''
substituteInPlace oldanki/lang.py --subst-var-by anki $out
substituteInPlace anki/lang.py --subst-var-by anki $out
Expand All @@ -58,6 +75,15 @@ stdenv.mkDerivation rec {
rm "locale/"*.qm
'';

# UTF-8 locale needed for testing
LC_ALL = "en_US.UTF-8";

checkPhase = ''
# - Anki writes some files to $HOME during tests
# - Skip tests using network
env HOME=$TMP pytest --ignore tests/test_sync.py
'';

installPhase = ''
pp=$out/lib/${python.libPrefix}/site-packages
Expand Down Expand Up @@ -87,10 +113,10 @@ stdenv.mkDerivation rec {
wrapPythonPrograms
'';

meta = {
meta = with stdenv.lib; {
homepage = http://ankisrs.net/;
description = "Spaced repetition flashcard program";
license = stdenv.lib.licenses.gpl3;
license = licenses.gpl3;

longDescription = ''
Anki is a program which makes remembering things easy. Because it is a lot
Expand All @@ -105,7 +131,7 @@ stdenv.mkDerivation rec {
or even practicing guitar chords!
'';

maintainers = with stdenv.lib.maintainers; [ the-kenny ];
platforms = stdenv.lib.platforms.mesaPlatforms;
maintainers = with maintainers; [ the-kenny ];
platforms = platforms.mesaPlatforms;
};
}
2 changes: 1 addition & 1 deletion pkgs/top-level/all-packages.nix
Expand Up @@ -17638,7 +17638,7 @@ with pkgs;

angband = callPackage ../games/angband { };

anki = callPackage ../games/anki { };
anki = python2Packages.callPackage ../games/anki { };

armagetronad = callPackage ../games/armagetronad { };

Expand Down

0 comments on commit d3cb4de

Please sign in to comment.