Subject: [PATCH v3 1/2] gnu: Add python-xdg.

From: phodina <[email-masked]>
Date: Tue, 15 Feb 2022 14:37:10 +0000

Hi,

here are updated patches based on the review. Also I manged to fix the issues in the sanity-check phase.

However, there are still some points to be solved
https://github.com/MycroftAI/mycroft-core/issues/3074 as the ALSA lib error blocks the tests. I also don't know how to mock the audio subsystem in tests properly.

FIY I renamed the package from python-mycroft-core to mycroft-core and move it to gnu/packages/speech.scm as this IMHO reflect more the purpose of this package.

Python module xdg was added as it's referenced in the code.

----
Petr

From c5a8653641595e549369a9ff008194a4a749f98e Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
Date: Tue, 15 Feb 2022 09:07:15 +0100
Subject: [PATCH v3 1/2] gnu: Add python-xdg.

* gnu/packages/python-xyz.scm (python-xdg): New variable.

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index feab9c7b50..d95fc12465 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -14511,6 +14511,23 @@ (define-public python-pyfiglet
 in pure Python.")
     (license license:expat)))
 
+(define-public python-xdg
+  (package
+    (name "python-xdg")
+    (version "5.1.1")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (pypi-uri "xdg" version))
+        (sha256
+          (base32 "0v6hmhjqlc6km284lr14kc4h5rl6xva231q1lsr8hq7crhk9yqda"))))
+    (build-system python-build-system)
+    (home-page "https://github.com/srstevenson/xdg")
+    (synopsis "Implementation of the XDG Base Directory Specification")
+    (description "This package provides implementation of the XDG Base Directory
+Specification.")
+    (license license:isc)))
+
 (define-public python-xdo
   (package
     (name "python-xdo")
-- 
2.34.0

From 25a9106faf2d9bd34fb48b689d39232a01a90cba Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
Date: Fri, 30 Jul 2021 17:21:07 +0200
Subject: [PATCH v3 2/2] gnu: Add mycroft-core.

* gnu/packages/speech.scm (mycroft-core): New variable.

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index d95fc12465..020855fb2a 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -210,6 +210,7 @@ (define-module (gnu packages python-xyz)
   #:use-module (gnu packages search)
   #:use-module (gnu packages serialization)
   #:use-module (gnu packages shells)
+  #:use-module (gnu packages speech)
   #:use-module (gnu packages sphinx)
   #:use-module (gnu packages ssh)
   #:use-module (gnu packages swig)
diff --git a/gnu/packages/speech.scm b/gnu/packages/speech.scm
index 98b6ebffe2..1851728d72 100644
--- a/gnu/packages/speech.scm
+++ b/gnu/packages/speech.scm
@@ -8,7 +8,7 @@
 ;;; Copyright © 2020 Nicolas Goaziou <[email-masked]>
 ;;; Copyright © 2020 Efraim Flashner <[email-masked]>
 ;;; Copyright © 2021 qblade <[email-masked]>
-;;; Copyright © 2021 Petr Hodina <[email-masked]>
+;;; Copyright © 2021, 2022 Petr Hodina <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -32,28 +32,43 @@ (define-module (gnu packages speech)
   #:use-module (guix git-download)
   #:use-module (guix utils)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system python)
   #:use-module (gnu packages)
   #:use-module (gnu packages audio)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)            ;for 'which'
   #:use-module (gnu packages bison)
+  #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages curl)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages emacs)
+  #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages gstreamer)
+  #:use-module (gnu packages icu4c)
+  #:use-module (gnu packages image)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages libffi)
   #:use-module (gnu packages ncurses)
+  #:use-module (gnu packages machine-learning)
+  #:use-module (gnu packages mp3)
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages python-xyz)
+  #:use-module (gnu packages python-web)
+  #:use-module (gnu packages screen)
+  #:use-module (gnu packages sphinx)
   #:use-module (gnu packages swig)
   #:use-module (gnu packages texinfo)
-  #:use-module (gnu packages textutils))
+  #:use-module (gnu packages textutils)
+  #:use-module (gnu packages time)
+  #:use-module (gnu packages xiph))
 
 (define-public flite
   (package
@@ -652,6 +667,127 @@ (define-public sphinxbase
 manipulating acoustic feature and audio files.")
     (license license:bsd-4)))
 
+(define-public mycroft-core
+  (package
+    (name "mycroft-core")
+    (version "21.2.2")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/MycroftAI/mycroft-core")
+                    (commit (string-append "release/v" version))))
+              (file-name (git-file-name name version))
+              (patches (search-patches "mycroft-core-remove-venv.patch"))
+              (sha256
+               (base32
+                "02r0vxw0hsihnvviwn4fyspwky3kwq42f9z455q1s70k0snzhb28"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:tests? #f ; Currently failing due to ALSA lib
+	               ; https://github.com/MycroftAI/mycroft-core/issues/3074
+       #:phases (modify-phases %standard-phases
+                  (add-after 'unpack 'patch-requirements
+                    (lambda* (#:key inputs outputs #:allow-other-keys)
+                      (let ((mycroft-home (string-append (assoc-ref outputs
+                                                                    "out")
+                                                         "/opt/mycroft")))
+                        (mkdir-p mycroft-home)
+                        ;; Fix home Mycroft directory (used for e.g. skills)
+                        (substitute* "scripts/mycroft-use.sh"
+                          (("/opt/mycroft") mycroft-home))
+                        (substitute* "scripts/my-info.sh"
+                          (("/opt/mycroft") mycroft-home))
+                        (substitute* "mycroft/skills/mycroft_skill/mycroft_skill.py"
+                          (("/opt/mycroft") mycroft-home))
+                        (substitute* "mycroft/configuration/mycroft.conf"
+                          (("/opt/mycroft") mycroft-home))
+                        (substitute* "mycroft/util/file_utils.py"
+                          (("/opt/mycroft") mycroft-home))
+                        (substitute* "test/unittests/tts/test_mimic_tts.py"
+                          (("/opt/mycroft") mycroft-home))
+                        (substitute* "test/unittests/api/test_api.py"
+                          (("/opt/mycroft") mycroft-home))
+                        (substitute* "test/integrationtests/skills/test_all_skills.py"
+                          (("/opt/mycroft") mycroft-home))
+                        (substitute* "README.md"
+                          (("/opt/mycroft") mycroft-home))
+                        ;; Fix mimic binary path
+                        (substitute* "mycroft/tts/mimic_tts.py"
+                          (("bin_ = config.*") (string-append "bin_ = \""
+                                                              (assoc-ref
+                                                               inputs
+                                                               "mycroft-mimic")
+                                                              "/bin/mimic\"
+"))
+                          (("os.path.join\\(MYCROFT_ROOT_PATH.*") ""))
+                        ;; Fix sanity-check errors
+                        (substitute* "setup.py"
+                          (("client\\.ws") "client.client"))
+                        (substitute* "mycroft/client/text/text_client.py"
+                          (("\\.gui_server") "mycroft.client.text.gui_server"))
+                        (substitute* "mycroft/client/text/__main__.py"
+                          (("\\.text_client")
+                           "mycroft.client.text.text_client"))
+                        ;; Use newer version of pkg
+                        (setenv "MYCROFT_LOOSE_REQUIREMENTS" "1")
+                        (substitute* "requirements/requirements.txt"
+                          (("requests>=2.20.0,<2.26.0") "requests>=2.20.0")))))
+                  (replace 'check
+                    (lambda* (#:key tests? #:allow-other-keys
+                              #:rest args)
+                      (when tests?
+                        (setenv "HOME" "/tmp")
+                        (setenv "PYTHONPATH"
+                                (string-append "./build/lib:"
+                                               (or (getenv "PYTHONPATH") "")))
+                        (apply (assoc-ref %standard-phases
+                                          'check) args)))))))
+    (native-inputs (list python-pytest swig))
+    (inputs (list curl
+                  fann
+                  flac
+                  icu4c
+                  libffi
+                  libjpeg-turbo
+                  mpg123
+                  mycroft-mimic
+                  portaudio
+                  pocketsphinx
+                  pulseaudio
+                  screen))
+    (propagated-inputs (list python-adapt-parser
+                             python-dateutil
+                             python-fann2
+                             python-fasteners
+                             python-gtts
+                             python-inflection
+                             python-lingua-franca
+                             python-msk
+                             python-msm
+                             python-mycroft-messagebus-client
+                             python-padaos
+                             python-padatious
+                             python-petact
+                             python-pillow
+                             python-pocketsphinx
+                             python-precise-runner
+                             python-psutil
+                             python-pyaudio
+                             python-pyee
+                             python-pyserial
+                             python-pyxdg
+                             python-pyyaml
+                             python-requests
+                             python-requests-futures
+                             python-speech-recognition
+                             python-tornado-6
+                             python-websocket-client
+                             python-xdg))
+    (home-page "https://github.com/HelloChatterbox/HolmesIV")
+    (synopsis "Mycroft Core, the Mycroft Artificial Intelligence platform")
+    (description "This module provides a hackable voice assistant - Mycroft")
+    (license license:asl2.0)))
+
 (define-public pocketsphinx
   (package
     (name "pocketsphinx")
-- 
2.34.0