After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 330013 - deskbar-applet will not compile without connection to the display
deskbar-applet will not compile without connection to the display
Status: RESOLVED FIXED
Product: deskbar-applet
Classification: Deprecated
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Deskbar Applet Maintainer(s)
Deskbar Applet Maintainer(s)
: 330998 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-02-05 16:11 UTC by Elijah Newren
Modified: 2006-02-13 16:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to python.m4 that fixes this bug (491 bytes, patch)
2006-02-08 01:38 UTC, Elijah Newren
none Details | Review

Description Elijah Newren 2006-02-05 16:11:29 UTC
deskbar-applet checks for the existence of gnomeapplet by running python and trying to import it.  As a side effect, this imports gtk.  Apparently, gtk tries to open a connection to the display when imported and fails if it is unsuccessful.    This prevents me from building remotely; I'm guessing my setup is similar to Luis' past tinderbox setups (which we would like to start up again), in which case this would cause problems there too.

Would it be possible to just do a pkg-config check for gnome-python-desktop, similar to how the pygtk dependency is currently handled?
Comment 1 Raphael Slinckx 2006-02-05 16:17:53 UTC
I think this is more ignorance of my part :)

The problem is that the gnomeapplet module is either in gnome-python-desktop in post 2.13.? releases, and is in gnome-python-extras before that.

The second problem is that the pkg-config exists even if only one module from g-p-e or g-p-d is built, meaning that there could be situations where there is the pkgconfig file, but not the gnomeapplet module.

Do you have suggestions on how to improve that ? And if it involves autoconf, a patch is apreciated, cause i don't master at all conditional stuff etc, i steal them from others :)
Comment 2 Elijah Newren 2006-02-06 21:21:21 UTC
Unfortunately, I probably know less than you about autoconf, and definitely know less than you about the relevant python stuff.  I'll cc Gustavo and James to see if they have any good ideas.
Comment 3 James Henstridge 2006-02-07 02:51:14 UTC
Raphael: if no display is set, "import gtk" will fail with a RuntimeError.  If the gtk module does not exist, then it will fail with ImportError.  This should be quite easy to test for in your configure script.  Something like:

