Subject: [PATCH v3 21/21] gnu: Add octoprint.

From: Vinicius Monego <[email-masked]>
Date: Mon, 27 Dec 2021 23:30:44 +0000

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

diff --git a/gnu/packages/printers.scm b/gnu/packages/printers.scm
index 546a808452..cea7f4e6e9 100644
--- a/gnu/packages/printers.scm
+++ b/gnu/packages/printers.scm
@@ -25,10 +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 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 python-web))
+  #:use-module (gnu packages web))
 
 ;; This is a module for packages related to printer-like devices, but not
 ;; related to CUPS.
@@ -109,6 +114,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.2")
+    (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 "0zvjnbcmszifvr02rsmfzb5v24f1ss8klrnkd9fcg2351nkpqbbd"))
+       (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"
+               (("cachelib>=0.1,<0.2") "cachelib>=0.1")
+               (("colorlog>=5.0.1,<6") "colorlog>=5.0.1")
+               (("flask>=1.1.4,<2") "flask>=1.1.4")
+               (("itsdangerous>=1.1.0,<2") "itsdangerous>=1.1.0")
+               (("Jinja2>=2.11.3,<3") "Jinja2>=2.11.3")
+               (("markdown>=3.1,<3.2") "markdown>=3.1,<4")
+               (("markupsafe>=1.1,<2.0") "markupsafe>=1.1")
+               (("sarge==0.1.6") "sarge>=0.1.6")
+               (("watchdog==0.10.4") "watchdog>=0.10.4")
+               (("werkzeug>=1.0.1,<2") "werkzeug>=1.0.1")
+               (("wrapt>=1.12.1,<1.13") "wrapt>=1.12.1")
+               (("zeroconf>=0.33,<0.34") "zeroconf>=0.33"))))
+         (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
+     (list python-ddt python-mock python-pytest python-pytest-doctest-custom))
+    (inputs
+     (list octoprint-filecheck
+           octoprint-firmwarecheck
+           octoprint-pisupport
+           python-appdirs
+           python-blinker
+           python-cachelib
+           python-click
+           python-colorlog
+           python-emoji
+           python-feedparser
+           python-filetype
+           python-flask
+           python-flask-assets
+           python-flask-babel
+           python-flask-login
+           python-future
+           python-immutabledict
+           python-itsdangerous
+           python-jinja2
+           python-markdown
+           python-markupsafe
+           python-netaddr
+           python-netifaces
+           python-pathvalidate
+           python-pkginfo
+           python-psutil
+           python-pylru
+           python-pyserial
+           python-pyyaml
+           python-regex
+           python-requests
+           python-sarge
+           python-semantic-version
+           python-sentry-sdk
+           python-tornado-6
+           python-unidecode
+           python-watchdog
+           python-websocket-client
+           python-werkzeug
+           python-wrapt
+           python-zeroconf
+           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