Subject: [PATCH 29/29] gnu: Add octoprint.

From: Vinicius Monego <[email-masked]>
Date: Thu, 21 Oct 2021 04:02:00 +0000

* gnu/packages/printers.scm (octoprint): New variable.
---
 gnu/packages/printers.scm | 115 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 114 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/printers.scm b/gnu/packages/printers.scm
index 4056a66ad3..37e1734aad 100644
--- a/gnu/packages/printers.scm
+++ b/gnu/packages/printers.scm
@@ -25,9 +25,15 @@
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (gnu packages check)
   #:use-module (gnu packages libusb)
   #:use-module (gnu packages pkg-config)
-  #:use-module (gnu packages qt))
+  #:use-module (gnu packages python)
+  #:use-module (gnu packages python-check)
+  #:use-module (gnu packages python-web)
+  #:use-module (gnu packages python-xyz)
+  #:use-module (gnu packages qt)
+  #:use-module (gnu packages web))
 
 ;; This is a module for packages related to printer-like devices, but not
 ;; related to CUPS.
@@ -95,6 +101,113 @@ uploaded files that are known to cause issues while printing and which in
 the past have caused support requests on OctoPrint's Community Forums.")
     (license license:agpl3)))
 
+(define-public octoprint
+  (package
+    (name "octoprint")
+    (version "1.7.0")
+    (source
+     (origin
+       (method git-fetch) ; no tests in the PyPI tarball.
+       (uri (git-reference
+             (url "https://github.com/OctoPrint/OctoPrint")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "08a1in2kbgy4w02q2xkhp7m09mvw0hxn3fgcbi1z7f6hg8ibym9n"))
+       (modules '((guix build utils)))
+       (snippet
+        '(begin
+           ;; Remove bundled font-awesome.
+           (delete-file-recursively "src/octoprint/static/vendor")
+           #t))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'relax-version-requirements
+           ;; Octoprint maintains strict version requirements for Python2
+           ;; compatibility.  We're not packaging with Python2, so modify
+           ;; setup.py to relax those versions.  Octoprint will drop Python2
+           ;; support in version 2.0 so we won't need this change after it.
+           (lambda _
+             (substitute* "setup.py"
+               (("markdown>=3.1,<3.2") "markdown>=3.1,<4")
+               (("watchdog==0.10.4") "watchdog>=0.10.4")
+               ;; Relax core packages that are outdated in Guix.
+               (("Jinja2>=2.11.3,<3") "Jinja2>=2.11.2,<3")
+               (("requests>=2.26.0,<3") "requests>=2.25,<3"))))
+         (add-before 'check 'set-home
+           (lambda _
+             (setenv "HOME" (getcwd)))) ; some tests need a writable home
+         (replace 'check
+           (lambda* (#:key inputs outputs tests? #:allow-other-keys)
+             (when tests?
+               (add-installed-pythonpath inputs outputs)
+               (invoke "python" "-m" "pytest" "tests" "-k"
+                       (string-append
+                        ;; These tests try to write to the source tree and
+                        ;; fail with PermissionError.
+                        "not test_add_file_overwrite"
+                        " and not test_set_external_modification"))))))))
+    (native-inputs
+     `(("python-ddt" ,python-ddt)
+       ("python-mock" ,python-mock)
+       ("python-pytest" ,python-pytest)
+       ("python-pytest-doctest-custom"
+        ,python-pytest-doctest-custom)))
+    (inputs
+     `(("octoprint-filecheck" ,octoprint-filecheck)
+       ("octoprint-firmwarecheck" ,octoprint-firmwarecheck)
+       ("octoprint-pisupport" ,octoprint-pisupport)
+       ("python-appdirs" ,python-appdirs)
+       ("python-blinker" ,python-blinker)
+       ("python-cachelib" ,python-cachelib)
+       ("python-click" ,python-click)
+       ("python-colorlog" ,python-colorlog)
+       ("python-emoji" ,python-emoji)
+       ("python-feedparser" ,python-feedparser)
+       ("python-filetype" ,python-filetype)
+       ("python-flask" ,python-flask)
+       ("python-flask-assets" ,python-flask-assets)
+       ("python-flask-babel" ,python-flask-babel)
+       ("python-flask-login" ,python-flask-login)
+       ("python-future" ,python-future)
+       ("python-immutabledict" ,python-immutabledict)
+       ("python-itsdangerous" ,python-itsdangerous)
+       ("python-jinja2" ,python-jinja2)
+       ("python-markdown" ,python-markdown)
+       ("python-markupsafe" ,python-markupsafe)
+       ("python-netaddr" ,python-netaddr)
+       ("python-netifaces" ,python-netifaces)
+       ("python-pathvalidate" ,python-pathvalidate)
+       ("python-pkginfo" ,python-pkginfo)
+       ("python-psutil" ,python-psutil)
+       ("python-pylru" ,python-pylru)
+       ("python-pyserial" ,python-pyserial)
+       ("python-pyyaml" ,python-pyyaml)
+       ("python-regex" ,python-regex)
+       ("python-requests" ,python-requests)
+       ("python-sarge" ,python-sarge)
+       ("python-semantic-version"
+        ,python-semantic-version)
+       ("python-sentry-sdk" ,python-sentry-sdk)
+       ("python-tornado" ,python-tornado-6)
+       ("python-unidecode" ,python-unidecode)
+       ("python-watchdog" ,python-watchdog)
+       ("python-websocket-client"
+        ,python-websocket-client)
+       ("python-werkzeug" ,python-werkzeug)
+       ("python-wrapt" ,python-wrapt)
+       ("python-zeroconf" ,python-zeroconf)
+       ("python-zipstream-new" ,python-zipstream-new)))
+    (home-page "https://octoprint.org")
+    (synopsis "Web interface for 3D printers")
+    (description "OctoPrint provides a snappy web interface for controlling
+consumer 3D printers.")
+    ;; The web interface contains many third party JavaScript libraries under
+    ;; different licenses.  Check THIRDPARTYLICENSES.md.
+    (license license:agpl3)))
+
 (define-public robocut
   (package
     (name "robocut")
-- 
2.30.2