pypygtk status update #1

OS: Kubuntu,
$ uname -a
Linux ethan-GA-880GM-UD2H 3.2.0-23-generic-pae #36-Ubuntu SMP Tue Apr 10 22:19:09 UTC 2012 i686 athlon i386 GNU/Linux

ethan@ethan-GA-880GM-UD2H:~/pypy-2.0-beta1/bin$ ./pypy
Python 2.7.3 (7e4f0faa3d51, Nov 16 2012, 16:56:51)
[PyPy 2.0.0-beta1 with GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``in pypy you are always at the
wrong level, in one way or the other''
>>>> import pygtk
>>>> dir(pygtk)
['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_get_available_versions', '_our_dir', '_pygtk_2_0_dir', '_pygtk_dir_pat', '_pygtk_required_version', 'fnmatch', 'glob', 'os', 'require', 'require20', 'sys']

>>>> pygtk._get_available_versions()
{'2.0': '/home/ethan/pypy-2.0-beta1/site-packages/gtk-2.0'}

so far, nothing to bad, but..., now starting bad dream on here.  ImportError: No module named glib._glib
>>>> import gtk
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/ethan/pypy-2.0-beta1/site-packages/gtk-2.0/gtk/__init__.py", line 30, in <module>
    import gobject as _gobject
  File "/home/ethan/pypy-2.0-beta1/site-packages/gobject/__init__.py", line 26, in <module>
    from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
  File "/home/ethan/pypy-2.0-beta1/site-packages/glib/__init__.py", line 22, in <module>
    from glib._glib import *
ImportError: No module named glib._glib

Confirm my installed list whether have libglib2.0-dev, so here might something to missing...
ethan@ethan-GA-880GM-UD2H:~$ dpkg --get-selections | grep glib
gir1.2-glib-2.0                                 install
...
libglib2.0-0                                    install
libglib2.0-bin                                  install
libglib2.0-data                                 install
libglib2.0-dev                                  install
...

After checked the _glib.so is in python2.7/dst-packages/glib/; copy or link in the file in pypy/site-packages/glib/
ethan@ethan-GA-880GM-UD2H:~$ ls /usr/lib/python2.7/dist-packages/glib/
_glib.so  __init__.py  __init__.pyc  option.py  option.pyc

-
>>>> ctypes.cdll.LoadLibrary('_glib.so')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/ethan/pypy-2.0-beta1/lib-python/2.7/ctypes/__init__.py", line 448, in LoadLibrary
    return self._dlltype(name)
  File "/home/ethan/pypy-2.0-beta1/lib-python/2.7/ctypes/__init__.py", line 367, in __init__
    self._handle = _ffi.CDLL(name, mode)
OSError: _glib.so: /usr/lib/libpyglib-2.0-python2.7.so.0: undefined symbol: _PyObject_CallFunction_SizeT
>>>> 

Trial use cpyext.load_module, but met same error message.
>>>> cpyext.load_module('/usr/lib/_glib.so','glib')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: unable to load extension module '/usr/lib/_glib.so': /usr/lib/libpyglib-2.0-python2.7.so.0: undefined symbol: _PyObject_CallFunction_SizeT

Use Python to load _glib.so is not raise _PyObject_CallFunction_SizeT error message.
Python 2.7.3 (default, Aug  1 2012, 05:16:07) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.cdll.LoadLibrary('_glib.so')
<CDLL '_glib.so', handle 87de270 at b72247ac>
>>> 

So, that's mean pypy need to define _PyObject_CallFunction_SizeT, and I find Python include *.h files, in /usr/include/python2.7/abstract.h file can finding declared as below, line 8 and line 326:



#ifdef PY_SSIZE_T_CLEAN
#define PyObject_CallFunction _PyObject_CallFunction_SizeT
#define PyObject_CallMethod _PyObject_CallMethod_SizeT
#endif

...
PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable,
                                                         char *format, ...);





Comments

Popular Posts