Visual Python, OS X source build, Homebrew dependencies
Guilherme Brondani Torri <[email protected]> Mon, 13 Aug 2012 17:21:31 +0200
| Newsgroups | gmane.comp.python.visualpython.user |
|---|---|
| Message-ID | <[email protected]> |
Hello,
Just wanted to report how I compiled Visual Python 5.74 from source on
OS X. The dependencies were supplied by Homebrew [1] (alternative to
MacPorts and Fink). More importantly, I also drafted a Homebrew formula
which automates the build on OS X.
My environment is as follows:
- OS X 10.6.8 (Snow Leopard)
- XCode 3.2.6
- Python 2.7.3 (built with Homebrew [2])
All other dependencies are being provided by Homebrew.
I haven't tested against the Python shipped with OSX, nor custom Python
builds installed in custom prefixes. The formula tries to take care of
finding the proper python library path.
The draft Homebrew formula is temporarily on the link below. After a bit
of test and cleanup we can ask to have it included into Homebrew.
https://gist.github.com/3340522
If you have a working Homebrew installation, you might try to install
Visual Python from the above formula (see instructions below for other
Python dependencies). It might take a while, since Homebrew will trigger
a download and compile chain for a whole bunch of dependencies (20+
other packages).
$ brew install
https://gist.github.com/raw/3340522/630f49b0f9c91b80c2ad652e0ee5def455116f62/visualpython.rb
I picked the name 'visualpython' for the package, let me know if I
should change it.
Issues:
1) Down below I suggest a one-line patch to the build system, to remove
a Fink hardcoded path. Please keep it in mind for the next release.
2) I am getting a warning (see below) from the X11 window which runs the
visual objects. Is that relevant?
Ideally, one should be able to install Visual Python with just 2
commands. One for Homebrew to compile and install Visual. Another for
pip to fetch the other Python modules from PyPI (currently two modules
have broken links or broken builds at PyPI).
This was the interesting part of this message.
--
Below I gathered some notes on how I compiled Visual Python manually
before creating the Homebrew formula.
I have installed Python 2.7 via Homebrew [2], but perhaps the following
will work also with the Python shipped with OS X, and other versions of
OS X.
Let's get the dependencies. It might take a while, since Homebrew will
download and compile a whole bunch of dependencies (20+ other packages)
to satisfy these three main dependencies.
$ brew install boost
$ brew install gtkglextmm
$ brew install libglademm
We need to 'link' some packages in order to get them ahead of the OSX
older versions.
Apparently visual needs autoconf >= 2.68. Homebrew has 2.69 which we
link to put it on the path. gktglextmm needs cairo linked and cairo
needs pixman linked.
$ brew link autoconf cairo pixman
Ready to move on to Visual Python source.
$ wget http://www.vpython.org/contents/download/visual-5.74_release.tar.bz2
$ tar xvfz visual-5.74_release.tar.bz2
$ cd visual-5.74_release
$ autoconf
Need to edit or patch a Makefile which is hardcoded to Fink. Remove
hardcoded path, switch to dynamic boost-python, switch to multi-threaded
boost-signal
[edit | patch] src/Makefile.in
203 - $(GTHREAD_LIBS) /sw/lib/libboost_python-mt.a -lboost_thread-mt
-lboost_signals)
203 + $(GTHREAD_LIBS) -lboost_python-mt -lboost_thread-mt
-lboost_signals-mt)
[end edit]
Now we can configure and build.
$ mkdir build; cd build
We instruct pkg-config to look for .pc files into Homebrew and X11
(xrender.pc).
$ export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig"
The `brew --prefix` is typically /usr/local. The install might break if
you haven't installed anything into
/usr/local/local/python2.7/site-packages yet.
During build it will pick some libs from /usr/X11/lib (libGLU, libXmu,
...). The '-framework OpenGL' gets around 'Undefined symbols:
"_CGLGetCurrentContext" '. By pointing to libpython2.7 it gets around
'Undefined symbols: "_PyExc_RuntimeError" '.
Using the LDFLAGS was the less disruptive way I found to succeed with
the build.
$ ../configure --prefix=`brew --prefix` LDFLAGS="-L/usr/X11/lib
-framework OpenGL
-L/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib
-lpython2.7"
Finally...
$ make install
------
Now we move on to the Python dependencies (ttfquery, fonttools, polygon).
$ pip install ttfquery
Fonttools link is broken on PyPI, pointing to the tarball allows you
continue.
$ pip install
http://sourceforge.net/projects/fonttools/files/2.3/fonttools-2.3.tar.gz
Polygon is also broken on PyPI. It also has a small NumPy issue on its
setup.py. I already informed upstream [3].
$ wget https://github.com/downloads/jraedler/Polygon2/Polygon-2.0.5.zip
$ unzip Polygon-2.0.5.zip
[edit | patch] Polygon-2.0.5/setup.py
29 if withNumPy:
30 try:
31 import numpy
32 print "Using NumPy extension"
33 mac.append(('WITH_NUMPY', 1))
34 + numPyIncludePath=numpy.get_include() #add this
[end edit]
$ pip install ./Polygon-2.0.5
------
Assuming that your /usr/local/lib/python2.7/site-packages is present on
PYTHONPATH, you should now be good to run visual.
I tested the installation with the following script:
# testvisual.py
from visual import *
redbox=box(pos=vector(4,2,3),size=(8,4,6),color=color.red)
ball=sphere(pos=vector(4,7,3),radius=2,color=color.green)
Both objects show up on a X11 window, but the following warning is also
issued:
Xlib: extension "RANDR" missing on display "/tmp/launch-Nowttg/org.x:0".
warning: get proc address request is not for a gl or glX function
----
That was it.
With best regards,
Guilherme
[1] http://mxcl.github.com/homebrew/
[2]
http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/
[3] https://github.com/jraedler/Polygon2/pull/1
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/