Following my previous post about switching to use python distribute when upgrading to Python 2.7 via MacPorts, I am curious about the difference between python setuptools and python distribute. Well, with some googling, distribute is apparently a fork of setuptools and distribute looks very community friendly.
For people unfamiliar with the whacky world of Python Packaging, here are two very good articles which will help you understand the back story with these two packages.
And for the impatient who just want to get things done, this quotable quote sums it all up for you… :-)
In case you heard of both setuptools and distribute: distribute fully replaces setuptools. Just use distribute. Setuptools is “maintained” (for various historically dubious values of “maintain”) by one person (whom all should applaud for creating the darn thing in the first place, btw!). Distribute is maintained by a lot of people, so bugs actually get fixed. And “bugs” meaning “it doesn’t break with subversion 1.6 because patches that fix it don’t get applied for half a year”. Be sure to use the latest versions of distribute (and buildout, if applicable).
Looks like I am going to be sticking to python distribute from now on.
I have recently upgraded to use Python 2.7 on my Mac for local development work for a python/django project and needed to use py27-mysql. So naturally, this is what I did…
calvin$ sudo port -v install python27
calvin$ sudo python_select python27
calvin$ sudo port -v install py27-setuptools
Unfortunately when I attempted to install py27-mysql via MacPorts, this is the error I received:
calvin$ sudo port -v install py27-mysql
---> Computing dependencies for py27-distribute.Error: Unable to execute port: Can't install py27-distribute because conflicting ports are installed: py27-setuptools
To report a bug, see <http://guide.macports.org/#project.tickets>
It appears that py27-mysql needs to use py27-distribute instead of py27-setuptools.
To solve this problem, I decided to uninstall py27-setuptools and give py27-distribute a spin. So:
calvin$ sudo port -v uninstall py27-setuptools
---> Deactivating py27-setuptools @0.6c11_1
---> Uninstalling py27-setuptools @0.6c11_1
---> Uninstall is removing py27-setuptools from the port registry.
calvin$ sudo port -v install py27-mysql
---> Computing dependencies for py27-mysql..
---> Dependencies to be installed: py27-distribute
---> Fetching py27-distribute
---> Verifying checksum(s) for py27-distribute
---> Checksumming distribute-0.6.15.zip
---> Extracting py27-distribute
---> Extracting distribute-0.6.15.zip
---> Configuring py27-distribute
---> Building py27-distribute
...
running install_egg_info
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
deleting MySQL_python.egg-info/native_libs.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
Copying MySQL_python.egg-info to /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py27-mysql/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.2-py2.7.egg-info
running install_scripts
---> Installing py27-mysql @1.2.2_0+mysql5
---> Activating py27-mysql @1.2.2_0+mysql5
---> Cleaning py27-mysql
---> Removing work directory for py27-mysql
And magically, py27-mysql now works as required.
Hurrah. :-)

Attempting to run a python/django application today which depended on a legacy MySQL db, I encountered:
No module named mysqldb
Apparently, I am missing the python interface library to MySQL, so here’s the easy solution to it:
sudo port -v install py26-mysql
WARNING: The download and installation process could take a while! :-) About 30 minutes for my case.
As I was using Python 2.6.4 previously, the installation process also upgraded my Python to 2.6.6 since py26-mysql depends on the Python 2.6.6.
Back to coding!