gnu: kaldi-gstreamer-server: Fix build, cleanup tests.

* gnu/packages/machine-learning.scm (kaldi-gstreamer-server):
  [origin]<snippet>: Remove test files.
  [arguments]<phases>: Migrate from GObject.MainLoop to GLib.MainLoop
  in 'build phase.  Adapt to the absence of test files.  Improve the
  wrap part of 'install phase.
  [inputs]: Add gstreamer, gst-plugins-base, gst-plugins-good, kaldi.
  They are necessary for proper install/wrapping.

Signed-off-by: Christopher Baines <mail@cbaines.net>
This commit is contained in:
Nicolas Graves 2025-04-24 01:08:12 +02:00 committed by Christopher Baines
parent c51c0f3d73
commit 97ea59b846
No known key found for this signature in database
GPG key ID: 5E28A33B0B84F577

View file

@ -3204,10 +3204,18 @@ automatically.")
(file-name (git-file-name name version))
(sha256
(base32
"1iijq8jmgdxr7961inal1ggs496ymxradm51m4sqx8vl983x14y8"))))
"1iijq8jmgdxr7961inal1ggs496ymxradm51m4sqx8vl983x14y8"))
;; XXX: Tests are broken beyond repair and are mingled in the
;; source directory. Remove them to avoid installing them.
;; See https://github.com/nicolas-graves/kaldi-gstreamer-server
;; for a fork that tries to repair them, to no avail.
(snippet #~(for-each delete-file
'("kaldigstserver/test-buffer.py"
"kaldigstserver/decoder_test.py"
"kaldigstserver/decoder2_test.py")))))
(build-system gnu-build-system)
(arguments
`(#:tests? #f ; there are no tests that can be run automatically
`(#:tests? #f
#:modules ((guix build utils)
(guix build gnu-build-system)
(srfi srfi-26))
@ -3215,7 +3223,11 @@ automatically.")
(modify-phases %standard-phases
(delete 'configure)
(replace 'build
(lambda* (#:key outputs #:allow-other-keys)
(lambda _
;; Migrate to Glib.MainLoop.
(substitute* (find-files "kaldigstserver" "\\.py")
(("GObject\\.threads_init\\(\\)") "")
(("GObject") "GLib"))
;; Disable hash randomization to ensure the generated .pycs
;; are reproducible.
(setenv "PYTHONHASHSEED" "0")
@ -3224,10 +3236,6 @@ automatically.")
(substitute* "master_server.py"
(("\\.replace\\('\\\\.*") ")"))
;; This is a Python 2 file
(delete-file "decoder_test.py")
(delete-file "test-buffer.py")
(for-each (lambda (file)
(apply invoke
`("python"
@ -3254,19 +3262,18 @@ automatically.")
(let* ((server (string-append bin "/kaldi-gst-server"))
(client (string-append bin "/kaldi-gst-client"))
(worker (string-append bin "/kaldi-gst-worker"))
(PYTHONPATH (getenv "GUIX_PYTHONPATH"))
(GST_PLUGIN_PATH (string-append
(assoc-ref inputs "gst-kaldi-nnet2-online")
"/lib/gstreamer-1.0:${GST_PLUGIN_PATH}"))
(wrap (lambda (wrapper what)
(with-output-to-file wrapper
(lambda _
(format #t
"#!~a
(format #t "#!~a
export GUIX_PYTHONPATH=~a
export GST_PLUGIN_PATH=~a
exec ~a ~a/~a \"$@\"~%"
(which "bash") PYTHONPATH GST_PLUGIN_PATH
export GI_TYPELIB_PATH=~a:${GI_TYPELIB_PATH}
export GST_PLUGIN_SYSTEM_PATH=~a:${GST_PLUGIN_SYSTEM_PATH}
exec ~a ~a~a \"$@\"~%"
(which "bash")
(getenv "GUIX_PYTHONPATH")
(getenv "GI_TYPELIB_PATH")
(getenv "GST_PLUGIN_SYSTEM_PATH")
(which "python") share what)))
(chmod wrapper #o555))))
(for-each wrap
@ -3275,7 +3282,11 @@ exec ~a ~a/~a \"$@\"~%"
"client.py"
"worker.py")))))))))
(inputs
(list gst-kaldi-nnet2-online
(list gstreamer
gst-kaldi-nnet2-online
gst-plugins-base
gst-plugins-good
kaldi
python-wrapper
python-pygobject
python-pyyaml