[Distutils] Egg support for system packages (including bdist_wininst)

Phillip J. Eby pje at telecommunity.com
Thu Dec 15 01:06:35 CET 2005

Setuptools in SVN now provides preliminary support for installing eggs in 
.egg-info directory style, so that setuptools-based projects can be wrapped 
by system packagers who wish to avoid using .egg files or directories.  In 
addition, you can now use setuptools to install non-setuptools packages in 
such a way that an .egg-info directory is included, so that 
setuptools-based packages can detect the presence of the 
non-setuptools-based package.

If you are building packages using a distutils command such as 
'bdist_wininst' that internally invokes the distutils "install" command, 
you do not need to do anything special.  Setuptools detects when the 
"install" command is invoked programmatically (via run_command()) and 
automatically enters its backward-compatibility mode.

However, if you are using a command such as 'bdist_rpm' that generates 
external scripts which then run "setup.py install", you will need to modify 
the generated scripts to run this instead:

     setup.py install --single-version-externally-managed

You will also need to include the --root or --record options.

For the 'bdist_rpm' command, setuptools automatically adjusts the 'spec' 
files before they're written, so bdist_rpm *should* work correctly, 
although I haven't tested it yet.  Please let me know if you find any 
problems, as I have not yet tested this installation mode with anything but 
bdist_wininst or direct manual installation.

For persons like Paul Moore who want to wrap egg-based packages in Windows 
installers, note that you can now take a setuptools-based package's source 
and run "setup.py bdist_wininst" and it will build a usable .exe.

In addition, you can build Windows installer-wrapped eggs for 
non-setuptools packages by changing your command line from:

     python setup.py bdist_wininst

     python -c "import setuptools;execfile('setup.py')" bdist_wininst

This will build an .exe that includes .egg-info, so that other packages 
will be able to detect it at runtime.

Similarly, if you are building any other kind of system package using 
"python setup.py install", you can force .egg-info to be included by using 
this instead:

     python -c "import setuptools;execfile('setup.py')" install \
         --single-version-externally-managed ...

This support for system packages of eggs is still early and experimental; 
please let me know about any problems you may encounter or any questions 
you may have.  Thanks.

More information about the Distutils-SIG mailing list