Hi Giovanni,

Am Freitag, 3. Juli 2009 schrieb Giovanni Bajo:
> On gio, 2009-07-02 at 21:56 +0200, Hans-Peter Jansen wrote:
> > Am Donnerstag, 2. Juli 2009 schrieb Giovanni Bajo:
> > > On 7/2/2009 11:23 AM, Hans-Peter Jansen wrote:
> > > > Shouldn't this work out of the box? I would very much like to keep
> > > > the original Qt build, I'm using here. Needless to say, running it
> > > > with Qt installed, works fine.
> > >
> > > Yes, it should work out of the box, and I have sucessfully managed to
> > > ship PyQt applications on Mac.
> > >
> > > It might be related to the fact that PyInstaller seems not to set
> > > DYLD_LIBRARY_PATH correctly in one-dir mode.
> >
> > Hmm, given that the libs are missing, how could setting a environment
> > variable fix that problem?
>
> Sorry, I had misread your original mail.

Excuse me, I don't wanted to sound rude. I tend to be explicite sometimes..

> > > Does it work in one-file mode? If so, it's should be easy to fix.
> >
> > No, it doesn't, but since the analyse part is the same, it cannot.
> >
> > Did you really shipped apps, based on a current Qt framework build, and
> > it worked out of the box (without Qt installed on the target
> > systems)?!?
>
> Yes. I'm not 100% sure my deployment Mac has the standard Qt framework
> though; I'll have to check.
>
> I still can't see what it is going on. mf.py (which is the dependency
> analyzer) should be able to find the Qt libraries from the PyQt4 ones.
> What happens if you run "bindepend.py PyQt4.QtCore4.so"? Does it list Qt
> dependencies? Under what path?

$ tools/pyinstaller/bindepend.py dist/CReport/PyQt4.QtCore.so 
dist/CReport/PyQt4.QtCore.so E: cannot find path 
QtCore.framework/Versions/4/QtCore 
(needed by dist/CReport/PyQt4.QtCore.so)
['/usr/lib/libz.1.dylib', '/usr/lib/libSystem.B.dylib', 
'/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices',
 
'/usr/lib/libstdc++.6.dylib', '/usr/lib/libgcc_s.1.dylib']

Obviously, Qt uses a path relative to /Library/Frameworks.

With the gross hack appended, pyinstaller got rid of the error and added 
Qt{Core,Gui}:

$ python tools/pyinstaller/bindepend.py dist/CReport/PyQt4.QtCore.so 
dist/CReport/PyQt4.QtCore.so 
['/Library/Frameworks/QtCore.framework/Versions/4/QtCore', 
'/usr/lib/libz.1.dylib', '/usr/lib/libSystem.B.dylib', 
'/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices',
 
'/usr/lib/libstdc++.6.dylib', '/usr/lib/libgcc_s.1.dylib']


