[Distutils] easy_install doesn't recognize valid distutils Windows installers

Matt Good matt at matt-good.net
Thu Sep 21 02:25:51 CEST 2006


On Wed, 2006-09-20 at 20:00 -0400, Phillip J. Eby wrote:
> At 02:59 PM 9/19/2006 -0400, Matt Good wrote:
> >On Windows "easy_install trac" fails with the error:
> >"trac-0.10b1.win32.exe is not a valid distutils Windows .exe"
> >
> >http://trac.edgewall.org/ticket/3750
> >
> >The problem is with easy_install locating the config information
> >embedded in the file.  The following patch works with the Trac
> >installer, but I don't know if it will break support for other
> >installers:
> >
> >Index: setuptools/command/easy_install.py
> >===================================================================
> >--- setuptools/command/easy_install.py  (revision 51920)
> >+++ setuptools/command/easy_install.py  (working copy)
> >@@ -1249,7 +1249,7 @@
> >          if tag not in (0x1234567A, 0x1234567B):
> >              return None     # not a valid tag
> >
> >-        f.seek(prepended-(12+cfglen+bmlen))
> >+        f.seek(prepended-(12+cfglen))
> 
> I can't see how bdist_wininst for Python 2.3 or better can generate a file 
> that's missing the 'bmlen' value or has garbage in it.  bmlen corresponds 
> to the 'bitmaplen' value generated by the bdist_wininst command, and it 
> should be a zero if there was no custom bitmap added.
> 
> In other words, the .exe you're having problems with doesn't seem like it 
> could've been produced by an unmodified distutils bdist_wininst command, as 
> I've checked the SVN logs for that module and it's been 5 years since 
> bdist_wininst had the 'bitmaplen' value added.

Well, that would make sense since the bdist_wininst command writes the
bitmap *before* the config, not after as easy_install assumes.  So,
easy_install is seeking to the beginning of the bitmap as shown by the
data here:

>>> f.seek(prepended-(12+cfglen+bmlen))
>>> f.read(5)
'BM.\x9c\x00'

So, seeking to the beginning of the config should omit the bmlen:

>>> f.seek(prepended-(12+cfglen))
>>> f.read(10)
'[metadata]'

This is true at least back to Python 2.2:
        if bitmap:
            file.write(bitmapdata)

        file.write(cfgdata)


The Trac installer I was testing on is available here:
http://trac.edgewall.org/wiki/TracDownload

-- 
Matt Good <matt at matt-good.net>



More information about the Distutils-SIG mailing list