[Pythonmac-SIG] bdist_mpkg zipdist and unzip(1) (was ANN: pygame 1.7.0 for Mac OS X 10.3)

Robert Kern rkern at ucsd.edu
Mon Mar 21 04:02:44 CET 2005

Robert Kern wrote:

> Using /usr/bin/unzip to unzip the package seems to strip the executable 
> flags from these files. Stuffit Expander seems to work fine.

I've traced the problem to a deficiency in Python's zipfile (well, one 
could equally say that there is a deficiency in Info-Zip's code, but 
Python is still wrong regardless). I have attached a workaround patch to 

Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter
-------------- next part --------------
Index: src/bdist_mpkg/cmd_bdist_mpkg.py
--- src/bdist_mpkg/cmd_bdist_mpkg.py	(revision 426)
+++ src/bdist_mpkg/cmd_bdist_mpkg.py	(working copy)
@@ -434,6 +434,15 @@
                 if os.path.splitext(fn)[1] == '.gz':
                     compression= zipfile.ZIP_STORED
                 z.write(fn, arcfn, compression)
+        # ZipFile always marks the files' attributes to be interpreted as if
+        # they came from a Windows host. This interferes with some software
+        # (namely unzip(1) from Info-Zip) from extracting executables with the
+        # proper file attributes. So manually fix the appropriate attributes on
+        # each of the ZipInfo's to specify the host system as a UNIX.
+        for zinfo in z.filelist:
+            zinfo.create_system = 3 # UNIX
     def copy_tree(self, infile, outfile,

More information about the Pythonmac-SIG mailing list