guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Python ignores pth files?


From: Ricardo Wurmus
Subject: Python ignores pth files?
Date: Sun, 01 Mar 2015 21:27:56 +0100

Hi Guix,

I'm currently attempting to package GNU Solfege, a Python application
using PyGTK which uses the gnu-build-system.  Attached is the current
state of my changes.

I need to wrap the executable /bin/solfege to make sure that the
PYTHONPATH is set such that pygtk, pygobject, pycairo and so on can be
found.  Unfortunately, even with the wrapper solfege fails because it
cannot find pygtk:

   Traceback (most recent call last):
     File 
"/gnu/store/mq8zh2ajimn91hsxkrvf2a5pyi0v6gjs-solfege-3.22.2/bin/.solfege-real", 
line 55, in <module>
       from solfege import presetup
     File 
"/gnu/store/mq8zh2ajimn91hsxkrvf2a5pyi0v6gjs-solfege-3.22.2/share/solfege/solfege/presetup.py",
 line 22, in <module>
       import gtk
   ImportError: No module named gtk

With strace I see that python attempts to load the gtk module from all
the places specified in the PYTHONPATH (and a few more), but it does not
actually enter the "gtk-2.0" subdirectory declared by the pygtk.pth
file.

When I explicitly add
/gnu/store/...-pygtk../lib/python2.7/site-packages/gtk-2.0 to PYTHONPATH
the application progresses a little further and then fails to load
"gio", which is also located in a "gtk-2.0" subdirectory rather than the
root of a "site-packages" directory.

pygtk and pygobject both come with .pth files that instruct Python to
check out the "gtk-2.0" subdirectory, yet these files are seemingly
ignored as (according to strace) Python makes no attempt to look inside
the declared subdirectories when Solfege starts up.

I would be glad for any insights you might be able to share.

~~ Ricardo

>From 4984cd4303ba59d07a672e226d54a9569d4770cd Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <address@hidden>
Date: Sun, 1 Mar 2015 21:10:48 +0100
Subject: [PATCH] WIP: Add solfege

---
 gnu/packages/audio.scm | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/gnu/packages/audio.scm b/gnu/packages/audio.scm
index 5a23618..6bb7ccc 100644
--- a/gnu/packages/audio.scm
+++ b/gnu/packages/audio.scm
@@ -35,12 +35,15 @@
   #:use-module (gnu packages curl)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages file)
+  #:use-module (gnu packages gettext)
+  #:use-module (gnu packages ghostscript)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages qt)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages man)
   #:use-module (gnu packages mp3) ;taglib
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
@@ -48,6 +51,7 @@
   #:use-module (gnu packages python)
   #:use-module (gnu packages rdf)
   #:use-module (gnu packages readline)
+  #:use-module (gnu packages texinfo)
   #:use-module (gnu packages which)
   #:use-module (gnu packages xiph)
   #:use-module (gnu packages xml)
@@ -717,6 +721,66 @@ and ALSA.")
 tempo and pitch of an audio recording independently of one another.")
     (license license:gpl2+)))
 
+(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-before
+        'build 'patch-python-shebangs
+        (lambda _
+          (substitute* (find-files "solfege" ".*\\.py")
+            (("#!/usr/bin/python") (string-append "#!" (which "python")))))
+        (alist-cons-after
+         'install 'wrap-program
+         (lambda* (#:key inputs outputs #:allow-other-keys)
+           ;; Make sure 'solfege' can import 'pygtk'.
+           (let* ((out (assoc-ref outputs "out"))
+                  (pygtk (assoc-ref inputs "pygtk"))
+                  (path (getenv "PYTHONPATH")))
+             (wrap-program (string-append out "/bin/solfege")
+               `("PYTHONPATH" ":" prefix (,path
+                                          ;,(string-append pygtk 
"/lib/python2.7/site-packages/gtk-2.0")
+                                          )))))
+         %standard-phases))))
+    (inputs
+     `(("python" ,python-2)
+       ("pygtk" ,python2-pygtk)
+       ("gettext" ,gnu-gettext)
+       ("ghostscript" ,ghostscript)
+       ("gtk" ,gtk+)
+       ;("lilypond" ,lilypond)
+       ))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("txt2man" ,txt2man)
+       ("libxml2" ,libxml2) ; for tests
+       ("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.")
+    ;; Confusing: the README says "either version 2." but does not continue
+    ;; with the common "or (at your option) any later version", yet most of
+    ;; the file headers state GPLv3+.
+    (license license:gpl3+)))
+
 (define-public sratom
   (package
     (name "sratom")
-- 
2.1.0


reply via email to

[Prev in Thread] Current Thread [Next in Thread]