Browse Source

pzip: use Python zlib module to perform pzip step

This is more useful when cross-compiling, not requiring a functional pzip binary on the host.
rdb 5 years ago
parent
commit
1a5fd04499
1 changed files with 10 additions and 1 deletions
  1. 10 1
      makepanda/makepanda.py

+ 10 - 1
makepanda/makepanda.py

@@ -30,6 +30,11 @@ import time
 import os
 import sys
 
+try:
+    import zlib
+except:
+    zlib = None
+
 ########################################################################
 ##
 ## PARSING THE COMMAND LINE OPTIONS
@@ -1904,7 +1909,11 @@ def CompileEgg(eggfile, src, opts):
         oscmd(flt2egg + ' -ps keep -o ' + BracketNameWithQuotes(eggfile) + ' ' + BracketNameWithQuotes(src))
 
     if pz:
-        oscmd(pzip + ' ' + BracketNameWithQuotes(eggfile))
+        if zlib:
+            WriteBinaryFile(eggfile + '.pz', zlib.compress(ReadBinaryFile(eggfile)))
+            os.remove(eggfile)
+        else:
+            oscmd(pzip + ' ' + BracketNameWithQuotes(eggfile))
 
 ##########################################################################################
 #