[Python-Dev] Re: Python 2.4, distutils, and pure python packages

Thomas Heller theller at python.net
Thu Mar 10 14:30:24 CET 2005

The following message is a courtesy copy of an article
that has been posted to comp.lang.python as well.

[CC to python-dev]
"Fuzzyman" <fuzzyman at gmail.com> writes:

> Python 2.4 is built with Microsoft Visiual C++ 7. This means that it
> uses msvcr7.dll, which *isn't* a standard part of the windows operating
> system.

Nitpicking - it's MSVC 7.1, aka MS Visual Studio .NET 2003, and it's

> This means that if you build a windows installer using
> distutils - it *requires* msvcr7.dll in order to run. This is true even
> if your package is a pure python package. This means that when someone
> tries to use a windows installer created with Python 2.4, on a machine
> with only python 2.3 - it will fail.


> It's likely that nothing can be done about this (although for a pure
> python package there's no reason not to use the 'source distribution'
> and the setup.py). It does mean that I have to build my windows
> installer on a machine with python 2.3.

There's a workaround, although ugly.

bdist_wininst has a --target-version flag which allows to build an
installer for another Python version.  It works both for pure Python
packages, and for (how are they called? non-pure?) packages containing
compiled extensions.  The 2.4 distutils package has all that is needed
to create a installer running with python 2.3 or maybe even 2.2 (which
uses msvcrt.dll instead of msvcr71.dll).  The result, of course, is that
the installer can only install for the version that you specified at
build time.

Because distutils cannot cross-compile extensions for other versions,
you must have build extensions (if there are any to include) with the
other Python version before - distutils will simply pick up the
extensions it finds in build subdirectories for the other version.

Anyway, whether you have extensions or not, you must also specify the
--skip-build command line flag, distutils will complain if you don't.
So, for a pure distribution you would typically run these commands to
build separate installers for 2.3 and 2.4:

\python24\python setup.py --skip-build --target-version 2.3 bdist_wininst
\python24\python setup.py --skip-build --target-version 2.4 bdist_wininst

and for non-pure packages you must compile with each version before
building the installer (if you want for some reason to use python 2.4
to build the installer for 2.3):

\python24\python setup.py build_ext
\python23\python setup.py build_ext

\python24\python setup.py --skip-build --target-version 2.3 bdist_wininst
\python24\python setup.py --skip-build --target-version 2.4 bdist_wininst

OTOH, it's no problem to install both python 2.3 and python 2.4 in
separate directories on the same machine and always make native builds.


To make this story even more complete, there have been also other
bugs caused by the different runtime dlls used in 2.3 and 2.4, most
only showing when you use the --install-script option.  The installer
was using msvcrt.dll and msvcr71.dll at the same time, which led to
crashes when the install script was started - the PythonCard installer
suffered from that, at least.  The bug only occurred with pure python
distributions, because then the dll problem occurred.

The bug is solved in Python 2.3.5, and also in the 2.4.1 release which
will be out soon, with one exception: if the install-script prints
something the output will be lost instead of displayed on the last
screen.  At least that's better than crashing the process.


More information about the Python-Dev mailing list