AC_MSG_CHECKING([for gnomeapplet module])
if AC_RUN_LOG([python -c '
try:
    import gnomeapplet
except ImportError:
    raise
except:
    pass
']); then
  AC_MSG_RESULT([yes])
else
  AC_MSG_RESULT([no])
  AC_MSG_ERROR([gnomeapplet module required to build deskbar])
fi

You could also try using the AM_CHECK_PYMOD() macro in pygtk/m4/python.m4
Comment 4 Raphael Slinckx 2006-02-08 00:19:45 UTC
I'm already using AM_CHECK_PYMOD:
AM_CHECK_PYMOD(gnomeapplet,,AC_MSG_RESULT([yes]),AC_MSG_ERROR([gnomeapplet not found]))

which does exactly what you write above (excepts it sys.exit(0)).
Elijah how exactly is it failing ? Maybe a PYTHONPATH problem ? i had those using jhbuild because jhbuild doesn't set pythonpath correctly, at least that's what i think..
Comment 5 Elijah Newren 2006-02-08 00:51:47 UTC
You are correct that jhbuild doesn't set PYTHONPATH by default, but I manually set that in my ~/.jhbuildrc.  Also, that can't be the problem because if I ssh in with X forwarding, then the build completes just fine.  

I ran some stuff inside python, and it looks to me like the trick behind AM_CHECK_PYMOD doesn't work:
  >>> try:
  ...   import gtk
  ... except ImportError:
  ...   print "import error"
  ... except:
  ...   print "no import error"
  ...
  no import error
  >>> try:
  ...   import gnomeapplet
  ... except ImportError:
  ...   print "import error"
  ... except:
  ...   print "no import error"
  ...
  import error

If I run the above commands from a shell where I have ssh'ed in with X forwarding, nothing is printed.  Also, going back to the shell without X forwarding, I get the following (though you probably already knew this):

  >>> import gnomeapplet
  Traceback (most recent call last):
  • File "<stdin>", line 1 in ?
    ImportError: could not import gtk   >>> import gtk;   Traceback (most recent call last):
  • File "<stdin>", line 1 in ?
  • File "/opt/gnome2/lib/python2.4/site-packages/gtk-2.0/gtk/__init__.py", line 45 in ?
    from _gtk import *   RuntimeError: could not open display

Comment 6 Elijah Newren 2006-02-08 01:08:41 UTC
A trick that does work is trying to import gnomeapplet twice -- the second time succeeds without any problem for such a setup, whereas the second time will still fail if gnomeapplet really doesn't exist (or equivalently, if PYTHONPATH isn't setup correctly).

Maybe AM_CHECK_PYMOD should be altered to do this?
Comment 7 Elijah Newren 2006-02-08 01:38:45 UTC
Created attachment 58891 [details] [review]
Patch to python.m4 that fixes this bug

The exact same patch also applies to gnome-python/pygtk/m4/python.m4 (not too surprisingly -- the files appear to be copies of one another), so it may be useful there too.
Comment 8 James Henstridge 2006-02-08 02:01:20 UTC
Doing a double import as a check is a bad idea.  It is relying on the fact that the import is not atomic, so you see the left overs of the failed import the second time.  This is not guaranteed by the language spec, and may get fixed in a future version.

A better check might be to check the message of the import error to make sure it is talking about the module in question.  Something like:

  try:
      import gnomeapplets
  except ImportError, e:
      if str(e).find('gnomeapplets') >= 0:
          raise
  except:
      pass

This makes sure that the ImportError refelates to the module in question rather than some other module.
Comment 9 Raphael Slinckx 2006-02-08 18:54:20 UTC
I used the following snippet as per James and Elijah suggestion.
Comitted in HEAD, please re-open if it still doesn't work..

AM_PATH_PYTHON
AC_MSG_CHECKING([for gnomeapplet module])
if AC_RUN_LOG([$PYTHON -c '
try:
    import gnomeapplet
except ImportError, e:
    if str(e).find('gnomeapplets') >= 0:
          raise
except:
    pass
']); then
  AC_MSG_RESULT([yes])
else
  AC_MSG_RESULT([no])
  AC_MSG_ERROR([gnomeapplet module required to build deskbar])
fi

Comment 10 Elijah Newren 2006-02-08 21:02:17 UTC
Sorry to be such a pain, but this fails too -- in a strange way.  From config.log:

configure:23287: checking for gnomeapplet module
configure:23297: $PYTHON -c '
try:
    import gnomeapplet
except ImportError, e:
    if str(e).find('gnomeapplets') >= 0:
          raise
except:
    pass
'
Traceback (most recent call last):
  • File "<string>", line 5 in ?
NameError: name 'gnomeapplets' is not defined
configure:23308: $? = 1
configure:23313: result: no
configure:23315: error: gnomeapplet module required to build deskbar


Why would the name gnomeapplets have to be defined?
Comment 11 Gustavo Carneiro 2006-02-08 22:13:13 UTC
You have
... $PYTHON -c '
...
    if str(e).find('gnomeapplets') >= 0:
'...

i.e. you use the same quote (') for shell escaping and for python string literal.  Try changing one of the '' pairs to "".
Comment 12 Raphael Slinckx 2006-02-08 23:17:53 UTC
Thanks gustavo, and beides it must check for 'gnomeapplet' and not 'gnomeapplet*s*'.

I comitted the changes, elijah is it working now ?
Comment 13 Elijah Newren 2006-02-08 23:50:22 UTC
Indeed, it works now.  Thanks everyone!
Comment 14 Raphael Slinckx 2006-02-13 16:37:36 UTC
*** Bug 330998 has been marked as a duplicate of this bug. ***