diff options
author | adisbladis <adis@blad.is> | 2017-11-13 21:13:17 +0800 |
---|---|---|
committer | Jörg Thalheim <Mic92@users.noreply.github.com> | 2017-11-13 13:13:17 +0000 |
commit | d3cb4de970cb3e426c79524251df465844de0458 (patch) | |
tree | 277d770c3a59037db4d78e1f74c921fc954f4bcc /pkgs/games/anki | |
parent | 1a102a36baae580a90b1064b31df8e2af2fa8099 (diff) |
anki: Enable tests (#31582)
* anki: Enable tests
Convert package to use buildPythonApplication instead of mkDerivation
* anki: ignore tests via pytest arguments
Diffstat (limited to 'pkgs/games/anki')
-rw-r--r-- | pkgs/games/anki/beautifulsoup.nix | 4 | ||||
-rw-r--r-- | pkgs/games/anki/default.nix | 64 |
2 files changed, 47 insertions, 21 deletions
diff --git a/pkgs/games/anki/beautifulsoup.nix b/pkgs/games/anki/beautifulsoup.nix index 571df924e1f8..35118e5aabd2 100644 --- a/pkgs/games/anki/beautifulsoup.nix +++ b/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; diff --git a/pkgs/games/anki/default.nix b/pkgs/games/anki/default.nix index 22d5adc24475..b898fa1bbc57 100644 --- a/pkgs/games/anki/default.nix +++ b/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" @@ -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. @@ -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 @@ -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 @@ -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 @@ -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; }; } |