Subject: Re: [PATCHES] Add python-sanic and dependencies.

From: Lars-Dominik Braun <[email-masked]>
Date: Fri, 13 Nov 2020 09:59:14 +0100

Hi,

> I managed to package sanic following your channel definition (and enabled
> tests), I updated some packages, removed some other packages that were
> already merged in Guix and produced an updated patch set.
I’ve tested the patches with a real application and made some minor
modifications pointed out by `guix lint`. Also python-sanic requests
multidict==5.0.0, which we don’t have right now. But it seems to work with
4.7.5 just fine.

Cheers,
Lars

-- 
Lars-Dominik Braun
Wissenschaftlicher Mitarbeiter/Research Associate

www.leibniz-psychology.org
ZPID - Leibniz-Institut für Psychologie /
ZPID - Leibniz Institute for Psychology
Universitätsring 15
D-54296 Trier - Germany
Tel.: +49–651–201-4964
From a9d80c2beee8dfcff1a5c8b23a1acdcab89b267b Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <[email-masked]>
Date: Mon, 8 Jun 2020 23:57:19 +0200
Subject: [PATCH 01/10] gnu: Add python-contextvars.

* gnu/packages/python-xyz.scm (python-contextvars): New variable.
---
 gnu/packages/python-xyz.scm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index e5b8db02e0..3284128d79 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -22672,3 +22672,24 @@ applications with variable CPU loads).")
 
 (define-public python2-parallel
   (package-with-python2 python-parallel))
