Obtaining the latest version of python is easy. You can always find the newest version at the official Python website, www.python.org. You'll want to download the latest version that's not an alpha release. As of this writing, the current non-alpha version is 2.2.2.
Next, you need to determine where you want to put the source files, and, ultimately, where you want to put the compiled version of Python. There are essentially two options here:
The directory where you install Python (in the examples above, this is either /usr/local or ~/software), is called the prefix, and will be referred to as <prefix> for the rest of this document. The directory where you install the sources will be called <srcdir> for this rest of this document.
Note: On the lab linux machines, GNU tar is installed. To untar a gzip file, you only need to use the z command, as below:
tar xvfz Python-2.2.2.tar.gz
Most likely you will want to use Python interactively at some point. If this is the case, you probably want to install readline support so you can use the arrow keys to scroll through your command history. To do this, you must complete, several steps. First, you must make sure that the readline library is installed. In RedHat, this is available as an RPM, and you can test if you have it by typing:
rpm --query readline-develIf readline-devel is not installed, you will have to obtain it, either through an RPM (currently readline-devel-4.2a-4.rpm), or from the GNU website, www.gnu.org. On all the lab machines, this library is already installed.
Now that you've untarred your Python distribution, you'll need to configure it. Because of the ingenuity of UNIX programmers, this is incredibly easy. One simple program will search through your system and identify what libraries and packages you have installed and prepare your distribution for compilation. To do this you need to run the following command, from <srcdir>.
./configure --prefix=<prefix> --without-threads --without-cycle-gcYou will see a substantial amount of information go by, most of which you don't need to care about. Just be sure that the program completes with out giving you a critical error message and that the last line says, "creating Makefile." This is the file that tells your computer how to compile Python, and you will need to edit it next.
For most computers, the configure script does an excellent job in setting the appropriate options that will make Python run well. Indeed, if you were to skip this section you would get a perfectly good working copy of Python. However, because the configure script is designed for maximum flexibility across platforms, it can only give the compiler a limited range of speed optimizations. Since Linus is a computationally intense program, we want Python to be as fast as possible, and therefore we have to make a few modifications ourselves. There is no real science to the next section, and, to determine what changes to make, Raj had to try compiling Python with various combinations options to see what configuration was optimal.
If you are using gcc 2.9x, or are using an Athlon processor, you want to find the following line in the Makefile. Open it up with your favorite editor.
OPT= -DNDEBUG -g -O3 -Wall -Wstrict-prototypesChange that line so that it reads as follows:
OPT= -DNDEBUG -O3 -Wall -fomit-frame-pointer -mpentiumpro -maccumulate-outgoing-args
If you have a Pentium 4 processor, and are using gcc 3.x, change the line above to read:
OPT= -DNDEBUG -O3 -Wall -fomit-frame-pointer -mcpu=pentium4 -march=pentium4 -mmmx -msse -mfpmath=sseYou may also have to change the compiler that configure detected. To do this, you will need to find the line in Makefile that says
CC= <something>To figure out which version of gcc you are using, you will need to run the following command:
[nfitzkee@papageno Python-2.2.2]$ gcc --version 2.96In the case above, the version of gcc 2.96. Below is the output you would expect if you had a 3.1 compiler:
[nfitzkee@papageno Python-2.2.2]$ gcc-3.1 --version gcc-3.1 (GCC) 3.1.1 Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.Note that I had to type gcc-3.1 to invoke the newer version of the compiler. On the lab machines, the 3.1 compiler is installed using that binary, and if you want to use gcc 3.1, you should change the line in the make file to read:
CC= gcc-3.1When you are finished making changes to the make file, save your work and move on.
The next part should be easy. From the source directory, simply type in make and watch version of python install. When that is finished (check to make sure there are no errors), type make install, and that will install your new version of python to the directories discussed above. Of course, if you've made typos in the make file, you may have to go back and correct them, but everything should go smoothly at this point.
To test your configuration, load up python and see what it says.
[nfitzkee@papageno Python-2.2.2]$ python2.2 Python 2.2.2 (#3, Jan 17 2003, 09:31:31) [GCC 3.1.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>Check the compilation date (above, Jan 17 2003) to make sure that your version of Python was installed correctly. If not, you may need to check your PATH to make sure that your ~/software directory takes precedence over the RedHat-installed version of Python.
Note: Because many of RedHat's utilities use the system installed python (version 1.5.2), it is recommended that you not delete that version. Instead, change the name of the your compiled executable, modify your PATH environment variable, or adjust your aliases so that your version of Python will run conveniently.
Now that you've installed the base Python, you will want to install essential modules like biomol and linus that the lab uses. However, before you do that, you should install the following modules as well.