[Distutils] setuptools: why does it install ctypes twice?

Phillip J. Eby pje at telecommunity.com
Tue Nov 7 17:49:08 CET 2006


At 04:47 PM 11/7/2006 +0100, Victor Stinner wrote:
>My problem is that "sudo ./setup.py install" reinstall ctypes 1.0.1 and
>ElementTree 1.2.6 whereas they are already installed by Ubuntu (using
>apt-...).

setuptools isn't installing these things twice, it's installing them 
once.  It can't detect that Ubuntu has already installed them, if they are 
installed without .egg-info files or directories.  Python 2.5 does this 
automatically for any distutils-installed package, but for older versions 
of Python you need to manually create these files in site-packages if you 
want to ensure that another copy doesn't get installed:

      ctypes.egg-info
      ElementTree.egg-info

The content of each file should be that package's PKG-INFO file.  This will 
allow setuptools to detect what versions are installed.

The alternative of course is just to let the second installation happen.

Still another alternative would be to create a tool for Debian/Ubuntu users 
that would generate the .egg-info files automatically, although I'm not 
sure how practical that is, since Debian package names do not map 1:1 with 
PyPI package names, and the installed packages do not include PKG-INFO files.

Essentially, this is a design flaw of Debian packaging policy for Python, 
which has not been updated to deal with distutils' project-oriented nature 
or the existence of PyPI.  Debian requirements are expressed in terms of 
Python packages, rather than in terms of Python *projects*.  Python 
projects are the unit of distribution and cataloguing, whereas Python 
packages are code units, and can be split across projects as well as having 
more than one in a given project.  This problem is independent of 
setuptools per se, but the flaw is more clearly visible when you try to use 
setuptools in conjunction with it.



More information about the Distutils-SIG mailing list