Posted by: mishunov on: October 24, 2008
The post is mostly a reminder to myself and contains references to some other posts by other respected developers.
Today I have found out that Philipp von Weitershausen has written the post about the same problem I had a couple of weeks ago and was in the middle of writing the post about the same. Philipp has already explained the problem but I would like to extend it a little (since it’s the note to myself as well):
So, in general, when you install Python in Leopard using MacPorts you are doomed to have Buss Error, since python will pick up broken readline from the system. As Steve McMahon points out in Philipp’s post and Andreas Jung in his own post Leopard uses broken libedit or libreadline (I still don’t get what Leopard is actually using). And that broken library will be caught by your python when you install it with MacPorts.
To avoid the problem I had to do the following steps. They worked for me pretty fine and might work the same nice for you as well. Though it’s not guarantied
I also have to point out that I needed Python 2.4, so there might be changes for other versions.
It’s safe to install it with MacPorts:
sudo port install readline
I have pointed out the problem with readline when you install python with MacPorts on Leopard. So I have decided to build python from source. If you will simply try to download python 2.4 and configure it you can get something like:
lector:Python-2.4.5 denys$ ./configure --prefix=/Users/denys/opt
...
lector:Python-2.4.5 denys$ make
...
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE - ./Modules/posixmodule.c -o Modules/posixmodule.o
./Modules/posixmodule.c: In function 'posix_setpgrp':
./Modules/posixmodule.c:3145: error: too few arguments to function 'setpgrp'
make: *** [Modules/posixmodule.o] Error 1
If you have this, this means you are really using Leopard. And Python 2.4 really can’t be installed in Leopard out-of-the-box. Bah! Even if it sounds silly what you need to do is to explicitly tell python to be installed for Leopard
./configure MACOSX_DEPLOYMENT_TARGET=10.5
But remember we need to point our python to the newly installed readline to avoid Buss Error.
According to Andreas Jung right after configuring your python and before running make you should roughly invade your Makefile. I have no wish to discuss how dirty this solution is, but it works. So, what needs to be done is replacing CC = gcc line in your Makefile to
CSS = gcc -I/opt/local/include -L/opt/local/lib
Then we can finally do
make && make install
If everything went smooth you can try simple test
lector:/ denys$ python2.4
Python 2.4.5 (#1, Oct 31 2008, 22:28:08)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 2+2
4
>>> 2+3
5
Previously (using python installed with MacPorts) you would get Buss Error after “2+3″ request. That’s it about installing python from source in Leopard.
If you plan to use this version of python to run Plone instances, don’t forget to make it your default by putting path to your python in your ~/.profile. Something like
export PATH=/Users/denys/opt/bin:$PATH
Of course you would like to have more libraries.
lector:Imaging-1.1.6 denys$ python ez_setup.py
lector:Imaging-1.1.6 denys$ python setup.py build_ext -i
...
lector:Imaging-1.1.6 denys$ python setup.py install
lector:Imaging-1.1.6 denys$ easy_install ZopeSkel
lector:Downloads denys$ svn co http://divmod.org/svn/Divmod/trunk/Pyflakes
lector:Downloads denys$ cd Pyflakes/
lector:Pyflakes denys$ python setup.py install
In general, you should have PyFlakes installed at this point. At least I would expect it to. But, if you will try to run pyflakes in your terminal, you will most probably get something like:
...
Traceback (most recent call last):
File "/Users/denys/opt/bin/pyflakes", line 3, in ?
from pyflakes.scripts.pyflakes import main
ImportError: No module named scripts.pyflakes
I have no idea why, but the installation procedure of the Pyflakes does not copy scripts/ folder to your python’s site-packages/pyflakes. So, this is the step you need to do manually – copy scripts/ from your SVN checkout of Pyflakes to your site-packages/pyflakes. In my case it was
lector:Pyflakes denys$ cp -r ~/Downloads/Pyflakes/pyflakes/scripts/ ~/opt/lib/python2.4/site-packages/pyflakes/scripts/
Now your Pyflakes should work properly.
December 15, 2008 at 21:39
Thanks, you saved me
December 15, 2008 at 21:51
You are welcome
Glad it was helpful.