Subject: [bug#54571] [PATCH] gnu: music21: Patch executables and add missing dependencies.

From: jgart <[email-masked]>
Date: Fri, 25 Mar 2022 21:12:33 -0400

* gnu/packages/music.scm (music21)[arguments]: Patch executables.
[propagated-inputs]: Add python-matplotlib, python-jsonpickle, and
python-numpy.
[inputs]: Add lilypond, musescore, and xdg-utils.
---
 gnu/packages/music.scm | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/music.scm b/gnu/packages/music.scm
index 9c8203aa80..2c6b530aac 100644
--- a/gnu/packages/music.scm
+++ b/gnu/packages/music.scm
@@ -1531,6 +1531,15 @@ (define-public music21
     (arguments
      `(#:phases
        (modify-phases %standard-phases
+         (add-before 'build 'patch-executables
+           (lambda _
+             (substitute* '("music21/environment.py"
+                            "music21/lily/translate.py")
+               (("/usr/bin/lilypond") (which "lilypond"))
+               (("/usr/bin/mscore3") (which "mscore"))
+               (("/usr/bin/xdg-open") (which "xdg-open"))
+               (("LILYEXEC = 'lilypond'")
+                (string-append "LILYEXEC = '" (which "lilypond") "'")))))
          (replace 'check
            (lambda* (#:key tests? inputs outputs #:allow-other-keys)
              (when tests?
@@ -1538,8 +1547,17 @@ (define-public music21
                ;; See: https://github.com/cuthbertLab/music21/issues/1164
                (invoke "python" "-m" "music21.stream.tests")))))))
     (propagated-inputs
-      (list python-chardet python-joblib python-more-itertools
-            python-webcolors))
+      (list python-chardet
+            python-joblib
+            python-matplotlib
+            python-jsonpickle
+            python-more-itertools
+            python-webcolors
+            python-numpy))
+    (inputs
+      (list lilypond
+            musescore
+            xdg-utils))
     (home-page "https://web.mit.edu/music21/")
     (synopsis "Toolkit for Computational Musicology")
     (description
-- 
2.34.0