From: Don A. <dal...@us...> - 2003-08-13 20:41:36
|
Alexandre, I like this patch. I've tested in on RH9, and it works there as well. I'll commit it later today. Don On Wed, 2003-08-13 at 12:39, Alexandre Duret-Lutz wrote: > >>> "Don" == Don Allingham <dal...@us...> writes: > > Don> I don't like the solution either. It was just a hack to get Ralph up and > Don> going. > > Don> On my systems, (still running python 2.2), this is not a requirement. > Don> What version of pygtk/gnome-python are you running? I have 1.99.14. I > Don> wonder if something changed with 1.99.16 or 1.99.17 > > pygtk 1.99.16 runs the following in its initialization function: > > if (!gtk_init_check(&argc, &argv)) { > if (argv != NULL) { > for (i = 0; i < argc; i++) > g_free(argv[i]); > g_free(argv); > } > PyErr_SetString(PyExc_RuntimeError, "could not open display"); > /* set the LC_NUMERIC locale back to "C", as Python requires > * that it be set that way. */ > setlocale(LC_NUMERIC, "C"); > return; > } > > You could intercept the RuntimeError, unfortunately that doesn't > work for all modules. The ui module from gnome-python 1.99.16 > aborts Python in such situation :( > > How about this patch? Tested on Debian/unstable with the above > packages and DISPLAY unset. > > 2003-08-13 Alexandre Duret-Lutz <ad...@gn...> > > * configure.in: Do not import gnome.ui, gnome.canvas, and gtk.glade; > just search for these modules. Factorize the YES and NO outputs > in $pygtk_require. Quote the result variables of Python checks > when testing against YES. > > Index: configure.in > =================================================================== > RCS file: /cvsroot/gramps/gramps2/configure.in,v > retrieving revision 1.38 > diff -u -b -r1.38 configure.in > --- configure.in 10 Aug 2003 23:25:22 -0000 1.38 > +++ configure.in 13 Aug 2003 18:37:31 -0000 > @@ -75,6 +75,11 @@ > pygtk.require('2.0') > except ImportError: > pass > + > +def out(str): > + f = open('conftest.out', 'w') > + f.write(str) > + f.close() > " > > dnl Check if python bindings for gtk are installed > @@ -84,18 +89,14 @@ > $pygtk_require > try: > import gobject > - f = open("conftest.out", "w") > - f.write("YES") > - f.close() > + out("YES") > except ImportError: > - f = open("conftest.out", "w") > - f.write("NO") > - f.close() > + out("No") > EOF > $PYTHON conftest.py > has_pygtk=`cat conftest.out` > rm -f conftest.out conftest.py > -if test "YES" != $has_pygtk > +if test YES != "$has_pygtk" > then > AC_MSG_ERROR([ > > @@ -107,19 +108,19 @@ > cat > conftest.py <<EOF > $pygtk_require > try: > - import gnome, gnome.ui > - f = open("conftest.out", "w") > - f.write("YES") > - f.close() > + import gnome > + # Do not import gnome.ui, this can kill python if the > + # display cannot be opened. Just search it. > + import imp > + imp.find_module('gnome/ui') > + out("YES") > except ImportError: > - f = open("conftest.out", "w") > - f.write("NO") > - f.close() > + out("NO") > EOF > $PYTHON conftest.py > has_pygnome=`cat conftest.out` > rm -f conftest.out conftest.py > -if test "YES" != $has_pygnome > +if test YES != "$has_pygnome" > then > AC_MSG_ERROR([ > **** The python bindings for GNOME 2.0 (gnome-python2) could not be found.]) > @@ -131,18 +132,14 @@ > $pygtk_require > try: > import gconf > - f = open("conftest.out", "w") > - f.write("YES") > - f.close() > + out("YES") > except ImportError: > - f = open("conftest.out", "w") > - f.write("NO") > - f.close() > + out("NO") > EOF > $PYTHON conftest.py > has_gconf=`cat conftest.out` > rm -f conftest.out conftest.py > -if test "YES" != $has_gconf > +if test YES != "$has_gconf" > then > AC_MSG_ERROR([ > **** The python bindings for gconf (gnome-python2-gconf) could not be found.]) > @@ -153,19 +150,18 @@ > cat > conftest.py <<EOF > $pygtk_require > try: > - import gnome.canvas > - f = open("conftest.out", "w") > - f.write("YES") > - f.close() > + # Do not import gnome.canvas, this can raise a RuntimeError if the > + # display cannot be opened. Just search it. > + import imp > + imp.find_module('gnome/canvas') > + out("YES") > except ImportError: > - f = open("conftest.out", "w") > - f.write("NO") > - f.close() > + out("NO") > EOF > $PYTHON conftest.py > has_canvas=`cat conftest.out` > rm -f conftest.out conftest.py > -if test "YES" != $has_canvas > +if test YES != "$has_canvas" > then > AC_MSG_ERROR([ > **** The python bindings for GNOME canvas (gnome-python2-canvas) could not be found.]) > @@ -176,19 +172,18 @@ > cat > conftest.py <<EOF > $pygtk_require > try: > - import gtk.glade > - f = open("conftest.out", "w") > - f.write("YES") > - f.close() > + # Do not import gtk.glade, this can raise a RuntimeError if the > + # display cannot be opened. Just search it. > + import imp > + imp.find_module('gtk/glade') > + out("YES") > except ImportError: > - f = open("conftest.out", "w") > - f.write("NO") > - f.close() > + out("NO") > EOF > $PYTHON conftest.py > has_pygtk=`cat conftest.out` > rm -f conftest.out conftest.py > -if test "YES" != $has_pygtk > +if test YES != "$has_pygtk" > then > AC_MSG_ERROR([ > -- Don Allingham <dal...@us...> GRAMPS OpenSource Genealogy |