This post explains how to compile Python v3.2 including support for the GNU Readline Library on MacOS X 10.7 (Lion), not using tools like MacPorts. One of the problems we try to solve is making history work in the interactive Python interpreter.
First, you need a fresh copy of the GNU Readline Library and compile it. At the time of writing, readline v6.2 was the latest. Fire up a Terminal and do the following:
shell> tar xzf readline-6.2.tar.gz shell> cd readline-6.2 shell> MACOSX_DEPLOYMENT_TARGET=10.7 ARCHFLAGS="-arch x86_64" \ ./configure --prefix=/opt/local shell> make && sudo make install
Note that you can change the location /opt/local to anything you like, but avoid /usr/lib or other system location.
When readline compiled and installed successfully, compile Python v3.2 as follows:
shell> tar xzf Python-3.2.3.tgz shell> cd Python-3.2.3 shell> LDFLAGS="-L/opt/local/lib" CFLAGS="-I/opt/local/include" \ ./configure --prefix=/opt/python/3.2.3 shell> make && sudo make install
Note that you might have more arguments to pass to the ./configure if you have special needs. Note also that /opt/python/3.2.3 is where Python will be installed to avoid clashing with the system provided Python installations.
You should now have history support in the Python interpreter:
shell> /opt/python/3.2.3/bin/python3 >>> import this >>>