Subject: Add fava, a beancount web UI

From: Christopher Lemmer Webber <[email-masked]>
Date: Wed, 08 Apr 2020 13:27:55 -0400

So it turns out fava, a web UI for beancount, is amazing, just amazing.
I recommend everyone use it and switch to it and hug it and tell it how
much they love and appreciate it.  You can see an example version
running here:

  https://fava.pythonanywhere.com/example-beancount-file/income_statement/

I got it "packaged" in the sense that the package works and runs.
However it isn't good enough for Guix yet.

 - Needs to be separated out into separate commits
 - I lost patience with several dependencies' test requirments and
   disabled tests
 - At least one dependency's tests requires a newer pytest.  That's not
   in master yet afaict because, based on this email:
     https://lists.gnu.org/archive/html/guix-devel/2019-10/msg00598.html
   It was waiting for Python 3.8.0 to hit core-updates.  I haven't
   looked yet whether that's happening or not.

I need to get back to other work right now, but figured that it was more
helpful than nothing to leave a "it works, but isn't quite right" patch
on the mailing list before I forgot.

It's really quite close, but I'm drowning in tasks ATM.  Maybe I can
come back to this, though if someone else beat me to it, I wouldn't
complain.

 - Chris

>From 220ab3414adb136d09d603ea96e5b321fe06af2e Mon Sep 17 00:00:00 2001
From: Christopher Lemmer Webber <[email-masked]>
Date: Tue, 7 Apr 2020 16:10:21 -0400
Subject: [PATCH] fava and deps wip

---
 gnu/packages/finance.scm    |  33 ++++
 gnu/packages/python-xyz.scm | 317 ++++++++++++++++++++++++++++++++++++
 2 files changed, 350 insertions(+)

diff --git a/gnu/packages/finance.scm b/gnu/packages/finance.scm
index e666860392..5de5f168b0 100644
--- a/gnu/packages/finance.scm
+++ b/gnu/packages/finance.scm
@@ -1440,3 +1440,36 @@ a Qt GUI.")
 define financial transaction records in a text file, read them in memory,
 generate a variety of reports from them, and provides a web interface.")
     (license license:gpl2)))
+
+(define-public fava
+  (package
+    (name "fava")
+    (version "1.14")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "fava" version))
+       (sha256
+        (base32
+         "181ypq2p7aaq2b76s55hxxbm1hykzf45mjjgm500h4dsaa167dqy"))))
+    (build-system python-build-system)
+    (propagated-inputs
+     `(("beancount" ,beancount)
+       ("python-babel" ,python-babel)
+       ("python-cheroot" ,python-cheroot)
+       ("python-click" ,python-click)
+       ("python-flask" ,python-flask)
+       ("python-flask-babel" ,python-flask-babel)
+       ("python-jinja2" ,python-jinja2)
+       ("python-markdown2" ,python-markdown2)
+       ("python-ply" ,python-ply)
+       ("python-simplejson" ,python-simplejson)
+       ("python-werkzeug" ,python-werkzeug)))
+    (native-inputs
+     `(("python-setuptools-scm" ,python-setuptools-scm)))
+    (home-page "https://beancount.github.io/fava/")
+    (synopsis
+     "Web interface for the accounting tool Beancount.")
+    (description
+     "Web interface for the accounting tool Beancount.")
+    (license license:expat)))
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index d98b38411f..1191f4e780 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -19344,3 +19344,320 @@ an identity provider.  The distribution contains examples of both.
 This package was originally written to work in a WSGI environment, but
 there are extensions that allow you to use it with other frameworks.")
     (license license:asl2.0)))
