From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: [PATCH] Add Csound and Solfege. Date: Tue, 31 Mar 2015 22:57:16 +0200 Message-ID: <87twx03mxf.fsf@mango.localdomain> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yd3E0-0001Ch-93 for guix-devel@gnu.org; Tue, 31 Mar 2015 16:57:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yd3Dv-0003OB-KM for guix-devel@gnu.org; Tue, 31 Mar 2015 16:57:28 -0400 Received: from sender1.zohomail.com ([74.201.84.162]:52053) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yd3Dv-0003O0-6j for guix-devel@gnu.org; Tue, 31 Mar 2015 16:57:23 -0400 List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Guix-devel --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-gnu-Add-Csound.patch >From dc602efed43f839c964d976f30e73175e79a5f9f Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus 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 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0002-gnu-Add-Solfege.patch >From d819aa3f733ed2d38e083c5cee0e96e3818a0612 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus 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 --=-=-=--