2013/7/10 Joel B. Mohler <jmoh...@gamry.com> > On 7/9/2013 11:20 AM, John Ehresman wrote: > > On 7/9/13 11:06 AM, Joel B. Mohler wrote: > >> I have tried commenting out the _setupQtDirectories in __init__.py. It > >> then crashes (ala segfault) on the import of QtCore. I can't think of > >> anything that makes sense explaining that crash since it works fine > >> unfrozen and the normal cxfreeze failure mode is to have some missing > >> dll or module ... not crashes. > > > > It would be nice for someone to try this in a debug build and hopefull > > identify where it's segfaulting. Even if it won't work without a > > qt.conf, it shouldn't segfault. > > Aha, this has been an interesting journey to get this all compiled in > debug. I have found the problem. > > Shiboken::AutoDecRef atexit(Shiboken::Module::import("atexit")); > Shiboken::AutoDecRef regFunc(PyObject_GetAttrString(atexit, > "register")); > > This C-level module import in qtcore_module_wrapper.cpp imports python > module atexit, but it fails and so the second line crashes because > atexit is null. So, easy fix is to include "--include-modules=atexit" > in the cxfreeze command line. > > So, what is the correct fix? I think that import in sbkmodule.cpp does > right to set the PyErr, but the calling code copied above originating > from typesystem_core_common.xml (I think?) doesn't check PyErr_Occurred > and I don't know how the error should propagate in the abstract > conditions of typesystem_core_common.xml. > > With that knowledge, then I suggest the following is a cxfreeze friendly > implementation of __file__ access appropriate in this context: > > diff --git a/PySide/_utils.py.in b/PySide/_utils.py.in > index fb2d25e..f82ce65 100644 > --- a/PySide/_utils.py.in > +++ b/PySide/_utils.py.in > @@ -84,8 +84,10 @@ if sys.platform == 'win32': > return path > > def get_pyside_dir(): > - return > _get_win32_case_sensitive_name(os.path.abspath(os.path.dirname(__file__))) > + from . import QtCore > + return > > _get_win32_case_sensitive_name(os.path.abspath(os.path.dirname(QtCore.__file__))) > > else: > def get_pyside_dir(): > - return os.path.abspath(os.path.dirname(__file__)) > + from . import QtCore > + return os.path.abspath(os.path.dirname(QtCore.__file__)) >
Just small correction - on linux the "import . from QtCore" fails when running post install script first time, so it should be: .... def get_pyside_dir(): from . import QtCore return _get_win32_case_sensitive_name(os.path.abspath(os.path.dirname(QtCore.__file__))) else: def get_pyside_dir(): try: from . import QtCore except ImportError: return os.path.abspath(os.path.dirname(__file__)) else: return os.path.abspath(os.path.dirname(QtCore.__file__)) .... -Roman > I would be happy to hear opinions on these topics. > > Joel > > _______________________________________________ > PySide mailing list > PySide@qt-project.org > http://lists.qt-project.org/mailman/listinfo/pyside >
_______________________________________________ PySide mailing list PySide@qt-project.org http://lists.qt-project.org/mailman/listinfo/pyside