The Story about Distribute and Setuptools [Edit]
Contents
To make a long story short, I've switched my packages to use distribute instead of setuptools. Distribute is an actively maintained fork of setuptools and provides the setuptools package name. I expect distribute to be "the way of the future".
The need for this change came from Python 2.6.3, which broke every C/C++ extension on the planet that was shipped using setuptools (which includes PyCuda, PyOpenCL, and many more of my packages.) Python 2.6.4 eventually fixed the issue.
How to switch to Distribute [Edit]
Step 1: Completely Remove Setuptools [Edit]
First, check if setuptools was installed using the package manager. In Debian and Ubuntu, do
sudo apt-get remove --purge python-setuptools python-virtualenv
to be sure.
Update 8/11/2010: When you install setuptools in Debian unstable nowadays, you actually get distribute.
Once that's done, try
Python 2.5.4 (r254:67916, Sep 26 2009, 08:19:36) [GCC 4.3.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import setuptools >>> setuptools.__file__ '/usr/lib/python2.5/site-packages/setuptools/__init__.pyc' >>>
If setuptools is still found, delete it:
$ sudo rm -Rf /usr/lib/python2.5/site-packages/setuptools
where you obviously need to subsitute the path that was found for setuptools above.
For completeness, also get rid of easy_install:
$ which easy_install /usr/bin/easy_install $ sudo rm /usr/bin/easy_install
Repeat until no more copies of setuptools are found. Then repeat with distribute instead of setuptools.
Step 2: Download and Unpack Distribute [Edit]
Download distribute from here, unpack, install:
$ tar xvfz distribute-x.y.z.tar.gz $ cd distribute-x.y.z $ [sudo?] python setup.py install
Step 3: Install virtualenv (Optional) [Edit]
If you use virtualenv prior to version 1.5.1, note that you need to use the command line option --distribute to force the use of distribute rather than setuptools. Distribute seems to have become the new default. virtualenv-distribute, a former solution to using distribute with virtualenv, does not work any more.
Error Messages and Solutions [Edit]
KeyError: '_something' [Edit]
Does your error message look like this?
"/usr/local/lib/python2.6/dist-packages/setuptools-0.6c9- py2.6.egg/setuptools/command/build_ext.py", line 85, in get_ext_filename KeyError: '_something'
You are using Python 2.6.3 with Setuptools. This will not work. Uninstall setuptools, install distribute.
Invalid Command 'develop' [Edit]
Does your error message look like this?
Scanning installed packages Setuptools installation detected at /home/schwede/PIC_Hedge/pytools Non-egg installation Removing elements out of the way... Already patched. /home/schwede/PIC_Hedge/pytools/setuptools-0.6c9-py2.6.egg-info already patched. Extracting in /tmp/tmpGSNq8D Now working in /tmp/tmpGSNq8D/distribute-0.6.4 Building a Distribute egg in /home/schwede/PIC_Hedge/pytools /home/schwede/PIC_Hedge/pytools/setuptools-0.6c9-py2.6.egg-info already exists usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help error: invalid command 'develop'
You've managed to install both setuptools and distribute. This shouldn't happen. To clean up the mess, follow the steps above.
