Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tools/Blender.py')
-rw-r--r--tools/Blender.py139
1 files changed, 135 insertions, 4 deletions
diff --git a/tools/Blender.py b/tools/Blender.py
index 1b0573cfda4..fec11685525 100644
--- a/tools/Blender.py
+++ b/tools/Blender.py
@@ -20,6 +20,9 @@ import string
import glob
import time
import sys
+import zipfile
+import shutil
+import cStringIO
from SCons.Script.SConscript import SConsEnvironment
import SCons.Action
@@ -327,6 +330,128 @@ def set_quiet_output(env):
env['BUILDERS']['Library'] = static_lib
env['BUILDERS']['Program'] = program
+
+class CompZipFile(zipfile.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
+
+ 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
+ debug= 0 #list files instead of unpacking
+ good= []
+ if debug: print '\nFiles not being unpacked:\n'
+ for name in zip.namelist():
+ is_bad= 0
+ for r in exclude_re:
+ if r.match(name):
+ is_bad=1
+ if debug: print name
+ break
+ if not is_bad:
+ good.append(name)
+ if debug:
+ print '\nFiles being unpacked:\n'
+ for g in good:
+ print g
+ else:
+ zip.extractall(to_dir, good)
+
+def my_winpybundle_print(target, source, env):
+ pass
+
+def WinPyBundle(target=None, source=None, env=None):
+ import re
+ py_zip= env.subst( env['LCGDIR'] )
+ if py_zip[0]=='#':
+ py_zip= py_zip[1:]
+ py_zip+= '/release/python' + env['BF_PYTHON_VERSION'].replace('.','') + '.zip'
+
+ py_target = env.subst( env['BF_INSTALLDIR'] )
+ if py_target[0]=='#':
+ py_target=py_target[1:]
+ py_target+= '/.blender/python/lib/'
+ def printexception(func,path,ex):
+ if os.path.exists(path): #do not report if path does not exist. eg on a fresh build.
+ print str(func) + ' failed on ' + str(path)
+ print "Trying to remove existing py bundle."
+ shutil.rmtree(py_target, False, printexception)
+ exclude_re=[re.compile('.*/test/.*'),
+ re.compile('^config/.*'),
+ re.compile('^distutils/.*'),
+ re.compile('^idlelib/.*'),
+ re.compile('^lib2to3/.*'),
+ re.compile('^tkinter/.*')]
+ print "Unpacking '" + py_zip + "' to '" + py_target + "'"
+ unzip_pybundle(py_zip,py_target,exclude_re)
+
def my_appit_print(target, source, env):
a = '%s' % (target[0])
d, f = os.path.split(a)
@@ -392,10 +517,10 @@ def AppIt(target=None, source=None, env=None):
# extract copy system python, be sure to update other build systems
# when making changes to the files that are copied.
-def my_pyinst_print(target, source, env):
+def my_unixpybundle_print(target, source, env):
pass
-def PyInstall(target=None, source=None, env=None):
+def UnixPyBundle(target=None, source=None, env=None):
# Any Unix except osx
#-- .blender/python/lib/python3.1
@@ -522,6 +647,9 @@ class BlenderEnvironment(SConsEnvironment):
lenv.Append(CCFLAGS = lenv['CC_WARN'])
lenv.Append(CXXFLAGS = lenv['CXX_WARN'])
+ if lenv['OURPLATFORM'] == 'win64-vc':
+ lenv.Append(LINKFLAGS = ['/MACHINE:X64'])
+
if lenv['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
if lenv['BF_DEBUG']:
lenv.Append(CCFLAGS = ['/MTd'])
@@ -602,8 +730,11 @@ class BlenderEnvironment(SConsEnvironment):
elif os.sep == '/': # any unix
if lenv['WITH_BF_PYTHON']:
if not lenv['WITHOUT_BF_INSTALL'] and not lenv['WITHOUT_BF_PYTHON_INSTALL']:
- lenv.AddPostAction(prog,Action(PyInstall,strfunction=my_pyinst_print))
-
+ lenv.AddPostAction(prog,Action(UnixPyBundle,strfunction=my_unixpybundle_print))
+ elif lenv['OURPLATFORM'].startswith('win'): # windows
+ if lenv['WITH_BF_PYTHON']:
+ if not lenv['WITHOUT_BF_PYTHON_INSTALL']:
+ lenv.AddPostAction(prog,Action(WinPyBundle,strfunction=my_winpybundle_print))
return prog
def Glob(lenv, pattern):