> > Here's what I did (hopefully complete):
> >
> > cd .app/Contents
> > md Framework
> > cp -R /Library/Frameworks/Qt{Core,Gui}.framework Framework
> > find Framework -depth -name Headers -exec rm -r {} \;
> > find Framework -depth -name \*_debug\* -exec rm -r {} \;
> >
> > # treat QtCore
> > install_name_tool -id \
> > @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore \
> > QtCore.framework/Versions/4.0/QtCore
> >
> > install_name_tool -change QtCore.framework/Versions/4/QtCore \
> > @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore \
> > QtCore.framework/Versions/4.0/QtCore
> >
> > # treat QtGui
> > install_name_tool -id \
> > @executable_path/../Frameworks/QtGui.framework/Versions/4.0/QtGui \
> > QtGui.framework/Versions/4.0/QtGui
> >
> > install_name_tool -change QtCore.framework/Versions/4/QtCore \
> > @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore \
> > QtGui.framework/Versions/4.0/QtGui
> >
> > # treat PyQt4.QtCore
> > install_name_tool -change QtCore.framework/Versions/4/QtCore \
> > @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
> > ../MacOS/PyQt4.QtCore.so
> >
> > # treat PyQt4.QtGui
> > install_name_tool -change QtCore.framework/Versions/4/QtCore \
> > @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore
> > ../MacOS/PyQt4.QtGui.so
> >
> > install_name_tool -change QtGui.framework/Versions/4/QtGui \
> > @executable_path/../Frameworks/QtGui.framework/Versions/4.0/QtGui
> > ../MacOS/PyQt4.QtGui.so
> >
> > # check, if something is still missing
> > otool -L ../MacOS/PyQt4.Qt*.so QtCore.framework/QtCore
> > QtGui.framework/QtGui
> >
> >
> > You see, the whole mess is asking for automatic treatment. What I'm
> > thinking about, is getting rid of the Framework junk, and simply throw
> > the lib files QtCore, QtGui, etc into "the" dir (renaming them to
> > Qt*.so), and do the adjustments as outlined above, but I haven't tried
> > this yet.
>
> Yes it would be better to just put everything inside the output
> directory, like we do on other platforms (unless dyld makes this really
> impossible -- which I hope it does not).
>
> The install_name_tool trick shouldn't be necessary: I used to do it
> automatically in PyInstaller, but it turned out to have compatibility
> problems across different Mac OSX versions (I don't recall details) and
> setting DYLD_LIBRARY_PATH instead was just as effective.

Okay, that's missing as well:
output from print os.environ
{'SHELL': '/bin/bash', 'QT_PLUGIN_PATH': 'qt4_plugins:', 
'PYTHONPATH': '/Applications/CReport.app/Contents/MacOS', 
'SECURITYSESSIONID': '6052c0', '__CF_USER_TEXT_ENCODING': '0x1F5:0:3', 
'USER': 'hp', 'HOME': '/Users/hp', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin'}

Traceback (most recent call last):
  File "<string>", line 36, in <module>
  File "/Users/hp/Desktop/PyQt-Devel/creport/tools/pyinstaller/iu.py", line 
480, in importHook
  File "/Users/hp/Desktop/PyQt-Devel/creport/tools/pyinstaller/iu.py", line 
498, in doimport
  File "/Users/hp/Desktop/PyQt-Devel/creport/tools/pyinstaller/iu.py", line 
300, in getmod
  File "/Users/hp/Desktop/PyQt-Devel/creport/tools/pyinstaller/archive.py", 
line 468, in getmod
  File "/Users/hp/Desktop/PyQt-Devel/creport/tools/pyinstaller/iu.py", line 
109, in getmod
ImportError: dlopen(/Applications/CReport.app/Contents/MacOS/PyQt4.QtCore.so, 
2): 
Library not loaded: QtCore.framework/Versions/4/QtCore
  Referenced from: /Applications/CReport.app/Contents/MacOS/PyQt4.QtCore.so
  Reason: image not found

I tried to find the right spot for adding it, but failed. source/linux/main.s 
looks to me, like it should appear (as long as workpath is not empty).

> You don't need to rename Qt libraries to ".so". If I recall correctly,
> they can stay as-is. Just try copying them within the output directory
> and see what happens (and set DYLD_LIBRARY_PATH to point to that
> directory as well).

Could you give me the hint, where DYLD_LIBRARY_PATH is missing, and I'm 
testing it right away.

> > I think, this deserves a mac related option (one may don't want to ship
> > Qt), but by default the libs should be included. Using qt4_plugins may
> > deserve another option, since they need the same treatment as above,
> > and on that way pull nearly the full distribution into the bundle.
>
> This is a totally different topic, as PyInstaller treats qt4_plugins
> mostly as data files. We'll have to find out why hook-PyQt4.Qt*.py don't
> find the Qt4 plugins directory.

It looks like QT_PLUGIN_PATH is set correctly, and they also appear 
altogether, but those plugins bind with nearly all Qt libs in existence,
and this dependancy is not handled correctly, yet.

$ find . -name \*.dylib -exec otool -L {} \; | grep -i qt
./accessible/libqtaccessiblecompatwidgets.dylib:
        libqtaccessiblecompatwidgets.dylib (compatibility version 0.0.0, 
current version 0.0.0)
        Qt3Support.framework/Versions/4/Qt3Support (compatibility version 
4.5.0, current version 4.5.2)
        QtSql.framework/Versions/4/QtSql (compatibility version 4.5.0, current 
version 4.5.2)
        QtXml.framework/Versions/4/QtXml (compatibility version 4.5.0, current 
version 4.5.2)
        QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.5.0, 
current version 4.5.2)
        QtGui.framework/Versions/4/QtGui (compatibility version 4.5.0, current 
version 4.5.2)
        QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, 
current version 4.5.2)
./accessible/libqtaccessiblewidgets.dylib:
        libqtaccessiblewidgets.dylib (compatibility version 0.0.0, current 
version 0.0.0)
        QtGui.framework/Versions/4/QtGui (compatibility version 4.5.0, current 
version 4.5.2)
        QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, 
