anki: Enable tests (#31582)

* anki: Enable tests

Convert package to use buildPythonApplication instead of mkDerivation

* anki: ignore tests via pytest arguments
This commit is contained in:
adisbladis 2017-11-13 21:13:17 +08:00 committed by Jörg Thalheim
parent 1a102a36ba
commit d3cb4de970
3 changed files with 48 additions and 22 deletions

View file

@ -1,6 +1,6 @@
{ pythonPackages, isPy3k, pkgs }:
{ buildPythonPackage, isPy3k, pkgs }:
pythonPackages.buildPythonPackage rec {
buildPythonPackage rec {
name = "beautifulsoup-3.2.1";
disabled = isPy3k;

View file

@ -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;
# Development version of anki has bumped to beautifulsoup4
beautifulsoup = callPackage ./beautifulsoup.nix { };
qt4 = pyqt4.qt;
# Development version of anki has bumped to beautifulsoup4
beautifulsoup = python2Packages.callPackage ./beautifulsoup.nix {
pythonPackages = python2Packages;
};
in
stdenv.mkDerivation rec {
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;
};
}

View file

@ -17638,7 +17638,7 @@ with pkgs;
angband = callPackage ../games/angband { };
anki = callPackage ../games/anki { };
anki = python2Packages.callPackage ../games/anki { };
armagetronad = callPackage ../games/armagetronad { };