straw-devel
[Top][All Lists]
Advanced

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

Re: [Straw-devel] module_check in setup.py


From: Terje Rosten
Subject: Re: [Straw-devel] module_check in setup.py
Date: Tue, 20 Jan 2004 23:10:29 +0100
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

* Juri Pakaste
| 
| No, I don't think so. Probably in most cases if you don't have $DISPLAY,
| you don't have authorization to access a display either.

Yeah, you are right.


| Maybe I'll just make it catch the runtimeerror, print out a warning and
| keep going.

Here is a new patch.

It uses the imp module on modules which requires the $DISPLAY variable
and simply check if the glade.so file exists in the correct path
without loading the gtk.glade module.

Too ugly?


 - Terje


--- orig/setup.py
+++ mod/setup.py
@@ -4,6 +4,7 @@
 #
 # 
 
+import imp
 import sys
 import glob
 import os.path
@@ -24,26 +25,28 @@
     try:
         import pygtk
         pygtk.require('2.0')
-        import gtk
+        imp.find_module('gtk')
     except:
         sys.exit('Error: PyGTK-1.99.13 or newer is required.')
 
     mod_list = [
-        ('gtk.glade', "PyGTK's glade"),
-        ('mx.DateTime', 'mx.DateTime'),
-        ('ORBit', 'pyorbit'),
-        ('gnome', 'gnome-python'),
-        ('gnome.vfs', "gnome-python's gnomevfs"),
-        ('gtkhtml2', "gnome-python's gtkhtml2"),
-        ('gconf', "gnome-python's gconf")]
+        ('mx.DateTime', 'mx.DateTime', 0),
+        ('ORBit', 'pyorbit', 0),
+        ('gnome', 'gnome-python', 0),
+        ('gnome.vfs', "gnome-python's gnomevfs", 0),
+        ('gtkhtml2', "gnome-python's gtkhtml2", 1),
+        ('gconf', "gnome-python's gconf", 0)]
 
     if sys.version < '2.3':
-        mod_list.append(('bsddb3.db', 'bsddb3'))
+        mod_list.append(('bsddb3.db', 'bsddb3', 0))
 
     ok = 1
-    for m, w in mod_list:
+    for m, w, x in mod_list:
         try:
-            exec('import %s' % m)
+            if not x:
+                exec('import %s' % m)
+            else:
+                imp.find_module(m)
         except ImportError:
             ok = False
             print 'Error: %s Python module is required to install %s' \
@@ -53,6 +56,13 @@
     except ImportError:
         print 'Warning: adns Python module not found, will continue without.'
 
+    # gtk.glade needs special care (ugly...)
+    if ok:
+        path = imp.find_module('gtk')
+        if not os.path.exists(path[1] + '/glade.so'):
+            ok = False
+            print 'Error: %s Python module is required to install %s' \
+                  % ("PyGTK's glade", name.title())
     if not ok:
         sys.exit(1)
 







reply via email to

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