2013-06-21
This is how I installed PyGTK on my office machine, a Mac with OS X 10.7.5 (aka Lion) on which I've never managed to properly use fink or macports and gave up trying to install homebrew. In other words, without a package manager. Look, mommy, no hands!
I'm putting those notes here in case it might help someone struggling with similar problems. Please try using a package manager first, and save yourself some headache.
First of all, my main sources for inspiration:
- The official procedure at live.gnome.org
- Installing PyGTK on Mac Lion
- Building PyGTK for Mac
I started by creating a special directory in which to play:
mkdir $HOME/gtk cd gtk
in which I downloaded the setup script downloaded from gnome.org:
chmod +x gtk-osx-build-setup.sh ./gtk-osx-build-setup.sh
This installed jhbuild in $HOME/.local/bin, which I then added to my path following the script's advice:
export PATH=$HOME/.local/bin:$PATH
In $HOME/.jhbuildrc-custom I made sure that the line
setup_sdk(target=_target, sdk_version="native", architectures=["x86_64"])
was properly set to the right values (in particular, 'x86_64' for a 64-bit architecture such as Lion).
Then the building started:
jhbuild bootstrap
And failed with the following message:
I: Moving temporary DESTDIR u'$HOME/gtk/inst/_jhbuild/root-libtool' into build prefix *** Error during phase install of libtool: Install encountered errors: 2 errors raised, 64 files copied. The errors are: [Errno 2] No such file or directory: '$HOME/gtk/inst/share/libtool/libltdl/._argz_.h' [Errno 2] No such file or directory: '$HOME/gtk/inst/share/libtool/libltdl/._argz.c' *** [6/19] [1] Rerun phase install [2] Ignore error and continue to next module [3] Give up on module [4] Start shell [5] Reload configuration
which is actually just due to the way OS X deals with temporary ._ files (don't get me started on ._ files). After checking that the temporary root-libtool directory had indeed been correctly copied, I typed 2 to keep going.
The next fail was:
*** Error during phase checkout of intltool: ########## Error running wget --continue http://launchpad.net/intltool/trunk/0.50.2/+download/intltool-0.50.2.tar.gz -O $HOME/gtk/source/pkgs/intltool-0.50.2.tar.gz *** [18/19]
So I went and downloaded intltool myself and moved it to $HOME/gtk/source/pkgs and hit 1.
Things happily worked out, and I was able to move on to the next phase:
jhbuild build meta-gtk-osx-bootstrap
Of course this failed as well. This time I was told:
*** Error during phase build of gnome-doc-utils: ########## Error running make -j 17 *** [8/10]
This appeared to be linked to segmentation faults with xsltproc, and possibly the warning
Warning: program compiled against libxml 209 using older 207
I had a closer look at xsltproc
/usr/bin/xsltproc --version
returned
Using libxml 20703, libxslt 10124 and libexslt 813 xsltproc was compiled against libxml 20703, libxslt 10124 and libexslt 813 libxslt 10124 was compiled against libxml 20703 libexslt 813 was compiled against libxml 20703
while
$HOME/gtk/inst/bin/xsltproc --version
returned
Warning: program compiled against libxml 209 using older 207 Using libxml 20708, libxslt 10127 and libexslt 816 xsltproc was compiled against libxml 20900, libxslt 10127 and libexslt 816 libxslt 10127 was compiled against libxml 20900 libexslt 816 was compiled against libxml 20900
Looks like there's something awkward with the xsltproc installed by jhbuilder. My brute force solution was simply to remove the faulty xsltproc from $HOME/gtk/inst/bin. This seemed to make jhbuild happy.
On to the next step then!
jhbuild build meta-gtk-osx-core
This, of course, failed as well.
*** Error during phase build of gtk+: ########## Error running make -j 17 *** [9/11]
This was coming from
libtool: Version mismatch error. This is libtool 2.4.2, but the libtool: definition of this LT_INIT comes from libtool 2.4.
so I installed libtool 2.4.2 as follows: I downloaded libtool-2.4.2.tar.gz from gnu.org to $HOME/gtk/source/pkgs
cd $HOME/gtk/source tar zxvf pkgs/libtool-2.4.2.tar.gz cd libtool-2.4.2/ ./configure --prefix=$HOME/gtk/inst make make install
and then chose 6 (Go to phase "wipe directory and start over") in jhbuild
Yes! Success! GTK was apparently installed. I smoothly moved on to the Python bindings:
jhbuild build pygtk
jhbuild build meta-gtk-osx-python
jhbuild build meta-gtk-osx-themes
And then all what was left was to move the Python packages to their final destination:
sudo cp -r $HOME/gtk/inst/lib/python2.7/site-packages/* /Library/Python/2.7/site-packages/.
I was ready for testing.
python Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pygtk >>> import gobject >>> import glib >>> import gtk Fatal Python error: PyThreadState_Get: no current thread Abort trap: 6
Ah! It turned out that /usr/local/bin must be before /usr/bin in the PATH
export PATH=/usr/local/bin:$PATH
And voilà. This, of course, is the very bare bones version of my last attempt, after an entire week of trial and errors and restarting from scratch again...
P.S. How I installed PyGTK on my Ubuntu laptop, with a well-behaved package manager:
sudo aptitude install python-gtk2



