[pygtk] PyGTK with py2app
Anders F Björklund
afb at users.sourceforge.net
Fri Oct 21 19:04:49 WST 2011
Shrihari Sankaran wrote:
>> The app bundle itself isn't much, it's just a directory structure:
>>
>> YourApp.app
>> └── Contents
>> ├── Info.plist
>> ├── MacOS
>> │ └── yourapp
>> └── Resources
>> └── yourapp.icns
>>
>> The tricky part is when using an interpreted language like Python,
>> and including all the libraries used (like GTK+) inside the bundle.
>> In order to use a relative path, like "@executable_path/../*", one
>> also has to include the interpreter - in this case a "python" binary.
>>
>> That's the magic that the "ige-mac-bundler" helper is doing for you.
>
> This page (https://live.gnome.org/GTK%2B/OSX/Python) says ige-mac-bundler does work properly with Python. Or, does it?
It should. There is a demo on how to bundle, using "pygtk-demo" app ?
It includes a new Python installation, rather than using system Python.
If there's something wrong with it (gtk-mac-bundler, nee ige-mac-bundler),
you should report those bugs to the gtk-osx tracker and mailing list...
http://git.gnome.org/browse/gtk-mac-bundler
https://live.gnome.org/GTK%2B/OSX/Bundling
>> The stand-alone installation was for just using PyGTK without having
>> to build and bundle it, similar to using it on Windows (or Linux) ?
>> So there were no important differences or patches done, and all the
>> development on GTK+ 3, or Integration, or whatever, happens elsewhere.
>>
>> But if it's just that linker issue that is stopping you from using
>> the all-in-one bundle, it would be possible to do a relocatable one...
>> (one does have to patch a few other packages, to not hardcode paths)
>> I could take a look at it, after transitioning to the new project*.
>
> Will you be able to take a look if I upload the source code? I'm surely doing something wrong. :(
There is nothing wrong, just that the package I did does NOT support
relocation but has /opt/gtk hardcoded in the code and in the linkage.
And on second thought, I don't think it's all that useful to add it...
If you want to bundle Python/PyGTK, you can use the gtk-mac-bundler ?
But I've added the extra flag (-headerpad_max_install_names) to LDFLAGS,
so if I do rebuild it (for whatever reason) it will be relocatable then.
And added the "binary relocation" support to pkg-config and to gtk+,
so that it will allow relocation - just like it did on Win32* already...
* http://developer.gnome.org/glib/2.28/glib-Windows-Compatibility-Functions.html#g-win32-get-package-installation-directory-of-module
The main problem is that it uses the executable, not the gtk library!
So it still fails for an uninstalled app using a system installation.
http://bugzilla-attachments.gnome.org/attachment.cgi?id=199026
>> * The PyGTK.pkg got relocated to: http://macpkg.sourceforge.net/
>> It also got upgraded from 2.22 to 2.24, and had Lion support added.
>> That is, it supports 32-bit and 64-bit Python 2.5, 2.6 and 2.7 on
>> Mac OS X 10.5 Leopard and above - but it is (not yet?) relocatable.
>
> I'm planning to start clean with gtk-osx. What do I do to uninstall PyGTK.pkg? To undo it's path changes.
>
> Thanks a lot :)
> Shrihari
The installation is contained within /opt/gtk, so deleting that is
enough to "uninstall" even if Installer.app doesn't allow uninstall.
If you really want to clean up the (harmless) redirection links too,
you also need to remove any / all of the following six .pth files:
/Library/Python/2.5/site-packages/gtkredirect.pth
/Library/Python/2.6/site-packages/gtkredirect.pth
/Library/Python/2.7/site-packages/gtkredirect.pth
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/gtkredirect.pth
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gtkredirect.pth
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gtkredirect.pth
Those are just one-liners, so deleting them is more for removing
that extra /opt/gtk/lib/python2.?/site-packages from PYTHONPATH...
There are two locations, one for /usr/bin/python2.? and one for
/usr/local/bin/python2.? (from http://python.org) if using that.
--anders
More information about the pygtk
mailing list