[Pythonmac-SIG] PyQt 3.8.1 on MacOS X 10.1 hobbles

Markus Biermaier mbier at office-m.at
Mon Nov 10 06:32:29 EST 2003


Am Montag den, 10. November 2003, um 11:46, schrieb Jack Jansen:

>
> On 9 Nov 2003, at 14:06, Markus Biermaier wrote:
>> I think PyQt for the Mac is not yet official supported. Also Sip is 
>> pre-release (pre3). I contacted Phil Thompson the person behind PyQt 
>> (I think) with this problem and he told me only to ask the list.
>> I forgot to mention that I use Python-2.3.2.
>>
>>> If you don't run a python script from an executable bundle, it won't 
>>> be able to do GUI stuff (unless it calls undocumented private Apple 
>>> APIs), so that may have something to do with the problem you're 
>>> seeing.  You might have a pythonw script that will do this, but you 
>>> don't mention which version of Python you are using.
>>
>> I find it cool to call a python script simply with "open *.py" from 
>> the shell. It DOES GUI stuff. I think the "open" program is a clever 
>> Apple program and does perhaps "undocumented private Apple APIs"!?
>
> If you've built Python 2.3.2 with --enable-framework then "open 
> file.py" will open file.py with  the PythonLauncher helper program, 
> which will in turn run "pythonw" to run your script. So then everything 
> should be okay, as far as the GUI stuff is concerned.
>
> Which means that (if the above paragraph holds for you) the problem is 
> elsewhere. I would second Bob's suggestion to move to 10.2, because 
> that's the standard OSX version right now, so any PyQt and Qt 
> development will in all likelyhood have been done on that platform.
>
> The fact that changing the order of imports makes the problem disappear 
> seems to point in the direction of something fishy going on in the area 
> of dynamic linking. The OSX model of dynamic linking is different from 
> what many unixen provide, and there are some tricks that packages with 
> a unix background used that needed some massaging to port to MacOSX. 
> Moreover, this sort of massaging tended to break between 10.1 and 10.2. 
> As an example, some package (wxPython, I think, but I'm not sure) had a 
> dynamic module A that exported a symbol Asym. A subsequently loaded 
> dynamic module B would then link to this symbol Asym. This will not 
> work on 10.2 and later without various linker flags, and Apple 
> discourages uses of those flags.
>
> If you run the script with "pythonw -v" you'll see the modules being 
> imported. This may help you pinpoint the exact module that needs to be 
> loaded before anything else, which may indicate where the problem is.
>
> If you need more help from the mailing list then you should probably 
> post the full stacktrace, plus the output of the build process of PyQt 
> (since it'll allow us to inspect the linker flags used). But again, 
> unless you move to at least 10.2 few people here will be able to 
> reproduce what you do.
> --
> Jack Jansen        <Jack.Jansen at cwi.nl>        http://www.cwi.nl/~jack
> If I can't dance I don't want to be part of your revolution -- Emma 
> Goldman

Thanks for your explainations.
Following:
- the result of "pythonw -v" -- with error
- the result of "pythonw -v" -- with workaround (error catched)
- Source-location of error-message
- Incomplete output of build of PyQt (as you see it took hours to build)
   From a build I usually keep only
   o the command line with possible flags
   o the times (to estimate the time for the next build)
   o any errors.
   I'm sorry but I didn't keep the full output (with the linker flags).
Many thanks for your help.

------------------------------ [ BEGIN 
Python-RuntimeError-Fails ] ------------------------------
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site.pyc 
matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site.py
import site # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site.pyc
# /Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/os.pyc 
matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/os.py
import os # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/os.pyc
import posix # builtin
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/posixpath.
pyc matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/posixpath.
py
import posixpath # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/posixpath.
pyc
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/stat.pyc 
matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/stat.py
import stat # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/stat.pyc
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/UserDict.pyc 
matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/UserDict.py
import UserDict # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/UserDict.pyc
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/copy_reg.pyc 
matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/copy_reg.py
import copy_reg # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/copy_reg.pyc
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/types.pyc 
matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/types.py
import types # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/types.pyc
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/warnings.pyc 
matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/warnings.py
import warnings # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/warnings.pyc
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/linecache.
pyc matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/linecache.
py
import linecache # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/linecache.
pyc
Python 2.3.2 (#10, Nov  4 2003, 20:58:36)
[GCC 2.95.2 19991024 (release)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import sip # dynamically loaded from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/
sip.so
Traceback (most recent call last):
   File "aclock.py", line 5, in ?
     from qt import *
RuntimeError: Attempt to create a Python instance for a NULL pointer
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] zipimport
# cleanup[1] warnings
# cleanup[1] signal
# cleanup[1] site
# cleanup[1] linecache
# cleanup[1] posix
# cleanup[1] types
# cleanup[1] exceptions
# cleanup[1] qt
# cleanup[2] stat
# cleanup[2] copy_reg
# cleanup[2] posixpath
# cleanup[2] UserDict
# cleanup[2] sip
# cleanup[2] os
# cleanup[2] os.path
# cleanup sys
# cleanup __builtin__
# cleanup ints: 7 unfreed ints in 6 out of 105 blocks
# cleanup floats
------------------------------ [ END   
Python-RuntimeError-Fails ] ------------------------------

------------------------------ [ BEGIN 
Python-RuntimeError-Catched ] ------------------------------
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site.pyc 
matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site.py
import site # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site.pyc
# /Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/os.pyc 
matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/os.py
import os # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/os.pyc
import posix # builtin
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/posixpath.
pyc matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/posixpath.
py
import posixpath # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/posixpath.
pyc
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/stat.pyc 
matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/stat.py
import stat # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/stat.pyc
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/UserDict.pyc 
matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/UserDict.py
import UserDict # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/UserDict.pyc
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/copy_reg.pyc 
matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/copy_reg.py
import copy_reg # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/copy_reg.pyc
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/types.pyc 
matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/types.py
import types # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/types.pyc
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/warnings.pyc 
matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/warnings.py
import warnings # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/warnings.pyc
# 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/linecache.
pyc matches 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/linecache.
py
import linecache # precompiled from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/linecache.
pyc
Python 2.3.2 (#10, Nov  4 2003, 20:58:36)
[GCC 2.95.2 19991024 (release)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import sip # dynamically loaded from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/
sip.so
import qt # dynamically loaded from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/
qt.so
import qtui # dynamically loaded from 
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/
qtui.so
Qt: QApplication: Warning argv[0] == 'aclock.py' is relative.
In order to dispatch events correctly Mac OS X may require applications 
to be run with the *full* path to the executable.
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] zipimport
# cleanup[1] warnings
# cleanup[1] signal
# cleanup[1] site
# cleanup[1] qtui
# cleanup[1] linecache
# cleanup[1] posix
# cleanup[1] types
# cleanup[1] exceptions
# cleanup[2] stat
# cleanup[2] copy_reg
# cleanup[2] posixpath
# cleanup[2] UserDict
# cleanup[2] sip
# cleanup[2] os
# cleanup[2] os.path
# cleanup[2] qt
# cleanup sys
# cleanup __builtin__
# cleanup ints: 7 unfreed ints in 6 out of 105 blocks
# cleanup floats
------------------------------ [ END   
Python-RuntimeError-Catched ] ------------------------------

------------------------------ [ BEGIN snippet of sip-mac-
gpl-4.0pre3/siplib/threads.c ] ------------------------------
/*
  * Convert a new C/C++ pointer to a Python instance.
  */
PyObject *sip_api_new_cpp_to_self(void *cppPtr,sipWrapperType *type,int 
flags)
{
         static PyObject *nullargs = NULL;

         PyObject *self;
#ifdef WITH_THREAD
         threadDef *td;
#endif

         if (nullargs == NULL && (nullargs = PyTuple_New(0)) == NULL)
                 return NULL;

         if (cppPtr == NULL)
         {
                 PyErr_SetString(PyExc_RuntimeError,"Attempt to create a 
Python instance for a NULL pointer");

                 return NULL;
         }

#ifdef WITH_THREAD
         if ((td = currentThreadDef()) != NULL)
         {
                 td -> cppPending = cppPtr;
                 td -> cppPendingFlags = flags;
         }
         else
         {
                 cppPending = cppPtr;
                 cppPendingFlags = flags;
         }
#else
         cppPending = cppPtr;
         cppPendingFlags = flags;
#endif

         self = PyObject_Call((PyObject *)type,nullargs,NULL);

#ifdef WITH_THREAD
         if (td != NULL)
                 td -> cppPending = NULL;
         else
                 cppPending = NULL;
#else
         cppPending = NULL;
#endif

         return self;
}
------------------------------ [ END   snippet of sip-mac-
gpl-4.0pre3/siplib/threads.c ] ------------------------------

------------------------------ [ BEGIN PyQt-mac-gpl-
snapshot-20031027/.BuildResults ] ------------------------------
time python build.py
...
The build of the PyQt source code for your system is now complete. To 
compile
and install PyQt run "make" and "make install" with appropriate user
privileges.
**************************************************************************
****

real    9m19.768s
user    6m41.390s
sys     0m50.870s

time sudo make
real    113m46.472s
user    97m41.050s
sys     3m41.520s

time sudo make install
real    0m13.600s
user    0m2.600s
sys     0m2.290s
------------------------------ [ END   PyQt-mac-gpl-
snapshot-20031027/.BuildResults ] ------------------------------

Markus

----------------------------------------------------------------------
M. Biermaier                                      mbier AT office-m.at
Wiesengasse 15
3011  Untertullnerbach
Austria / Europe                      Web Site: http://www.office-m.at




More information about the Pythonmac-SIG mailing list