wxPythonOSX building from source
Why build from source?
It is important for software developers to know how to build things from source code. If you find a bug and need to use a bleeding edge version of something, it is helpful to be able to do so. In addition, by using source code and contributing your experiences back to the project, everyone wins.
I started this page because I found the other two installation pages (BUILD and INSTALL quite confusing and incomplete. Especially for MacOSX users.
I want to build my own for the following reasons:
- The only wxPython binaries available are for Python 2.3.
- OSX 10.3 comes with Python 2.3. I want to use Python 2.4.
- OSX 10.3 Python 2.3 does not support Unicode and I want that enabled.
- The software releases I'm trying to use are not even beta software, but actual latest releases.
The instructions below will result in a working installation of Python 2.4 and wxPython 2.5.3.1.
Jon Scott Stevens jon N O S P A M latchkey.com
My Setup
My setup works like this:
I have a directory /usr/local/src/python where I have put all the Python related things that I want to build. There is no requirement to have things built in this location, but it is easiest for me to do it this way.
[ /usr/local/src/python ]# ls -la total 26188 0 drwxrwxr-x 14 root wheel 476 Jan 19 17:01 ./ 0 drwxrwxr-x 20 root wheel 680 Jan 19 08:28 ../ 0 drwxr-xr-x 39 179 666 1326 Jan 19 17:00 Python-2.4/ 8984 -rw-rw-r-- 1 root wheel 9198035 Nov 29 19:27 Python-2.4.tgz 4 -rw-rw-r-- 1 root wheel 109 Jan 19 17:00 build-python.sh 4 -rw-rw-r-- 1 root wheel 521 Jan 19 16:58 build-wxPython.sh 0 drwxr-xr-x 16 jon wheel 544 Jan 19 09:28 waste/ 0 drwxr-xr-x 41 jon jon 1394 Jan 19 15:21 wxPython-src-2.5.3.1/ 15536 -rw-rw-r-- 1 root wheel 15906505 Nov 9 18:34 wxPython-src-2.5.3.1.tar.gz
In order to build Python 2.4 properly, I need to first download Python 2.4 from http://python.org and I also need to download the waste text editor engine from http://www.merzwaren.com . As instructed in Python-2.4/Mac/OSX/README, I renamed the WASTE engine directory to waste. You will also need to run ranlib on the waste/Static Libraries/libWASTE.a
[ /usr/local/src/python ]# ranlib "waste/Static Libraries/libWASTE.a"
Please note: If you are installing things this way, there is also no need to download the MacPython 2.3 distribution. This will build and install it for you in /Applications/MacPython2.4.
I then created a script called build-python.sh and executed it from the command line while in the /usr/local/src/python directory...
[ /usr/local/src/python ]# cat build-python.sh #!/bin/sh DIR=Python-2.4 cd $DIR ./configure \ --enable-framework \ --enable-unicode make make install
That should build and install Python in /usr/local/bin and /Library/Frameworks/Python.Framework. As noted above, it also installs useful stuff in /Applications/MacPython2.4.
Next, I wanted to add wxPython to my machine. One confusing aspect of all of the other documentation that I have read is that the wxPython source distribution also includes a copy of wxWidgets. There is no need to download and install them separately!
This is my build script for wxWidgets/wxPython...I'm installing wxWidgets into /usr/local/wx. wxPython will get installed into your the previously mentioned directory as well as your Python site-packages directory, which if you have installed Python 2.4 according to the instructions above will be at /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages.
[193][ /usr/local/src/python ]# more build-wxPython.sh #!/bin/sh VER=2.5.3.1 DIR=wxPython-src-$VER BUILD=$DIR/bld PREFIX=/usr/local/wx WX_CONFIG=${PREFIX}/${VER}/bin/wx-config UNICODE=1 GLCANVAS=0 mkdir -p $BUILD cd $BUILD ../configure \ --prefix=${PREFIX}/${VER} \ --with-mac \ --enable-optimize \ --enable-unicode \ --enable-monolithic \ --with-libjpeg=builtin \ --with-libpng=builtin \ --with-libtiff=builtin \ --with-zlib=builtin \ --with-opengl \ --enable-geometry \ --enable-sound --with-sdl \ --enable-display make install make -C contrib/src/gizmos install make -C contrib/src/ogl CXXFLAGS="-DwxUSE_DEPRECATED=0" install make -C contrib/src/stc install cd ../wxPython python setup.py install \ UNICODE=${UNICODE} \ WX_CONFIG=${WX_CONFIG} \ BUILD_GLCANVAS=${GLCANVAS}
Now, this will take a while to build and install everything (on my g4 500mhz box, it takes around an hour!), but after that you should have a working wxPython/wxWidgets installation. If you want to test things out, try running the wxPython demo application.
cd /usr/local/src/python/wxPython-src-2.5.3.1/wxPython/demo pythonw demo.py