Showing posts with label gtk. Show all posts
Showing posts with label gtk. Show all posts

Wednesday, March 2, 2011

Building PyGTK for Mac

In the past couple of months a number of people have asked me to provide new native Mac PyGTK builds. I do not use PyGTK anymore, so I don't have time to maintain these builds - sorry. Out of curiosity I recently built PyGTK on my Snow Leopard (10.6.6) machine, just to see if the process has gotten any easier, and I must say that it has. I was able to build the entire thing without any hacking. So, to those of you asking me to provide new builds, here you have a complete HOWTO of how to build a native Mac PyGTK:

  1. Create a new user account (to make sure that no MacPorts/Fink/other libraries are available in the environment)

  2. Install git (http://code.google.com/p/git-osx-installer/downloads/list?can=3)

  3. Log in to the new account (I ssh'ed in from a Terminal)

  4. Download the build script (https://github.com/jralls/gtk-osx-build/raw/master/gtk-osx-build-setup.sh)

  5. Add ~/.local/bin to PATH

  6. Edit ~/.jhbuildrc-custom setting setup_sdk like so: setup_sdk(target="10.6", sdk_version="10.6", architectures=["i386"])

  7. Run these build commands:

    1. $ jhbuild bootstrap

    2. $ jhbuild build meta-gtk-osx-bootstrap

    3. $ jhbuild build meta-gtk-osx-core

    4. $ jhbuild build pygtk



  8. Download the PyGTK hello world script (http://www.pygtk.org/pygtk2tutorial/examples/helloworld.py)

  9. Update your PYTHONPATH: export export PYTHONPATH=$PYTHONPATH:~/gtk/inst/lib/python2.6/site-packages

  10. Make sure that 32-bit Python is used: export VERSIONER_PYTHON_PREFER_32_BIT=yes

  11. Test your build by running the hello world script: python helloworld.py


Note that to perform the last step you need to be properly logged in (not just through SSH).

I hope that this helps some of the people that have asked me about PyGTK builds. Happy hacking ;-)

Friday, September 18, 2009

Native Mac PyGTK for Snow Leopard

I have just made a fresh build of native PyGTK for Mac on my new Snow Leopard install. It seems to be working - I have only tested my simple hello_pygtk.py script, and that works at least ;-)

You can grab the new build here: MacPyGTK_SnowLeopard_091809.dmg

Remember to follow the three simple instructions in README.txt in order to make it work. B.t.w., one has to be running Python in 32-bit mode for it to work. This can be done in two ways:
  1. By setting this environment variable VERSIONER_PYTHON_PREFER_32_BIT=yes
  2. By issuing this command (once): defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
I would prefer setting the environment variable in a script starting my PyGTK application. That way I am changing as little as possible in the standard setup of the machine...

Sunday, September 13, 2009

Fresh PyGTK build for Leopard/Intel

I have just built a fresh version of native Mac OS X PyGTK and all of its dependencies. This time I have only made an Intel build for Leopard, so no PPC version this time around.

You can grab the new dmg file here: MacPyGTK_Leopard_Intel_091309.dmg

The install procedure is the usual:
  1. Download and mount the dmg
  2. Drag the MacPyGTK folder to /Developer
  3. Copy the contents of site-packages into the site packages of your Python installation (on 10.5 this should be /Library/Python/2.5/site-packages)
  4. Test that it works by running the hello_pygtk.py file with your Python interpreter.
That's it - now you should have a fully functional PyGTK installation to play around with.

Friday, December 19, 2008

PyGTK natively on Mac

I recently found out that the GTK+ GUI widget set had been ported to run natively (i.e. without the use of X11) on Mac OS X. Information about this project can be found on this page. Now, I like GTK+ but life is too short to be coding in C, so I imediately started looking into the possibility of using PyGTK together with this native Mac version of GTK+ and that is indeed possible. To get a fully functional version of GTK+ and PyGTK installed onto your Mac follow the instructions on Imendio's page and then after finishing the installation add the following command:
jhbuild build pygtk

This will build libglade, pygtk, pycairo and some other stuff and install the necessary files into your site-packages folder of your local Python.

Building all of this from source is a lengthy process, and I have therefore created a .dmg image (Intel or PPC) of a GTK+-with-PyGTK that you may use as a shortcut :-) Using this approach will give you a fully functional native PyGTK to play with in less than two minutes.