[TriZPUG] jump start needed

Chris Calloway cbc at unc.edu
Mon Dec 8 00:30:42 CET 2008


On Dec 5, 2008, at 8:34 PM, Scott Hicks wrote:
> * Getting a python development environment setup correctly on the  
> Mac.  I would like to start with 3.0 since I am new, but do not yet  
> see a Mac image available yet on Python.org

You don't want to start out with Python 3K. Most third party packages  
you'd want to use don't work with it yet. For instance, the lastest  
ez_setup.py for installing setuptools isn't ported to 3.0 yet.

If you want to set up a development environment, the first thing to do  
is compile a Python separate from your built-in system framework Python.

There is a minor problem here. Readline is not distributed with OSX  
because of license problems. And you really want readline to be used  
by Python. So you have to install a private readline library and then  
compile Python to use it.

The simplest way to install readline is to use MacPorts. You can get a  
dmg file to install from the MacPorts site.

Except to install MacPorts, you'll need Xcode and X installed first.  
The X that comes with OSX will have some problems with many programs  
(like WIng, for one). So install the latest XQuartz after installing  
and updating XCode. You can get a pkg file to install from the XQuartz  
site.

So when you get readline from MacPorts, it will likely be installed in  
a default location like /opt/local rather than /usr/local. This is  
good, actually.

Then you can download a Python tarball. The following works with  
either Python 3.0 or > 2.5 by changing the version number in the  
commands:

cd ~
tar -xvzf Python-3.0
cd Python-3.0
export CC="gcc -I/opt/local/include -L/opt/local/lib"

Then edit setup.py. Find the statement that says:

if do_readline:

and right before it, add the following line:

do_readline = True

Then you can perform the following:

./configure --prefix=/opt/python3.0 2>&1 | tee configure.stdout
make 2>&1 | tee make.stdout
make test 2>&1 | tee test.stdout   # this step is optional and takes  
some time
sudo make install 2>&1 | tee install.stdout
cd /opt/python3.0/bin
sudo ln ~sf python3.0 python

Then your development python will be available as /opt/python3.0/bin/ 
python

If you installed a Python in the 2.x series, you'll be able to install  
easy_install and virtualenv, to make real development workbenches.  
Don't use the --enable-framework option with ./configure if you plan  
on using virtualenv.

curl http://peak.telecommunity.com/dist/ez_setup.py > ez_setup.py
sudo /opt/python2.5/bin/python ez_setup.py
sudo /opt/python2.5/bin/easy_install virtualenv
/opt/python2.5/bin/virtualenv my-python
cd my-python
bin/easy_install BeautifulSoup
bin/python
import BeautifulSoup
/opt/python2.5/bin/python

> * I have purchased TextMate and would like to learn tips and tricks  
> of that editor

Another good reason not to use Python 3K right now. You'd need to  
right a TextMate grammar bundle for it.

Also, the TextMate Python bundle responds to the TM_PYTHON and  
PYTHONPATH environment variables a lot, although it is hard coded to  
things like /usr/bin/python2.3 in places. It requires a lot of fix up  
to use with development workspaces and having a global PYTHONPATH  
environment variable is generally not a good thing.

> * I have a particular project in mind.  Pretty simple html parsing /  
> processing and reading and writing to an sqlite database (database  
> is complete).  I have looked at and played around with HTMLParser,  
> urllib, and other libraries such as twill.  They all seem to do the  
> same job and I am not sure which one would best suit my needs.   
> Eventually, I want to get into driving Selenium Grid with Python.

I second the BeautifulSoup recommendations. Which isn't ready for  
Python 3K, either.

> I realize it is the holiday season and I do not want to get started  
> until January.  Hopefully, Python 3 will be available for the Mac by  
> then.

Well, it's available for OSX now as a tarball to compile. When you get  
those Python for Mac installers, they create an alternate framework  
python in OSX, which is not good for development because it becomes  
your default system python instead of an isolated private python.

-- 
Sincerely,

Chris Calloway
http://www.secoora.org
office: 332 Chapman Hall   phone: (919) 599-3530
mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599





More information about the TriZPUG mailing list