+
+(define-public python-contextvars
+  (package
+    (name "python-contextvars")
+    (version "2.4")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (pypi-uri "contextvars" version))
+        (sha256
+          (base32
+            "17n3w8c20kgkgc6khaafdhhlcdj4bzman4paxqsl7harma59137k"))))
+    (build-system python-build-system)
+    (propagated-inputs
+      `(("python-immutables" ,python-immutables)))
+    (home-page
+      "https://github.com/MagicStack/contextvars")
+    (synopsis "PEP 567 Backport")
+    (description "This package implements a backport of Python 3.7
+@code{contextvars} module (see PEP 567) for Python 3.6.")
+    (license license:asl2.0)))
-- 
2.26.2

From cd1d8c98637f43c386d51a74e2508ac25ae4b2e0 Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <[email-masked]>
Date: Tue, 9 Jun 2020 17:40:32 +0200
Subject: [PATCH 02/10] gnu: Add python-aiofiles.

* gnu/packages/python-xyz.scm (python-aiofiles): New variable.
---
 gnu/packages/python-xyz.scm | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 3284128d79..77b7222959 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -22693,3 +22693,21 @@ applications with variable CPU loads).")
     (description "This package implements a backport of Python 3.7
 @code{contextvars} module (see PEP 567) for Python 3.6.")
     (license license:asl2.0)))
+
+(define-public python-aiofiles
+  (package
+    (name "python-aiofiles")
+    (version "0.5.0")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (pypi-uri "aiofiles" version))
+        (sha256
+          (base32
+            "1bqmv019x16qa3zah0z915cw6z4va3fjs60fk2s7vyah3gyvrrlq"))))
+    (build-system python-build-system)
+    (home-page "https://github.com/Tinche/aiofiles")
+    (synopsis "File support for @code{asyncio}")
+    (description "@code{python-aiofiles} is a library for handling local
+disk files in asyncio applications.")
+    (license license:asl2.0)))
-- 
2.26.2

From dda0406a4e36565ef241003104cb54c552df5577 Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <[email-masked]>
Date: Tue, 20 Oct 2020 12:37:54 +0200
Subject: [PATCH 03/10] gnu: Add python-hstspreload.

* gnu/packages/python-web.scm (python-hstspreload): New variable.
---
 gnu/packages/python-web.scm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/gnu/packages/python-web.scm b/gnu/packages/python-web.scm
index e9dde499d5..37c5980dc2 100644
--- a/gnu/packages/python-web.scm
+++ b/gnu/packages/python-web.scm
@@ -5194,3 +5194,24 @@ over IMAP:
 @item Work with mailbox folders (list, set, get, create, exists, rename, delete, status)
 @end itemize")
     (license license:asl2.0)))
+
+(define-public python-hstspreload
+  (package
+    (name "python-hstspreload")
+    (version "2020.10.20")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "hstspreload" version))
+       (sha256
+        (base32
+         "1qah80p2xlib1rhivvdj9v5y3girxrj7dwp1mnh8mwaj5wy32y8a"))))
+    (build-system python-build-system)
+    (home-page
+     "https://github.com/sethmlarson/hstspreload")
+    (synopsis
+     "Chromium HSTS Preload list as a Python package")
+    (description
+     "@code{python-hstspreload} contains Chromium HSTS Preload list
+as a Python package.")
+    (license license:bsd-3)))
-- 
2.26.2

From c835de22832e8c7fb33cf6eec1aa0afb029253ca Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <[email-masked]>
Date: Tue, 9 Jun 2020 19:06:02 +0200
Subject: [PATCH 04/10] gnu: Add python-mypy-extensions.

* gnu/packages/python-xyz.scm (python-mypy-extensions): New variable.
---
 gnu/packages/python-xyz.scm | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 77b7222959..6f13c730bd 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -22711,3 +22711,25 @@ applications with variable CPU loads).")
     (description "@code{python-aiofiles} is a library for handling local
 disk files in asyncio applications.")
     (license license:asl2.0)))
+
+(define-public python-mypy-extensions
+  (package
+    (name "python-mypy-extensions")
+    (version "0.4.3")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "mypy-extensions" version))
+       (sha256
+        (base32
+         "1a04qsk8hd1lqns8w1j7cr0vmvbhg450di5k1i16kqxkbf7q30id"))))
+    (build-system python-build-system)
+    (home-page
+     "https://github.com/python/mypy_extensions")
+    (synopsis
+     "Experimental type system extensions for mypy")
+    (description
+     "@code{python-mypy-extensions} defines experimental extensions
+to the standard @code{typing} module that are supported by the
+@code{mypy} typechecker.")
+    (license license:expat)))
-- 
2.26.2

From 1f021271add8115a03f1645d5e02c6a664360225 Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <[email-masked]>
Date: Wed, 10 Jun 2020 12:52:20 +0200
Subject: [PATCH 05/10] gnu: Add python-pyre-extensions.

* gnu/packages/python-xyz.scm (python-pyre-extensions): New variable.
---
 gnu/packages/python-xyz.scm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 6f13c730bd..a1ae408c82 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -22733,3 +22733,27 @@ disk files in asyncio applications.")
 to the standard @code{typing} module that are supported by the
 @code{mypy} typechecker.")
     (license license:expat)))
+
+(define-public python-pyre-extensions
+  (package
+    (name "python-pyre-extensions")
+    (version "0.0.18")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (pypi-uri "pyre-extensions" version))
+        (sha256
+          (base32
+            "0c5cbbqrfyjwakdh3kbwxis6mbrbwky1z1fqslgszgpcj4g43q30"))))
+    (build-system python-build-system)
+    (propagated-inputs
+      `(("python-typing-extensions"
+         ,python-typing-extensions)
+        ("python-typing-inspect" ,python-typing-inspect)))
+    (home-page "https://pyre-check.org")
+    (synopsis
+     "Type system extensions for use with @code{python-pyre}")
+    (description
+      "@code{python-pyre-extensions} defines extensions to the standard
+@code{typing} module that are supported by the Pyre typechecker.")
+    (license license:expat)))
-- 
2.26.2

From 22e6e518b43feab5082618de8c53f72fab1b90ca Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <[email-masked]>
Date: Tue, 20 Oct 2020 12:43:17 +0200
Subject: [PATCH 06/10] gnu: Add python-nbsphinx.

* gnu/packages/sphinx.scm (python-nbsphinx): New variable.
---
 gnu/packages/sphinx.scm | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/gnu/packages/sphinx.scm b/gnu/packages/sphinx.scm
index ac506ecbe5..5172f246a1 100644
--- a/gnu/packages/sphinx.scm
+++ b/gnu/packages/sphinx.scm
@@ -13,6 +13,7 @@
 ;;; Copyright © 2019 Nicolas Goaziou <[email-masked]>
 ;;; Copyright © 2019 Alexandros Theodotou <[email-masked]>
 ;;; Copyright © 2019 Brett Gilio <[email-masked]>
+;;; Copyright © 2020 Giacomo Leidi <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -642,3 +643,32 @@ translate and to apply translation to Sphinx generated document.")
 documentation when a change is detected.  It also includes a livereload
 enabled web server.")
     (license license:expat)))
