The Story about Distribute and Setuptools

As of June 2013, distribute and setuptools have been re-merged, and this page has become moot. I've switched back to setuptools, because something broke distribute. Grr. See the setuptools docs for more info.

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

Step 1: Completely Remove Setuptools

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__

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
$ 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

Download distribute from here, unpack, install:

$ tar xvfz distribute-x.y.z.tar.gz
$ cd distribute-x.y.z
$ [sudo?] python install

Step 3: Install virtualenv (Optional)

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

KeyError: '_something'

Does your error message look like this?

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'

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: [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: --help [cmd1 cmd2 ...]
   or: --help-commands
   or: 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.

DistributeVsSetuptools (last edited 2013-06-25 14:00:14 by AndreasKloeckner)