<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Straight Ornamental: Setting up Python 2.5 on OS X</title>
    <link>http://grahamstratton.org/blog/public/articles/2007/05/13/setting-up-python-2-5-on-os-x</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Ramblings from a rambler</description>
    <item>
      <title>Setting up Python 2.5 on OS X</title>
      <description>&lt;p&gt;Sadly, this isn&amp;#8217;t quite as simple as it might be.  First, set up /usr/local/src/ to contain the source of the packages to be installed:&lt;/p&gt;


&lt;pre&gt;mkdir /usr/local/src
sudo mkdir /usr/local/src
sudo chgrp admin  /usr/local/src
sudo chmod -R 775 /usr/local/src
cd /usr/local/src&lt;/pre&gt;

	&lt;p&gt;Custom packages are generally installed to /usr/local/, hence /usr/local/src is a sensible place to put the source.&lt;/p&gt;


	&lt;p&gt;Now install readline:&lt;/p&gt;


&lt;pre&gt;url -O ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gz
tar -xzvf readline-5.2.tar.gz
cd readline-5.2
./configure --prefix=/usr/local
make
sudo make install
cd ..&lt;/pre&gt;

	&lt;p&gt;One of the exciting new batteries included with Python 2.5 is bindings for Sqlite.  So, we&amp;#8217;d better install that, too:&lt;/p&gt;


&lt;pre&gt;curl -O http://www.sqlite.org/sqlite-3.3.17.tar.gz
./configure --prefix=/usr/local --with-readline-dir=/usr/local
tar xzvf sqlite-3.3.17.tar.gz 
cd sqlite-3.3.17
./configure --prefix=/usr/local --with-readline-dir=/usr/local
make
sudo make install
cd ..&lt;/pre&gt;

	&lt;p&gt;And finally we can actually build Python:&lt;/p&gt;


&lt;pre&gt;wget http://www.python.org/ftp/python/2.5.1/Python-2.5.1.tar.bz2
tar xjvf Python-2.5.1.tar.bz2
cd Python-2.5.1/
./configure --prefix=/usr/local --with-readline-dir=/usr/local --with-sqlite3=/usr/local
make
sudo make install
cd ..&lt;/pre&gt;

	&lt;p&gt;Finally, enable tab completion in the interactive interpreter.  Set ~/.pythonstartup to contain&lt;/p&gt;


&lt;pre&gt;import readline, rlcompleter
readline.parse_and_bind("tab: complete")&lt;/pre&gt;

	&lt;p&gt;and set the environment variable &lt;span class="caps"&gt;PYTHONSTARTUP&lt;/span&gt; to point to this file,for example by adding&lt;/p&gt;


&lt;pre&gt;export PYTHONSTARTUP=~/.pythonstartup&lt;/pre&gt;

	&lt;p&gt;to ~/.bashrc&lt;/p&gt;


	&lt;p&gt;Phew. Now I can actually do something useful! Maybe my next post will be able to contain some more significant substance!&lt;/p&gt;


A quick trick I came across today.  I had code working in the interactive interpreter, but I wanted to copy into an editor.  So I copied the block into TextMate, and needed to strip out the &amp;gt;&amp;gt;&amp;gt;s, the &amp;#8230;s and the output.  Text -&amp;gt; Filter Through Command, setting the command to be 
&lt;pre&gt;egrep "&amp;gt;&amp;gt;&amp;gt;|..." | cut -c5-&lt;/pre&gt; and all sorted. Another instance of a nice blend of &lt;span class="caps"&gt;GUI&lt;/span&gt; and command line in &lt;span class="caps"&gt;OS X&lt;/span&gt;.</description>
      <pubDate>Sun, 13 May 2007 13:47:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:a5dfaee2-c58b-4494-aee9-0946ac31c70f</guid>
      <author>Graham Stratton</author>
      <link>http://grahamstratton.org/blog/public/articles/2007/05/13/setting-up-python-2-5-on-os-x</link>
      <category>Python</category>
      <category>Mac</category>
    </item>
  </channel>
</rss>
