On 7/3/2009 3:42 PM, Hans-Peter Jansen wrote:
> 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..

Don't worry, no offense taken :)

>>>> 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']

OK, this requires some Mac Guru to tell us how dyld resolves the 
dependencies at runtime. I thought otool -L always output absolute 
paths, but if that's not the case, how are we supposed to find out the 
absolute paths?

I don't have a Mac right now. Maybe someone can chime in?

>>> 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).

In one-dir mode, I *believe* that workpath is empty (I'm not sure I 
fully understand the code in there). Try putting some debug messages in 
there to debug.

Anyway, to test if it's the right approach, it is of course sufficient 
to manually set DYLD_LIBRARY_PATH:

  $ DYLD_LIBRARY_PATH=`pwd` ./myapp

If this works, at least we know that we don't need to play any 
install_name_tool game.

>>> 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.

This should be fixed wherever we fix the PyQt <-> Qt dependency, that is 
with DYLD_LIBRARY_PATH (hopefully).
-- 
Giovanni Bajo
Develer S.r.l.
http://www.develer.com

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to