+
+(define-public python-nbsphinx
+  (package
+    (name "python-nbsphinx")
+    (version "0.7.1")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (pypi-uri "nbsphinx" version))
+        (sha256
+          (base32
+            "0j56bxdj08vn3q1804qwb1ywhga1mdg1awgm7i64wfpfwi8df2zm"))))
+    (build-system python-build-system)
+    (propagated-inputs
+      `(("python-docutils" ,python-docutils)
+        ("python-jinja2" ,python-jinja2)
+        ("python-nbconvert" ,python-nbconvert)
+        ("python-nbformat" ,python-nbformat)
+        ("python-sphinx" ,python-sphinx)
+        ("python-traitlets" ,python-traitlets)))
+    (home-page "https://nbsphinx.readthedocs.io/")
+    (synopsis "Jupyter Notebook Tools for Sphinx")
+    (description "@code{python-nbsphinx} is a Sphinx extension that
+provides a source parser for @code{*.ipynb} files.  Custom Sphinx
+directives are used to show Jupyter Notebook code cells (and of course
+their results) in both HTML and LaTeX output.  Un-evaluated notebooks
+- i.e. notebooks without stored output cells - will be automatically
+executed during the Sphinx build process.")
+    (license license:expat)))
-- 
2.26.2

From 4c17f3615e43e5cbeae80898a649535232923aea Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <[email-masked]>
Date: Wed, 10 Jun 2020 17:00:25 +0200
Subject: [PATCH 07/10] gnu: Add python-dataclasses.

* gnu/packages/python-xyz.scm (python-dataclasses): New variable.
---
 gnu/packages/python-xyz.scm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index a1ae408c82..17c38ec5aa 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -22757,3 +22757,24 @@ to the standard @code{typing} module that are supported by the
       "@code{python-pyre-extensions} defines extensions to the standard
 @code{typing} module that are supported by the Pyre typechecker.")
     (license license:expat)))
+
+(define-public python-dataclasses
+  (package
+    (name "python-dataclasses")
+    (version "0.7")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (pypi-uri "dataclasses" version))
+        (sha256
+          (base32
+            "1rh8111fbws2vxyf2qy2zw3x6p6cq1jfz8pf904gig5qwg56sjj9"))))
+    (build-system python-build-system)
+    (home-page
+      "https://github.com/ericvsmith/dataclasses")
+    (synopsis
+      "Backport of the @code{dataclasses} module for Python 3.6")
+    (description
+      "This is an implementation of PEP 557, Data Classes.  It is a
+backport of the @code{dataclasses} module for Python 3.6.")
+    (license license:asl2.0)))
-- 
2.26.2

From a726b42ccf10f8ee08ff5fab5049990d3a0080c8 Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <[email-masked]>
Date: Wed, 10 Jun 2020 17:58:58 +0200
Subject: [PATCH 08/10] gnu: Add python-pywatchman.

* gnu/packages/python-xyz.scm (python-pywatchman): New variable.
---
 gnu/packages/python-xyz.scm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 17c38ec5aa..fb5c117aa8 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -22778,3 +22778,24 @@ to the standard @code{typing} module that are supported by the
       "This is an implementation of PEP 557, Data Classes.  It is a
 backport of the @code{dataclasses} module for Python 3.6.")
     (license license:asl2.0)))
+
+(define-public python-pywatchman
+  (package
+    (name "python-pywatchman")
+    (version "1.4.1")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (pypi-uri "pywatchman" version))
+        (sha256
+          (base32
+            "1yf2gm20wc3djpb5larxii3l55xxby0il2ns3q0v1byyfnr7w16h"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:tests? #f)) ;there are none
+    (home-page
+      "https://facebook.github.io/watchman/")
+    (synopsis "Watchman client for python")
+    (description "@code{python-pywatchman} is a library to connect and
+query Watchman to discover file changes.")
+    (license license:bsd-3)))
-- 
2.26.2

From fe0fe1a37494f1894e2425dad2a239c557cf9925 Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <[email-masked]>
Date: Fri, 13 Nov 2020 09:54:01 +0100
Subject: [PATCH 09/10] gnu: Add python-pytest-sanic.

* gnu/packages/python-check.scm (python-pytest-sanic): New variable.
---
 gnu/packages/python-check.scm | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gnu/packages/python-check.scm b/gnu/packages/python-check.scm
index dcd4bb90d8..314ca5795c 100644
--- a/gnu/packages/python-check.scm
+++ b/gnu/packages/python-check.scm
@@ -1078,3 +1078,31 @@ any Python VM with basically no runtime overhead.")
     (description "Robber is a Python assertion library for test-driven and
 behavior-driven development (TDD and BDD).")
     (license license:expat)))
+
+;; This is only used by python-sanic
+(define-public python-pytest-sanic
+  (package
+    (name "python-pytest-sanic")
+    (version "1.6.2")
+    (source
+    (origin
+      (method url-fetch)
+      (uri (pypi-uri "pytest-sanic" version))
+      (sha256
+        (base32
+          "02ajd8z77ahi69kzkz200qgxrb4s2j4qb6k8j9ds1kz6qa6fsa34"))))
+    (build-system python-build-system)
+    (arguments
+     ;; Tests depend on python-sanic.
+     `(#:tests? #f))
+    (propagated-inputs
+      `(("python-aiohttp" ,python-aiohttp)
+        ("python-async-generator"
+         ,python-async-generator)
+        ("python-pytest" ,python-pytest)))
+    (home-page
+      "https://github.com/yunstanford/pytest-sanic")
+    (synopsis "Pytest plugin for Sanic")
+    (description "A pytest plugin for Sanic.  It helps you to test your
+code asynchronously.")
+    (license license:expat)))
-- 
2.26.2

From 34bba96451cb29cb38706d04f7703301b1ae7dd7 Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <[email-masked]>
Date: Fri, 13 Nov 2020 09:55:19 +0100
Subject: [PATCH 10/10] gnu: Add python-sanic.

* gnu/packages/python-web.scm (python-sanic): New variable.
---
 gnu/packages/python-web.scm | 60 +++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/gnu/packages/python-web.scm b/gnu/packages/python-web.scm
index 37c5980dc2..958cbd5323 100644
--- a/gnu/packages/python-web.scm
+++ b/gnu/packages/python-web.scm
@@ -39,6 +39,7 @@
 ;;; Copyright © 2020 Edouard Klein <[email-masked]>
 ;;; Copyright © 2020 Vinicius Monego <[email-masked]>
 ;;; Copyright © 2020 Konrad Hinsen <[email-masked]>
+;;; Copyright © 2020 Giacomo Leidi <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -5215,3 +5216,62 @@ over IMAP:
      "@code{python-hstspreload} contains Chromium HSTS Preload list
 as a Python package.")
     (license license:bsd-3)))
+
+(define-public python-sanic
+  (package
+    (name "python-sanic")
+    (version "20.9.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "sanic" version))
+       (sha256
+        (base32
+         "06p0lsxqbfbka2yaqlpp0bg5pf7ma44zi6kq7qbb6hhry48dp1w6"))))
+    (build-system python-build-system)
+    (arguments
+     '(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'use-recent-pytest
+           ;; Allow using recent dependencies.
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* "setup.py"
+               (("httpcore==0.3.0") "httpcore")
+               (("pytest==5.2.1") "pytest")
+               (("multidict==5.0.0") "multidict"))
+             #t))
+         (replace 'check
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (add-installed-pythonpath inputs outputs)
+             (invoke "pytest" "-vv" "./tests" "-k"
+                     "not test_zero_downtime and not test_gunicorn_worker"))))))
+    (propagated-inputs
+     `(("python-aiofiles" ,python-aiofiles)
+       ("python-httptools" ,python-httptools)
+       ("python-httpx" ,python-httpx)
+       ("python-multidict" ,python-multidict)
+       ("python-ujson" ,python-ujson)
+       ("python-uvloop" ,python-uvloop)
+       ("python-websockets" ,python-websockets)))
+    (native-inputs
+     `(("gunicorn" ,gunicorn)
+       ("python-beautifulsoup4" ,python-beautifulsoup4)
+       ("python-hstspreload" ,python-hstspreload)
+       ("python-httpcore" ,python-httpcore)
+       ("python-pytest" ,python-pytest)
+       ("python-pytest-cov" ,python-pytest-cov)
+       ("python-pytest-benchmark" ,python-pytest-benchmark)
+       ("python-pytest-sanic" ,python-pytest-sanic)
+       ("python-pytest-sugar" ,python-pytest-sugar)
+       ("python-urllib3" ,python-urllib3)
+       ("python-uvicorn" ,python-uvicorn)))
+    (home-page
+     "https://github.com/huge-success/sanic/")
+    (synopsis
+     "Async Python 3.6+ web server/framework")
+    (description
+     "Sanic is a Python 3.6+ web server and web framework
+that's written to go fast.  It allows the usage of the
+@code{async/await} syntax added in Python 3.5, which makes
+your code non-blocking and speedy.")
+    (license license:expat)))
-- 
2.26.2