unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: Guix-devel <guix-devel@gnu.org>
Subject: Python ignores pth files?
Date: Sun, 01 Mar 2015 21:27:56 +0100	[thread overview]
Message-ID: <87a8zwa2er.fsf@mango.localdomain> (raw)

[-- Attachment #1: Type: text/plain, Size: 1594 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-WIP-Add-solfege.patch --]
[-- Type: text/x-patch, Size: 3950 bytes --]

From 4984cd4303ba59d07a672e226d54a9569d4770cd Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <rekado@elephly.net>
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	other threads:[~2015-03-01 20:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-01 20:27 Ricardo Wurmus [this message]
2015-03-01 20:34 ` Python ignores pth files? Taylan Ulrich Bayırlı/Kammer
2015-03-01 20:58   ` Ricardo Wurmus
2015-03-01 22:14     ` Ricardo Wurmus
  -- strict thread matches above, loose matches on Subject: below --
2015-03-02  8:18 Federico Beffa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a8zwa2er.fsf@mango.localdomain \
    --to=rekado@elephly.net \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).