* [PATCH] Add Csound and Solfege.
@ 2015-03-31 20:57 Ricardo Wurmus
2015-04-03 14:33 ` Ludovic Courtès
0 siblings, 1 reply; 3+ messages in thread
From: Ricardo Wurmus @ 2015-03-31 20:57 UTC (permalink / raw
To: Guix-devel
[-- Attachment #1: Type: text/plain, Size: 3065 bytes --]
Hi Guix,
attached is a patch for GNU Solfege, which was surprisingly hard to
package. Another patch is for Csound, which is an optional dependency
of Solfege; it's used in some nice intonation exercises.
Solfege required quite a few additional pre-build phases in order to fix
problems. The following phases have been added:
fix-configuration
: Change paths to audio/MIDI players in default configuration file to
store paths.
patch-python-shebangs
: Self-explanatory. As at least one file is in ISO-8859 encoding this
whole thing is wrapped in (with-fluids ((%default-port-encoding #f))
...)
add-sitedirs
: This is something I think will be required for many pygtk-based
applications. As *.pth files are not automatically considered,
dependencies of pygtk are not loaded and thus not found unless the
directories containing the *.pth files are added as sites. I think
it would be better if we could find a way around patching each and
every PyGTK application in this ad-hoc manner.
adjust-config-file-prefix
: Config files are usually loaded from /etc or /usr/share. This
phase sets the prefix to the package output directory.
fix-gettext
: I have no idea what's wrong with the i18n of Solfege. Upon
application start I'm greeted with locale errors and this particular
line looks like just wrong. "i18n" is None at this point and the
application just crashes unless I comment the line. I feel least
comfortable with this hack and I'd be glad if someone could find a
fix that makes this phase obsolete.
wrap-program
: Solfege needs to be wrapped a second time to set PYTHONPATH, so that
the hack added by the "add-sitedirs" phase actually works. We also
need to set GDK_PIXBUF_MODULE_FILE to enable SVG support (the logo is
an SVG file and the application crashes when the SVG loader is not in
the pixbuf path).
Lilypond is an optional dependency at compile time and runtime.
Unfortunately, I cannot seem to compile Solfege when Lilypond is added
to the inputs. During build it uses Lilypond and ghostscript to render
stuff, but this fails with weird errors like this:
Drawing systems...Error: /undefinedresult in --glyphshow--
I can fix some of them by adding fontconfig, yet others by adding
freetype, but ultimately I can't get all invocations of Lilypond to
complete without error.
Despite all these hacks and fixes, Solfege exhibits somewhat odd
behaviour. Sometimes an empty window pops up, accompanied by a timer
error message on the command line:
/gnu/store/...-solfege-3.22.2/share/solfege/solfege/gu.py:334: Warning: Source ID 3071 was not found when attempting to remove it
gobject.source_remove(self.__timeout)
I suspect some of these issues should be reported upstream because it
seems that they have nothing to do with packaging at all.
FWIW, Solfege as packaged for Guix works better on my system than the
Fedora package (which crashes with an SVG error on startup)...
Csound on the other hand took me no longer than four minutes to package.
~~ Ricardo
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-Add-Csound.patch --]
[-- Type: text/x-patch, Size: 2286 bytes --]
From dc602efed43f839c964d976f30e73175e79a5f9f Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <rekado@elephly.net>
Date: Tue, 31 Mar 2015 22:28:08 +0200
Subject: [PATCH 1/2] gnu: Add Csound.
* gnu/packages/audio.scm (csound): New variable.
---
gnu/packages/audio.scm | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/gnu/packages/audio.scm b/gnu/packages/audio.scm
index 7bce32a..ee80984 100644
--- a/gnu/packages/audio.scm
+++ b/gnu/packages/audio.scm
@@ -31,10 +31,13 @@
#:use-module (gnu packages autotools)
#:use-module (gnu packages boost)
#:use-module (gnu packages base)
+ #:use-module (gnu packages bison)
#:use-module (gnu packages compression)
#:use-module (gnu packages curl)
#:use-module (gnu packages databases)
#:use-module (gnu packages file)
+ #:use-module (gnu packages flex)
+ #:use-module (gnu packages gettext)
#:use-module (gnu packages glib)
#:use-module (gnu packages gtk)
#:use-module (gnu packages gnome)
@@ -233,6 +236,39 @@ bass section with five drawbars. A standalone JACK application and LV2
plugins are provided.")
(license license:gpl2)))
+(define-public csound
+ (package
+ (name "csound")
+ (version "6.04")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append
+ "mirror://sourceforge/csound/csound6/Csound"
+ version "/Csound" version ".tar.gz"))
+ (sha256
+ (base32
+ "1030w38lxdwjz1irr32m9cl0paqmgr02lab2m7f7j1yihwxj1w0g"))))
+ (build-system cmake-build-system)
+ (inputs
+ `(("alsa-lib" ,alsa-lib)
+ ("boost" ,boost)
+ ("pulseaudio" ,pulseaudio)
+ ("libsndfile" ,libsndfile)
+ ("liblo" ,liblo)
+ ("ladspa" ,ladspa)
+ ("jack" ,jack-1)
+ ("gettext" ,gnu-gettext)))
+ (native-inputs
+ `(("bison" ,bison)
+ ("flex" ,flex)
+ ("zlib" ,zlib)))
+ (home-page "http://csound.github.io/")
+ (synopsis "Sound and music computing system")
+ (description
+ "Csound is a user-programmable and user-extensible sound processing
+language and software synthesizer.")
+ (license license:lgpl2.1+)))
+
(define-public clalsadrv
(package
(name "clalsadrv")
--
2.1.0
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-gnu-Add-Solfege.patch --]
[-- Type: text/x-patch, Size: 7107 bytes --]
From d819aa3f733ed2d38e083c5cee0e96e3818a0612 Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <rekado@elephly.net>
Date: Wed, 11 Mar 2015 09:02:34 +0100
Subject: [PATCH 2/2] gnu: Add Solfege.
* gnu/packages/music.scm (solfege): New variable.
---
gnu/packages/music.scm | 125 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 125 insertions(+)
diff --git a/gnu/packages/music.scm b/gnu/packages/music.scm
index c923542..2065018 100644
--- a/gnu/packages/music.scm
+++ b/gnu/packages/music.scm
@@ -23,6 +23,7 @@
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix build-system gnu)
#:use-module (gnu packages)
+ #:use-module (gnu packages audio)
#:use-module (gnu packages bison)
#:use-module (gnu packages docbook)
#:use-module (gnu packages flex)
@@ -30,9 +31,14 @@
#:use-module (gnu packages fontutils)
#:use-module (gnu packages gettext)
#:use-module (gnu packages ghostscript)
+ #:use-module (gnu packages gnome)
#:use-module (gnu packages gtk)
#:use-module (gnu packages guile)
+ #:use-module (gnu packages image)
#:use-module (gnu packages imagemagick)
+ #:use-module (gnu packages linux) ; for alsa-utils
+ #:use-module (gnu packages man)
+ #:use-module (gnu packages mp3)
#:use-module (gnu packages netpbm)
#:use-module (gnu packages perl)
#:use-module (gnu packages pkg-config)
@@ -40,6 +46,8 @@
#:use-module (gnu packages rsync)
#:use-module (gnu packages texinfo)
#:use-module (gnu packages texlive)
+ #:use-module (gnu packages xml)
+ #:use-module (gnu packages xiph)
#:use-module (gnu packages zip))
(define-public lilypond
@@ -102,3 +110,120 @@ music. Music is input in a text file containing control sequences which are
interpreted by LilyPond to produce the final document. It is extendable with
Guile.")
(license license:gpl3+)))
+
+(define-public solfege
+ (package
+ (name "solfege")
+ (version "3.22.2")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append
+ "mirror://gnu/solfege/solfege-"
+ version ".tar.xz"))
+ (sha256
+ (base32
+ "1w25rxdbj907nsx285k9nm480pvy12w3yknfh4n1dfv17cwy072i"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:tests? #f ; xmllint attempts to download DTD
+ #:test-target "test"
+ #:phases
+ (alist-cons-after
+ 'unpack 'fix-configuration
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "default.config"
+ (("csound=csound")
+ (string-append "csound="
+ (assoc-ref inputs "csound")
+ "/bin/csound"))
+ (("/usr/bin/aplay")
+ (string-append (assoc-ref inputs "aplay")
+ "/bin/aplay"))
+ (("/usr/bin/timidity")
+ (string-append (assoc-ref inputs "timidity")
+ "/bin/timidity"))
+ (("/usr/bin/mpg123")
+ (string-append (assoc-ref inputs "mpg123")
+ "/bin/mpg123"))
+ (("/usr/bin/ogg123")
+ (string-append (assoc-ref inputs "ogg123")
+ "/bin/ogg123"))))
+ (alist-cons-before
+ 'build 'patch-python-shebangs
+ (lambda _
+ ;; solfege/dataparser.py is in ISO-8859 encoding
+ (with-fluids ((%default-port-encoding #f))
+ (substitute* (find-files "solfege" ".*\\.py$")
+ (("#!/usr/bin/python") (string-append "#!" (which "python"))))))
+ (alist-cons-before
+ 'build 'add-sitedirs
+ ;; .pth files are not automatically interpreted unless the
+ ;; directories containing them are added as "sites". The directories
+ ;; are then added to those in the PYTHONPATH. This is required for
+ ;; the operation of pygtk and pygobject.
+ (lambda _
+ (substitute* "run-solfege.py"
+ (("import os")
+ "import os, site
+for path in [path for path in sys.path if 'site-packages' in path]: site.addsitedir(path)")))
+ (alist-cons-before
+ 'build 'adjust-config-file-prefix
+ (lambda* (#:key outputs #:allow-other-keys)
+ (substitute* "run-solfege.py"
+ (("prefix = os.path.*$")
+ (string-append "prefix = " (assoc-ref outputs "out")))))
+ (alist-cons-before
+ 'build 'fix-gettext
+ (lambda _
+ ;; solfege/dataparser.py is in ISO-8859 encoding
+ (with-fluids ((%default-port-encoding #f))
+ (substitute* "solfege/dataparser.py"
+ (("_ = i18n") "# _ = i18n"))))
+ (alist-cons-after
+ 'install 'wrap-program
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ ;; Make sure 'solfege' runs with the correct PYTHONPATH. We
+ ;; also need to modify GDK_PIXBUF_MODULE_FILE for SVG support.
+ (let* ((out (assoc-ref outputs "out"))
+ (path (getenv "PYTHONPATH"))
+ (rsvg (assoc-ref inputs "librsvg"))
+ (pixbuf (find-files rsvg "^loaders\\.cache$")))
+ (wrap-program (string-append out "/bin/solfege")
+ `("PYTHONPATH" ":" prefix (,path))
+ `("GDK_PIXBUF_MODULE_FILE" ":" prefix ,pixbuf))))
+ %standard-phases))))))))
+ (inputs
+ `(("python" ,python-2)
+ ("pygtk" ,python2-pygtk)
+ ("gettext" ,gnu-gettext)
+ ("gtk" ,gtk+)
+ ;; TODO: Lilypond is optional. Produces errors at build time:
+ ;; Drawing systems...Error: /undefinedresult in --glyphshow--
+ ;; Fontconfig is needed to fix one of the errors, but other similar
+ ;; errors remain.
+ ;;("lilypond" ,lilypond)
+ ("librsvg" ,librsvg) ; needed at runtime for icons
+ ("libpng" ,libpng) ; needed at runtime for icons
+ ;; players needed at runtime
+ ("aplay" ,alsa-utils)
+ ("csound" ,csound) ; optional, needed for some exercises
+ ("mpg123" ,mpg123)
+ ("ogg123" ,vorbis-tools)
+ ("timidity" ,timidity++)))
+ (native-inputs
+ `(("pkg-config" ,pkg-config)
+ ("txt2man" ,txt2man)
+ ("libxml2" ,libxml2) ; for tests
+ ("ghostscript" ,ghostscript)
+ ;;("fontconfig" ,fontconfig) ; only needed with lilypond
+ ;;("freetype" ,freetype) ; only needed with lilypond
+ ("texinfo" ,texinfo)))
+ (home-page "https://www.gnu.org/software/solfege/")
+ (synopsis "Ear training")
+ (description
+ "GNU Solfege is a program for practicing musical ear-training. With it,
+you can practice your recognition of various musical intervals and chords. It
+features a statistics overview so you can monitor your progress across several
+sessions. Solfege is also designed to be extensible so you can easily write
+your own lessons.")
+ (license license:gpl3+)))
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Add Csound and Solfege.
2015-03-31 20:57 [PATCH] Add Csound and Solfege Ricardo Wurmus
@ 2015-04-03 14:33 ` Ludovic Courtès
2015-04-07 6:36 ` Ricardo Wurmus
0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2015-04-03 14:33 UTC (permalink / raw
To: Ricardo Wurmus; +Cc: Guix-devel
Ricardo Wurmus <rekado@elephly.net> skribis:
> patch-python-shebangs
> : Self-explanatory. As at least one file is in ISO-8859 encoding this
> whole thing is wrapped in (with-fluids ((%default-port-encoding #f))
> ...)
Why doesn’t the ‘patch-shebangs’ phase do its job? Could
‘patch-shebang’ be used instead of ‘substitute*’?
> add-sitedirs
> : This is something I think will be required for many pygtk-based
> applications. As *.pth files are not automatically considered,
> dependencies of pygtk are not loaded and thus not found unless the
> directories containing the *.pth files are added as sites. I think
> it would be better if we could find a way around patching each and
> every PyGTK application in this ad-hoc manner.
Yeah.
> adjust-config-file-prefix
> : Config files are usually loaded from /etc or /usr/share. This
> phase sets the prefix to the package output directory.
OK. I suppose Solfege also supports reading per-user config files from
~/.config or similar?
> fix-gettext
> : I have no idea what's wrong with the i18n of Solfege. Upon
> application start I'm greeted with locale errors and this particular
> line looks like just wrong. "i18n" is None at this point and the
> application just crashes unless I comment the line. I feel least
> comfortable with this hack and I'd be glad if someone could find a
> fix that makes this phase obsolete.
I don’t know what the Python API looks like. The gettext manual
mentions an API with the ‘gettext.’ prefix, dunno if that’s a different
thing.
> Despite all these hacks and fixes, Solfege exhibits somewhat odd
> behaviour. Sometimes an empty window pops up, accompanied by a timer
> error message on the command line:
>
> /gnu/store/...-solfege-3.22.2/share/solfege/solfege/gu.py:334: Warning: Source ID 3071 was not found when attempting to remove it
> gobject.source_remove(self.__timeout)
>
> I suspect some of these issues should be reported upstream because it
> seems that they have nothing to do with packaging at all.
Yes.
> FWIW, Solfege as packaged for Guix works better on my system than the
> Fedora package (which crashes with an SVG error on startup)...
It’s interesting that we find it surprising. ;-)
> From dc602efed43f839c964d976f30e73175e79a5f9f Mon Sep 17 00:00:00 2001
> From: Ricardo Wurmus <rekado@elephly.net>
> Date: Tue, 31 Mar 2015 22:28:08 +0200
> Subject: [PATCH 1/2] gnu: Add Csound.
>
> * gnu/packages/audio.scm (csound): New variable.
OK.
> From d819aa3f733ed2d38e083c5cee0e96e3818a0612 Mon Sep 17 00:00:00 2001
> From: Ricardo Wurmus <rekado@elephly.net>
> Date: Wed, 11 Mar 2015 09:02:34 +0100
> Subject: [PATCH 2/2] gnu: Add Solfege.
>
> * gnu/packages/music.scm (solfege): New variable.
[...]
> + (alist-cons-before
> + 'build 'fix-gettext
> + (lambda _
> + ;; solfege/dataparser.py is in ISO-8859 encoding
> + (with-fluids ((%default-port-encoding #f))
> + (substitute* "solfege/dataparser.py"
> + (("_ = i18n") "# _ = i18n"))))
Perhaps rename the phase to ‘disable-i18n’ for now, because that’s
really what it does AIUI.
OK to push with these changes!
Ludo’.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Add Csound and Solfege.
2015-04-03 14:33 ` Ludovic Courtès
@ 2015-04-07 6:36 ` Ricardo Wurmus
0 siblings, 0 replies; 3+ messages in thread
From: Ricardo Wurmus @ 2015-04-07 6:36 UTC (permalink / raw
To: Ludovic Courtès; +Cc: Guix-devel
Ludovic Courtès writes:
> Ricardo Wurmus <rekado@elephly.net> skribis:
>
>> patch-python-shebangs
>> : Self-explanatory. As at least one file is in ISO-8859 encoding this
>> whole thing is wrapped in (with-fluids ((%default-port-encoding #f))
>> ...)
>
> Why doesn’t the ‘patch-shebangs’ phase do its job? Could
> ‘patch-shebang’ be used instead of ‘substitute*’?
The two affected files start with a Unicode BOM. I simplified the phase
a little more, because it's really only two files that need this special
treatment, not all Python scripts.
>> adjust-config-file-prefix
>> : Config files are usually loaded from /etc or /usr/share. This
>> phase sets the prefix to the package output directory.
>
> OK. I suppose Solfege also supports reading per-user config files from
> ~/.config or similar?
It also reads ~/.solfegerc, but the default config file is used to
initialise the user config if it doesn't exist.
>> fix-gettext
>> : I have no idea what's wrong with the i18n of Solfege. Upon
>> application start I'm greeted with locale errors and this particular
>> line looks like just wrong. "i18n" is None at this point and the
>> application just crashes unless I comment the line. I feel least
>> comfortable with this hack and I'd be glad if someone could find a
>> fix that makes this phase obsolete.
>
> I don’t know what the Python API looks like. The gettext manual
> mentions an API with the ‘gettext.’ prefix, dunno if that’s a different
> thing.
I was wrong. Not i18n is None, but i18n.translation is. Dependent on
locale environment variables it will be set to hold the appropriate
translations. In my case this didn't work for the following reasons:
* glibc-locales was not installed to my profile
* LOCPATH was not set to $out:/lib/locales of glibc-locales
* LC_ALL was not set; when I set it to en_GB it works fine
Since it works in a correctly configured environment I removed the
phase.
> OK to push with these changes!
Thanks for the review! Pushed.
~~ Ricardo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-04-07 6:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-31 20:57 [PATCH] Add Csound and Solfege Ricardo Wurmus
2015-04-03 14:33 ` Ludovic Courtès
2015-04-07 6:36 ` Ricardo Wurmus
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.