[Distutils] easy_install - some thoughts

Paul Moore p.f.moore at gmail.com
Tue Jul 12 23:11:40 CEST 2005


On 7/12/05, Kevin Dangoor <dangoor at gmail.com> wrote:
> On 7/12/05, Paul Moore <p.f.moore at gmail.com> wrote:
> > By the way, I don't know if the sqlite web page has changed, but your
> > standard example of sqlite doesn't work for me:
> 
> It may be pysqlite.

It's not, it's Python 2.4 :-(

It looks like setuptools.command.easy_install is doing some ugly hacks
to read data out of the raw bdist_wininst file, in
extract_wininst_cfg, and the file format has changed in Python 2.4.

For 2.4, it looks like the "tag" has just changed from 0x1234567A to
0x1234567B... So just checking both values should work. I've attached
a patch.

Still doesn't work, as I get an error about the (not-)zip-safe file:

>python -m easy_install -xd eggs Python\ctypes-0.9.6.win32-py2.4.exe
Processing ctypes-0.9.6.win32-py2.4.exe
ctypes.__init__: module references __file__
ctypes.com.register: module references __file__
error: c:\docume~1\gustav\locals~1\temp\easy_install-unhoeu\ctypes-0.9.6-py2.4-win32.egg.tmp\
EGG-INFO\not-zip-safe: No such file or directory

It looks like the issue is in bdist_egg.py, write_safety_flag, where
an ensure_directory() call is needed. There's a patch for this below,
as well.

But even then, things are going odd, as if I try to build an egg for
ctypes (which isn't zip-safe) all of the files and subdirectories in
the egg directory are missing the first two characters... Hmm, it
happens with zip-safe eggs, as well, so I don't know - maybe it's
related to the bdist_wininst unpacking code. Sorry, I can't debug this
any further.

BTW, it would be useful to have some type of debug flag which left the
temporary directory around for debugging...

Paul.

--- setuptools\command\easy_install.py.orig	2005-07-10 22:26:46.000000000 +0100
+++ setuptools\command\easy_install.py	2005-07-12 21:30:04.718750000 +0100
@@ -877,7 +877,7 @@
 
         import struct, StringIO, ConfigParser
         tag, cfglen, bmlen = struct.unpack("<iii",f.read(12))
-        if tag<>0x1234567A:
+        if tag<>0x1234567A and tag<>0x1234567B:
             return None     # not a valid tag
 
         f.seek(prepended-(12+cfglen+bmlen))

--- \Apps\Python24\Lib\site-packages\setuptools\command\bdist_egg.py.orig	2005-07-10
23:32:28.000000000 +0100
+++ \Apps\Python24\Lib\site-packages\setuptools\command\bdist_egg.py	2005-07-12
21:55:35.781250000 +0100
@@ -8,7 +8,7 @@
 from distutils.dir_util import remove_tree, mkpath
 from distutils.sysconfig import get_python_version, get_python_lib
 from distutils import log
-from pkg_resources import get_platform, Distribution
+from pkg_resources import get_platform, Distribution, ensure_directory
 from types import CodeType
 
 def write_stub(resource, pyfile):
@@ -315,7 +315,9 @@
 def write_safety_flag(egg_dir, safe):
     # Write a zip safety flag file
     flag = safe and 'zip-safe' or 'not-zip-safe'
-    open(os.path.join(egg_dir,'EGG-INFO',flag),'w').close()
+    filename = os.path.join(egg_dir,'EGG-INFO',flag)
+    ensure_directory(filename)
+    open(filename, 'w').close()


More information about the Distutils-SIG mailing list