forked from bartvdbraak/blender
== SCons ==
* Unzip of python31.zip now works also for Python 2.5. Patch by b333rt (thanks again!)
This commit is contained in:
parent
6282b7998b
commit
86307b58c0
@ -20,6 +20,9 @@ import string
|
|||||||
import glob
|
import glob
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
|
import zipfile
|
||||||
|
import shutil
|
||||||
|
import cStringIO
|
||||||
|
|
||||||
from SCons.Script.SConscript import SConsEnvironment
|
from SCons.Script.SConscript import SConsEnvironment
|
||||||
import SCons.Action
|
import SCons.Action
|
||||||
@ -328,10 +331,79 @@ def set_quiet_output(env):
|
|||||||
env['BUILDERS']['Program'] = program
|
env['BUILDERS']['Program'] = program
|
||||||
|
|
||||||
|
|
||||||
def unzip_pybundle(from_zip,to_dir,exclude_re):
|
class CompZipFile(zipfile.ZipFile):
|
||||||
import zipfile
|
"""Partial copy of python2.6's zipfile.ZipFile (see http://www.python.org)
|
||||||
|
to get a extractall() that works on py2.5 and probably earlier distributions."""
|
||||||
|
def __init__(self, file, mode="r", compression=zipfile.ZIP_STORED, allowZip64=False):
|
||||||
|
zipfile.ZipFile.__init__(self, file, mode, compression, allowZip64)
|
||||||
|
if not hasattr(self,"extractall"): # use our method
|
||||||
|
print "Debug: Using comp_extractall!"
|
||||||
|
self.extractall= self.comp_extractall
|
||||||
|
|
||||||
zip= zipfile.ZipFile(from_zip, mode='r')
|
def comp_extractall(self, path=None, members=None, pwd=None): #renamed method
|
||||||
|
"""Extract all members from the archive to the current working
|
||||||
|
directory. `path' specifies a different directory to extract to.
|
||||||
|
`members' is optional and must be a subset of the list returned
|
||||||
|
by namelist().
|
||||||
|
"""
|
||||||
|
if members is None:
|
||||||
|
members = self.namelist()
|
||||||
|
|
||||||
|
for zipinfo in members:
|
||||||
|
self.comp_extract(zipinfo, path, pwd) # use our method
|
||||||
|
|
||||||
|
def comp_extract(self, member, path=None, pwd=None): #renamed method
|
||||||
|
"""Extract a member from the archive to the current working directory,
|
||||||
|
using its full name. Its file information is extracted as accurately
|
||||||
|
as possible. `member' may be a filename or a ZipInfo object. You can
|
||||||
|
specify a different directory using `path'.
|
||||||
|
"""
|
||||||
|
if not isinstance(member, zipfile.ZipInfo):
|
||||||
|
member = self.getinfo(member)
|
||||||
|
|
||||||
|
if path is None:
|
||||||
|
path = os.getcwd()
|
||||||
|
|
||||||
|
return self.comp_extract_member(member, path, pwd) # use our method
|
||||||
|
|
||||||
|
def comp_extract_member(self, member, targetpath, pwd): #renamed method
|
||||||
|
"""Extract the ZipInfo object 'member' to a physical
|
||||||
|
file on the path targetpath.
|
||||||
|
"""
|
||||||
|
# build the destination pathname, replacing
|
||||||
|
# forward slashes to platform specific separators.
|
||||||
|
if targetpath[-1:] in (os.path.sep, os.path.altsep):
|
||||||
|
targetpath = targetpath[:-1]
|
||||||
|
|
||||||
|
# don't include leading "/" from file name if present
|
||||||
|
if member.filename[0] == '/':
|
||||||
|
targetpath = os.path.join(targetpath, member.filename[1:])
|
||||||
|
else:
|
||||||
|
targetpath = os.path.join(targetpath, member.filename)
|
||||||
|
|
||||||
|
targetpath = os.path.normpath(targetpath)
|
||||||
|
|
||||||
|
# Create all upper directories if necessary.
|
||||||
|
upperdirs = os.path.dirname(targetpath)
|
||||||
|
if upperdirs and not os.path.exists(upperdirs):
|
||||||
|
os.makedirs(upperdirs)
|
||||||
|
|
||||||
|
if member.filename[-1] == '/':
|
||||||
|
os.mkdir(targetpath)
|
||||||
|
return targetpath
|
||||||
|
|
||||||
|
#use StrinIO instead so we don't have to reproduce more functionality.
|
||||||
|
source = cStringIO.StringIO(self.read(member.filename))
|
||||||
|
target = file(targetpath, "wb")
|
||||||
|
shutil.copyfileobj(source, target)
|
||||||
|
source.close()
|
||||||
|
target.close()
|
||||||
|
|
||||||
|
return targetpath
|
||||||
|
|
||||||
|
def unzip_pybundle(from_zip,to_dir,exclude_re):
|
||||||
|
|
||||||
|
zip= CompZipFile(from_zip, mode='r')
|
||||||
exclude_re= list(exclude_re) #single re object or list of re objects
|
exclude_re= list(exclude_re) #single re object or list of re objects
|
||||||
debug= 0 #list files instead of unpacking
|
debug= 0 #list files instead of unpacking
|
||||||
good= []
|
good= []
|
||||||
@ -356,7 +428,7 @@ def my_winpybundle_print(target, source, env):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def WinPyBundle(target=None, source=None, env=None):
|
def WinPyBundle(target=None, source=None, env=None):
|
||||||
import shutil, re
|
import re
|
||||||
py_zip= env.subst( env['LCGDIR'] )
|
py_zip= env.subst( env['LCGDIR'] )
|
||||||
if py_zip[0]=='#':
|
if py_zip[0]=='#':
|
||||||
py_zip= py_zip[1:]
|
py_zip= py_zip[1:]
|
||||||
|
Loading…
Reference in New Issue
Block a user