root/anki.scm

(define-module (hidamari-blue anki)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system python)
  #:use-module (guix utils)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module ((guix licenses) #:renamer (symbol-prefix-proc 'license:))
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages qt)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages audio)
  #:use-module (gnu packages python)
  #:use-module (gnu packages compression))

;;; status: requires Qt 5.7+ to continue
;;; PyQt5.QtWebEngineWidgets is missing from pyqt, maybe for above reason

(define-public python-pyaudio
  (package
   (name "python-pyaudio")
   (version "0.2.11")
   (source
    (origin
     (method url-fetch)
     (uri (string-append
           "https://pypi.python.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-"
           version
           ".tar.gz"))
     (sha256
      (base32
       "0x7vdsigm7xgvyg3shd3lj113m8zqj2pxmrgdyj66kmnw0qdxgwk"))))
   (build-system python-build-system)
   (inputs `(("portaudio" ,portaudio)))
   (home-page
    "http://people.csail.mit.edu/hubert/pyaudio/")
   (synopsis
    "Bindings for PortAudio v19, the cross-platform audio input/output stream library.")
   (description
    "Bindings for PortAudio v19, the cross-platform audio input/output stream library.")
   (license #f)))

(define-public python2-pyaudio
  (package
   (inherit (package-with-python2
             (strip-python2-variant python-pyaudio)))
   (arguments `(#:python ,python-2))))

;;; send2trash will not build for python3
;;; wtf it does not work with python3, can you mix it?
(define python-send2trash
  (package
   (name "python-send2trash")
   (version "1.3.0")
   (source
    (origin
     (method url-fetch)
     (uri (string-append
           "https://pypi.python.org/packages/cd/62/e40006ddd56e1b5aa49d343aa2cb3a9014174c237af2cf70011cba173c73/Send2Trash-"
           version
           ".tar.gz"))
     (sha256
      (base32
       "1zjq5ki02l0vl4f1xymsnqyxipx6q81a435p46db07l3mqg4dx1k"))))
   (build-system python-build-system)
   (home-page "http://github.com/hsoft/send2trash")
   (synopsis
    "Send file to trash natively under Mac OS X, Windows and Linux.")
   (description
    "Send file to trash natively under Mac OS X, Windows and Linux.")
   (license license:bsd-3)))

(define-public python2-send2trash
  (package
   (inherit (package-with-python2
             (strip-python2-variant python-send2trash)))
   (arguments `(#:python ,python-2))))

(define-public anki
  (let ((commit "7f7b8fc52faaa4b6d7de3478bb26328c36a73080"))
    (package
     (name "anki")
     (version (string-append "2.0.45-" commit))
     ;; (source (origin
     ;;          (method url-fetch)
     ;;          (uri (string-append "https://apps.ankiweb.net/downloads/current/anki-"
     ;;                              version "-source.tgz"))
     ;;          (sha256
     ;;           (base32
     ;;            "0yqs4j2r4mp025r2af34s51q05ahwmywla34i0agsjwlixb936q0"))))

     ;; the tar ball release does not contain pip files
     (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/dae/anki")
                    (commit commit)))
              (sha256
               (base32
                "0999rk1agqsk62chb746l2kp1xf109y7k31rjjhdqim60cmnci3r"))))

     (arguments `(#:phases
                  (modify-phases
                   %standard-phases
                   (add-before 'build 'create-setup
                               (lambda* (#:key source version inputs #:allow-other-keys)
                                 (call-with-output-file "setup.py"
                                   (lambda (port)
                                     (display
                                      "#!/usr/bin/env python

from distutils.core import setup

setup(name='Anki',
      version='2.0.45',
      description='Anki Flashcard reptition program',
      author='Anki developers',
      author_email='todo',
      url='https://apps.ankiweb.net/',
      packages=['anki'],
      scripts=['runanki'],
     )"  port)))
                                 (system* "./tools/build_ui.sh")
                                 ;; TODO wait for qt5.7+ to hit
                                 ;; (substitute* "aqt/qt.py"
                                 ;;              (("from PyQt5.QtWebEngineWidgets import QWebEnginePage")
                                 ;;               "#from PyQt5.QtWebEngineWidgets import QWebEnginePage"))
                                 (substitute* "aqt/qt.py"
                                              (("raise Exception\\(\"Your Qt version is known to be broken.\"\\)")
                                               "print(\"The japanease/chinese IME does not work with qt-5.8.0\")")))))))
     (build-system python-build-system)
     (inputs `(("zlib" ,zlib)
               ("qt" ,qt)
               ("pyaudio" ,python-pyaudio)
               ("httplib2" ,python-httplib2)
               ("send2trash" ,python2-send2trash)
               ("bs4",python-beautifulsoup4)
               ("python-requests" ,python-requests)
               ("python-sip" ,python-sip)
               ("python-pyqt" ,python-pyqt)))
     (native-inputs `(("nose" ,python-nose)
                      ("perl" ,perl)))
     (synopsis "Anki flash card repetition gui")
     (description "Graphical program for doing multi media flash card repetitions
 in spaced intervals.")
     (home-page "https://apps.ankiweb.net/")
     (license license:agpl3+))))