Giovanni Bajo <[EMAIL PROTECTED]> wrote:

>> This patch makes Build.py pass --strip-loadconf by default to UPX when
used
>> under Windows and Python 2.4. It also adds --best to UPX by default as it
>> makes sense to use the best compression if UPX is available.
>>
>> Committed as r251. I really wanted this in PyInstaller 1.1 and I had
>> forgotten about it. So I'm tagging this as RC2.

As a followup, we need at least UPX 1.92 to support --strip-loadconf. I made
so Configure.py check UPX version and disable UPX support if UPX is older
than that (and we're using Python 2.4 under Windows). Committed as r252.
-- 
Giovanni Bajo
Index: Build.py
===================================================================
--- Build.py    (revision 251)
+++ Build.py    (working copy)
@@ -47,7 +47,8 @@
     is24 = hasattr(sys, "version_info") and sys.version_info[:2] >= (2,4)
     if iswin and is24:
         # Binaries built with Visual Studio 7.1 require --strip-loadconf
-        # or they won't compress.
+        # or they won't compress. Configure.py makes sure that UPX is new
+        # enough to support --strip-loadconf.
         f = "--strip-loadconf " + f
     f = "--best " + f
     os.environ["UPX"] = f
Index: Configure.py
===================================================================
--- Configure.py        (revision 246)
+++ Configure.py        (working copy)
@@ -20,6 +20,7 @@
 import os, sys, string, shutil
 HOME = os.path.dirname(sys.argv[0])
 iswin = sys.platform[:3] == 'win'
+is24 = hasattr(sys, "version_info") and sys.version_info[:2] >= (2,4)
 cygwin = sys.platform == 'cygwin'
 configfile = os.path.join(HOME, 'config.dat')
 try:
@@ -192,16 +193,16 @@
 print 'I: testing for UPX...'
 hasUPX = 0
 try:
-    if iswin:
-        os.system('upx -V >upx.txt')
-        txt = open('upx.txt','r').read()
-        os.remove('upx.txt')
-        if txt[:3] == 'upx':
-            hasUPX = 1
+    vers = os.popen("upx -V").readlines()
+    if not vers:
+        hasUPX = 0
     else:
-        rc = os.system('upx -V >/dev/null')
-        hasUPX = ( rc == 0 )
-    print 'I: ...UPX %s' % (('unavailable','available')[hasUPX])
+        v = string.split(vers[0])[1]
+        hasUPX = tuple(map(int, string.split(v, ".")))
+        if iswin and is24 and hasUPX < (1,92):
+            print 'E: UPX is too old! Python 2.4 under Windows requires UPX 
1.92+'
+            hasUPX = 0
+    print 'I: ...UPX %s' % (('unavailable','available')[hasUPX != 0])
 except Exception, e:
     print 'I: ...exception result in testing for UPX'
     print e, e.args
_______________________________________________
PyInstaller mailing list
[email protected]
http://lists.hpcf.upr.edu/mailman/listinfo/pyinstaller

Reply via email to