+
+(define-public python-jaraco-classes
+  (package
+    (name "python-jaraco.classes")
+    (version "3.1.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "jaraco.classes" version))
+       (sha256
+        (base32
+         "1avsxzm5mwylmy2zbxq3xvn48z5djb0qy3hwv4ryncprivzri1n3"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         ;; Not importing the googleapis package for now
+         (add-after 'unpack 'ignore-googleapis
+           (lambda _
+             (substitute* "setup.py"
+               (("'pytest-black-multipy',") ""))
+             #t)))))
+    (propagated-inputs
+     `(("python-more-itertools" ,python-more-itertools)))
+    (native-inputs
+     `(("python-pytest" ,python-pytest)
+       ("python-pytest-checkdocs" ,python-pytest-checkdocs)
+       ("python-pytest-cov" ,python-pytest-cov)
+       ("python-pytest-flake8" ,python-pytest-flake8)
+       ("python-setuptools-scm" ,python-setuptools-scm)))
+    (home-page
+     "https://github.com/jaraco/jaraco.classes")
+    (synopsis
+     "Utility functions for Python class constructs")
+    (description
+     "Utility functions for Python class constructs")
+    (license #f)))
+
+(define-public python-jaraco-functools
+  (package
+    (name "python-jaraco-functools")
+    (version "3.0.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "jaraco.functools" version))
+       (sha256
+        (base32
+         "15vd7x4jillggb8xcg3cm00j1v6llhl16r0rqm0l4n2lyahfxc2w"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         ;; Not importing the googleapis package for now
+         (add-after 'unpack 'ignore-googleapis
+           (lambda _
+             (substitute* "setup.py"
+               (("'pytest-black-multipy',") ""))
+             #t)))))
+    (propagated-inputs
+     `(("python-more-itertools" ,python-more-itertools)))
+    (native-inputs
+     `(("python-mock" ,python-mock)
+       ("python-jaraco-classes" ,python-jaraco-classes)
+       ("python-pytest" ,python-pytest)
+       ("python-pytest-checkdocs"
+        ,python-pytest-checkdocs)
+       ("python-pytest-cov" ,python-pytest-cov)
+       ("python-pytest-flake8" ,python-pytest-flake8)
+       ("python-six" ,python-six)
+       ("python-setuptools-scm" ,python-setuptools-scm)))
+    (home-page
+     "https://github.com/jaraco/jaraco.functools")
+    (synopsis "Functools like those found in stdlib")
+    (description
+     "Functools like those found in stdlib")
+    (license #f)))
+
+(define-public python-jaraco-text
+  (package
+    (name "python-jaraco-text")
+    (version "3.2.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "jaraco.text" version))
+       (sha256
+        (base32
+         "1v0hz3h74m31jlbc5bxwkvrx1h2n7887bajrg1n1c3yc4q8qn1z5"))))
+    (build-system python-build-system)
+    (propagated-inputs
+     `(("python-jaraco-functools" ,python-jaraco-functools)
+       ("python-six" ,python-six)))
+    (native-inputs
+     `(("python-setuptools-scm" ,python-setuptools-scm)
+       ("python-pytest" ,python-pytest)
+       ("python-pytest-checkdocs"
+        ,python-pytest-checkdocs)
+       ("python-pytest-cov" ,python-pytest-cov)
+       ("python-pytest-flake8" ,python-pytest-flake8)))
+    (home-page
+     "https://github.com/jaraco/jaraco.text")
+    (synopsis "Module for text manipulation")
+    (description "Module for text manipulation")
+    (license #f)))
+
+(define-public python-pytest-testmon
+  (package
+    (name "python-pytest-testmon")
+    (version "1.0.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "pytest-testmon" version))
+       (sha256
+        (base32
+         "1iasz23zrzjgbak8jiq12i4zmkk8f6dmcdhfxz8m2q03agcidc7x"))))
+    (build-system python-build-system)
+    (propagated-inputs
+     `(("python-coverage" ,python-coverage)
+       ("python-pytest" ,python-pytest)))
+    (home-page "https://testmon.org")
+    (synopsis
+     "selects tests affected by changed files and methods")
+    (description
+     "selects tests affected by changed files and methods")
+    (license #f)))
+
+(define-public python-pytest-watch
+  (package
+    (name "python-pytest-watch")
+    (version "4.2.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "pytest-watch" version))
+       (sha256
+        (base32
+         "1fflnd3varpqy8yzcs451n8h7wmjyx1408qdin5p2qdksl1ny4q6"))))
+    (build-system python-build-system)
+    (propagated-inputs
+     `(("python-colorama" ,python-colorama)
+       ("python-docopt" ,python-docopt)
+       ("python-pytest" ,python-pytest)
+       ("python-watchdog" ,python-watchdog)))
+    (home-page
+     "http://github.com/joeyespo/pytest-watch")
+    (synopsis
+     "Local continuous test runner with pytest and watchdog.")
+    (description
+     "Local continuous test runner with pytest and watchdog.")
+    (license license:expat)))
+
+(define-public python-requests-unixsocket
+  (package
+    (name "python-requests-unixsocket")
+    (version "0.2.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "requests-unixsocket" version))
+       (sha256
+        (base32
+         "1sn12y4fw1qki5gxy9wg45gmdrxhrndwfndfjxhpiky3mwh1lp4y"))))
+    ;; why tied to waitress==0.9.0 I have no idea
+    (arguments
+     ;; We don't have all the test deps yet... missing pyttest-cache
+     `(#:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         ;; Not importing the googleapis package for now
+         (add-after 'unpack 'ignore-googleapis
+           (lambda _
+             (delete-file "test-requirements.txt")
+             #t)))))
+    (build-system python-build-system)
+    (propagated-inputs
+     `(("python-requests" ,python-requests)
+       ("python-urllib3" ,python-urllib3)))
+    (native-inputs
+     `(("python-pbr-minimal" ,python-pbr-minimal)
+
+       ;; ("python-waitress" ,python-waitress)
+       ;; ("python-pep8" ,python-pep8)
+       ;; ("python-apipkg" ,python-apipkg)
+       ;; ("python-appdirs" ,python-appdirs)
+       ;; ("python-execnet" ,python-execnet)
+       ;; ("python-packaging" ,python-packaging)
+       ;; ("python-py" ,python-py)
+       ;; ("python-pyparsing" ,python-pyparsing))
+     ))
+    (home-page
+     "https://github.com/msabramo/requests-unixsocket")
+    (synopsis
+     "Use requests to talk HTTP via a UNIX domain socket")
+    (description
+     "Use requests to talk HTTP via a UNIX domain socket")
+    (license #f)))
+
+(define-public python-trustme
+  (package
+    (name "python-trustme")
+    (version "0.6.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "trustme" version))
+       (sha256
+        (base32
+         "0v3vr5z6apnfmklf07m45kv5kaqvm6hxrkaqywch57bjd2siiywx"))))
+    (build-system python-build-system)
+    (propagated-inputs
+     `(("python-cryptography" ,python-cryptography)
+       ("python-idna" ,python-idna)))
+    (home-page
+     "https://github.com/python-trio/trustme")
+    (synopsis
+     "#1 quality TLS certs while you wait, for the discerning tester")
+    (description
+     "#1 quality TLS certs while you wait, for the discerning tester")
+    (license #f)))
+
+#;(define-public python-pytest-black-multipy
+  (package
+    (name "python-pytest-black-multipy")
+    (version "1.0.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "pytest-black-multipy" version))
+       (sha256
+        (base32
+         "1ciwa99fnz3ngbsvcjvxqz4k1vwfmvpxaj7qf5vxkx0awvczhsyd"))))
+    (build-system python-build-system)
+    (native-inputs
+     `(("python-pytest" ,python-pytest)
+       ("python-pytest-checkdocs"
+        ,python-pytest-checkdocs)
+       ("python-pytest-flake8" ,python-pytest-flake8)))
+    (home-page "https://github.com/jaraco/skeleton")
+    (synopsis "Allow '--black' on older Pythons")
+    (description "Allow '--black' on older Pythons")
+    (license #f)))
+
+(define-public python-cheroot
+  (package
+    (name "python-cheroot")
+    (version "8.3.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "cheroot" version))
+       (sha256
+        (base32
+         "0cc9cb5via001zkna0i2qp5s0bn1w327q6k7fba2f5v650gpwmx0"))))
+    (build-system python-build-system)
+    (propagated-inputs
+     `(("python-jaraco-functools" ,python-jaraco-functools)
+       ("python-more-itertools" ,python-more-itertools)
+       ("python-six" ,python-six)))
+    (arguments
+     ;; needs a newer pytest :\
+     `(#:tests? #f
+       ;; So we're also kicking out the dependency giving us
+       ;; trouble...
+       #:phases
+       (modify-phases %standard-phases
+         ;; Not importing the googleapis package for now
+         (add-after 'unpack 'ignore-googleapis
+           (lambda _
+             (substitute* "setup.py"
+               (("'python-pytest-testmon',") ""))
+             #t)))))
+    (native-inputs
+     `(("python-codecov" ,python-codecov)
+       ("python-colorama" ,python-colorama)
+       ("python-coverage" ,python-coverage)
+       ("python-jaraco-text" ,python-jaraco-text)
+       ("python-pyopenssl" ,python-pyopenssl)
+       ("python-pytest" ,python-pytest)
+       ("python-pytest-cov" ,python-pytest-cov)
+       ("python-pytest-mock" ,python-pytest-mock)
+       ("python-pytest-sugar" ,python-pytest-sugar)
+       ; ("python-pytest-testmon" ,python-pytest-testmon)
+       ("python-pytest-watch" ,python-pytest-watch)
+       ("python-pytest-xdist" ,python-pytest-xdist)
+       ("python-requests-unixsocket"
+        ,python-requests-unixsocket)
+       ("python-trustme" ,python-trustme)
+       ("python-urllib3" ,python-urllib3)
+       ("python-setuptools-scm-git-archive" ,python-setuptools-scm-git-archive)))
+    (home-page "https://cheroot.cherrypy.org")
+    (synopsis
+     "Highly-optimized, pure-python HTTP server")
+    (description
+     "Highly-optimized, pure-python HTTP server")
+    (license #f)))
+
+(define-public python-markdown2
+  (package
+    (name "python-markdown2")
+    (version "2.3.8")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "markdown2" version))
+       (sha256
+        (base32
+         "1gjxy3j7qgl0fzmdqd0jx0gv13s1z9n1g3fd3s72rh4nnc08xy3z"))))
+    (build-system python-build-system)
+    (home-page
+     "https://github.com/trentm/python-markdown2")
+    (synopsis
+     "A fast and complete Python implementation of Markdown")
+    (description
+     "A fast and complete Python implementation of Markdown")
+    (license license:expat)))
-- 
2.26.0