gnome-specimen r110 - in branches/import-from-bzr: . specimen



Author: wbolster
Date: Tue Jun 17 18:53:44 2008
New Revision: 110
URL: http://svn.gnome.org/viewvc/gnome-specimen?rev=110&view=rev

Log:
* configure.ac:
* specimen/main.py:
  - Check for Python module availability at run-time instead
    of build-time, as suggested by several people. See
    http://uwstopia.nl/blog/2006/11/using-autotools-to-detect-python-modules
    for more information.
  - "Bumped" version to 0.2pre1


Modified:
   branches/import-from-bzr/   (props changed)
   branches/import-from-bzr/configure.ac
   branches/import-from-bzr/specimen/main.py

Modified: branches/import-from-bzr/configure.ac
==============================================================================
--- branches/import-from-bzr/configure.ac	(original)
+++ branches/import-from-bzr/configure.ac	Tue Jun 17 18:53:44 2008
@@ -1,25 +1,12 @@
 # Initialization
-AC_INIT([gnome-specimen], [0.2])
+AC_INIT([gnome-specimen], [0.2pre1])
 AC_CONFIG_SRCDIR(specimen/specimenwindow.py)
 AM_INIT_AUTOMAKE([1.7])
 AM_MAINTAINER_MODE
 
-# Python
+# Python (Note: Python module availability checks should be done run-time!)
 AM_PATH_PYTHON
 
-# PyGTK
-if ! $PYTHON -c 'import gtk' > /dev/null 2>&1; then 
-	AC_MSG_ERROR([Python module 'gtk' not found])
-fi
-if ! $PYTHON -c 'import gtk.glade' > /dev/null 2>&1; then 
-	AC_MSG_ERROR([Python module 'gtk.glade2' not found])
-fi
-
-# Python Gnome module
-if ! $PYTHON -c 'import gnome' > /dev/null 2>&1; then 
-	AC_MSG_ERROR([Python module 'gnome' not found])
-fi
-
 # GConf
 PKG_CHECK_MODULES(gconf, gconf-2.0)
 AM_GCONF_SOURCE_2
@@ -28,11 +15,6 @@
 	AC_MSG_ERROR([gconftool-2 not found])
 fi
 
-# Python GConf module
-if ! $PYTHON -c 'import gconf' > /dev/null 2>&1; then 
-	AC_MSG_ERROR([Python module 'gconf' not found])
-fi
-
 # i18n
 GETTEXT_PACKAGE=gnome-specimen
 AC_SUBST([GETTEXT_PACKAGE])

Modified: branches/import-from-bzr/specimen/main.py
==============================================================================
--- branches/import-from-bzr/specimen/main.py	(original)
+++ branches/import-from-bzr/specimen/main.py	Tue Jun 17 18:53:44 2008
@@ -15,17 +15,35 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
+import sys
+
+def exit_with_error(msg, e):
+    sys.stderr.write('Error: %s (%s)\n' % (msg, str(e)))
+    sys.exit(1)
 
 def main(args):
     import gettext
     import locale
-    import sys
 
-    import pygtk; pygtk.require('2.0');
+    # Check module dependencies at run time instead of at build time. See
+    # http://uwstopia.nl/blog/2006/11/using-autotools-to-detect-python-modules
+    # for more information.
+    try:
+        import pygtk; pygtk.require('2.0')
+        import gtk, gtk.glade
+    except (ImportError, AssertionError), e:
+        exit_with_error('Importing pygtk, gtk, and gtk.glade modules failed',  e)
     
-    import gtk
-    import gtk.glade
-    import gnome
+    try:
+        import gnome
+    except ImportError, e:
+        exit_with_error('Importing gnome module failed',  e)
+
+    try:
+        import gconf
+    except ImportError, e:
+        exit_with_error('Importing gconf module failed',  e)
+
 
     import specimen.config as config
 



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