current version 4.5.2)
        QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, 
current version 4.5.2)
        QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, 
current version 4.5.2)
        QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, 
current version 4.5.2)
./codecs/libqtwcodecs.dylib:
        libqtwcodecs.dylib (compatibility version 0.0.0, current version 0.0.0)
        QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, 
current version 4.5.2)
        QtSvg.framework/Versions/4/QtSvg (compatibility version 4.5.0, current 
version 4.5.2)
        QtXml.framework/Versions/4/QtXml (compatibility version 4.5.0, current 
version 4.5.2)
        QtGui.framework/Versions/4/QtGui (compatibility version 4.5.0, current 
version 4.5.2)
        QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, 
current version 4.5.2)
        QtGui.framework/Versions/4/QtGui (compatibility version 4.5.0, current 
version 4.5.2)
        QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, 
current version 4.5.2)
        QtGui.framework/Versions/4/QtGui (compatibility version 4.5.0, current 
version 4.5.2)
        QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, 
current version 4.5.2)
        QtGui.framework/Versions/4/QtGui (compatibility version 4.5.0, current 
version 4.5.2)
        QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, 
current version 4.5.2)
        QtGui.framework/Versions/4/QtGui (compatibility version 4.5.0, current 
version 4.5.2)
        QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, 
current version 4.5.2)
        QtSvg.framework/Versions/4/QtSvg (compatibility version 4.5.0, current 
version 4.5.2)
        QtXml.framework/Versions/4/QtXml (compatibility version 4.5.0, current 
version 4.5.2)
        QtGui.framework/Versions/4/QtGui (compatibility version 4.5.0, current 
version 4.5.2)
        QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, 
current version 4.5.2)
./imageformats/libqtiff.dylib:
        libqtiff.dylib (compatibility version 0.0.0, current version 0.0.0)
        QtGui.framework/Versions/4/QtGui (compatibility version 4.5.0, current 
version 4.5.2)
        QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, 
current version 4.5.2)

> > Thus I may
> > decide to do without them, and spare a lot of space. BTW, do you know,
> > what codecs are shipped in libqtwcodecs.dylib? They can't be essential,
> > since my simple app works without them at least (due to missing "the"
> > treatment ATM).

Hopefully, my point is clearer now.

Thanks for your support, Giovanni. I really appreciate that. 

Pete

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/PyInstaller?hl=en
-~----------~----~----~----~------~----~------~--~---

--- bindepend.py~	2009-06-12 09:24:17.173934842 +0200
+++ bindepend.py	2009-07-03 15:17:18.743093952 +0200
@@ -363,6 +363,8 @@ def _getImports_otool(pth):
                 rel_path = lib.replace("@executable_path",".")
                 rel_path = os.path.join(os.path.dirname(pth), rel_path)
                 lib = os.path.abspath(rel_path)
+            elif not lib.startswith("/"):
+                lib = "/Library/Frameworks/" + lib
             if os.path.exists(lib):
                 rslt.append(lib)
             else:

Reply via email to