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 'build_files/scons/tools/Blender.py')
-rw-r--r--build_files/scons/tools/Blender.py163
1 files changed, 49 insertions, 114 deletions
diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py
index cab245a4518..ad4df1a60c1 100644
--- a/build_files/scons/tools/Blender.py
+++ b/build_files/scons/tools/Blender.py
@@ -20,7 +20,7 @@ import string
import glob
import time
import sys
-import zipfile
+import tarfile
import shutil
import cStringIO
import platform
@@ -399,89 +399,13 @@ def set_quiet_output(env):
if env['BF_LINE_OVERWRITE']:
SCons.Action._ActionAction.print_cmd_line = my_print_cmd_line
-
-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):
- if sys.version_info < (2, 6):
- zipfile.ZipFile.__init__(self, file, mode, compression)
- else:
- 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')
+def untar_pybundle(from_tar,to_dir,exclude_re):
+ tar= tarfile.open(from_tar, 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():
+ for name in tar.getnames():
is_bad= 0
for r in exclude_re:
if r.match(name):
@@ -489,26 +413,26 @@ def unzip_pybundle(from_zip,to_dir,exclude_re):
if debug: print name
break
if not is_bad:
- good.append(name)
+ good.append(tar.getmember(name))
if debug:
print '\nFiles being unpacked:\n'
for g in good:
print g
else:
- zip.extractall(to_dir, good)
+ tar.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_tar= env.subst( env['LCGDIR'] )
+ if py_tar[0]=='#':
+ py_tar= py_tar[1:]
if env['BF_DEBUG']:
- py_zip+= '/release/python' + env['BF_PYTHON_VERSION'].replace('.','') + '_d.zip'
+ py_tar+= '/release/python' + env['BF_PYTHON_VERSION'].replace('.','') + '_d.tar.gz'
else:
- py_zip+= '/release/python' + env['BF_PYTHON_VERSION'].replace('.','') + '.zip'
+ py_tar+= '/release/python' + env['BF_PYTHON_VERSION'].replace('.','') + '.tar.gz'
py_target = env.subst( env['BF_INSTALLDIR'] )
if py_target[0]=='#':
@@ -525,8 +449,8 @@ def WinPyBundle(target=None, source=None, env=None):
re.compile('^idlelib/.*'),
re.compile('^lib2to3/.*'),
re.compile('^tkinter/.*')]
- print "Unpacking '" + py_zip + "' to '" + py_target + "'"
- unzip_pybundle(py_zip,py_target,exclude_re)
+ print "Unpacking '" + py_tar + "' to '" + py_target + "'"
+ untar_pybundle(py_tar,py_target,exclude_re)
def my_appit_print(target, source, env):
a = '%s' % (target[0])
@@ -546,6 +470,7 @@ def AppIt(target=None, source=None, env=None):
installdir = env['BF_INSTALLDIR']
print("compiled architecture: %s"%(osxarch))
print("Installing to %s"%(installdir))
+ # TODO, use tar.
python_zip = 'python_' + osxarch + '.zip' # set specific python_arch.zip
print("unzipping to app-bundle: %s"%(python_zip))
bldroot = env.Dir('.').abspath
@@ -563,7 +488,8 @@ def AppIt(target=None, source=None, env=None):
if os.path.isdir(cmd):
shutil.rmtree(cmd)
shutil.copytree(sourcedir, cmd)
- cmd = "cat %s | sed s/VERSION/`cat release/VERSION`/ | sed s/DATE/`date +'%%Y-%%b-%%d'`/ > %s"%(sourceinfo,targetinfo)
+ cmd = "cat %s | sed s/\$\{MACOSX_BUNDLE_SHORT_VERSION_STRING\}/%s/ | "%(sourceinfo,VERSION)
+ cmd += "sed s/\$\{MACOSX_BUNDLE_LONG_VERSION_STRING\}/%s,\ %s/g > %s"%(VERSION,time.strftime("%Y-%b-%d"),targetinfo)
commands.getoutput(cmd)
cmd = 'cp %s/%s %s/%s.app/Contents/MacOS/%s'%(builddir, binary,installdir, binary, binary)
commands.getoutput(cmd)
@@ -624,31 +550,36 @@ def UnixPyBundle(target=None, source=None, env=None):
print '\t"%s"' % py_target
print '\t(skipping copy)\n'
return
-
-
+
# Copied from source/creator/CMakeLists.txt, keep in sync.
print 'Install python from:'
- print '\t"%s" into...' % py_src
- print '\t"%s"\n' % py_target
+ print '\t"%s" into...' % py_src
+ print '\t"%s"\n' % py_target
+
+ run("rm -rf '%s'" % py_target)
+ try:
+ os.makedirs(os.path.dirname(py_target)) # the final part is copied
+ except:
+ pass
+
+ run("cp -R '%s' '%s'" % (py_src, os.path.dirname(py_target)))
+ run("rm -rf '%s/distutils'" % py_target)
+ run("rm -rf '%s/lib2to3'" % py_target)
+ run("rm -rf '%s/idlelib'" % py_target)
+ run("rm -rf '%s/tkinter'" % py_target)
+ run("rm -rf '%s/config'" % py_target)
+
+ run("rm -rf '%s/site-packages'" % py_target)
+ run("mkdir '%s/site-packages'" % py_target) # python needs it.'
+
+ run("rm -f '%s/lib-dynload/_tkinter.so'" % py_target)
+ run("find '%s' -type d -name 'test' -prune -exec rm -rf {} ';'" % py_target)
+ run("find '%s' -type d -name 'config-*' -prune -exec rm -rf {} ';'" % py_target)
+ run("find '%s' -type d -name 'turtledemo' -prune -exec rm -rf {} ';'" % py_target)
+ run("find '%s' -type d -name '__pycache__' -exec rm -rf {} ';'" % py_target)
+ run("find '%s' -name '*.py[co]' -exec rm -rf {} ';'" % py_target)
+ run("find '%s' -name '*.so' -exec strip -s {} ';'" % py_target)
- run('rm -rf "%s"' % py_target)
- try: os.makedirs(os.path.dirname(py_target)) # the final part is copied
- except:pass
-
- run('cp -R "%s" "%s"' % (py_src, os.path.dirname(py_target)))
- run('rm -rf "%s/distutils"' % py_target)
- run('rm -rf "%s/lib2to3"' % py_target)
- run('rm -rf "%s/idlelib"' % py_target)
- run('rm -rf "%s/tkinter"' % py_target)
- run('rm -rf "%s/config"' % py_target)
-
- run('rm -rf "%s/site-packages"' % py_target)
- run('mkdir "%s/site-packages"' % py_target) # python needs it.'
-
- run('rm -f "%s/lib-dynload/_tkinter.so"' % py_target)
- run('find "%s" -name "test" -prune -exec rm -rf {} \;' % py_target)
- run('find "%s" -name "*.py?" -exec rm -rf {} \;' % py_target)
- run('find "%s" -name "*.so"-exec strip -s {} \;' % py_target)
#### END ACTION STUFF #########
@@ -675,6 +606,8 @@ def bsc(env, target, source):
class BlenderEnvironment(SConsEnvironment):
+ PyBundleActionAdded = False
+
def BlenderRes(self=None, libname=None, source=None, libtype=['core'], priority=[100]):
global libs
if not self or not libname or not source:
@@ -818,12 +751,14 @@ class BlenderEnvironment(SConsEnvironment):
lenv.AddPostAction(prog,Action(AppIt,strfunction=my_appit_print))
elif os.sep == '/' and lenv['OURPLATFORM'] != 'linuxcross': # any unix (except cross-compilation)
if lenv['WITH_BF_PYTHON']:
- if not lenv['WITHOUT_BF_INSTALL'] and not lenv['WITHOUT_BF_PYTHON_INSTALL']:
+ if not lenv['WITHOUT_BF_INSTALL'] and not lenv['WITHOUT_BF_PYTHON_INSTALL'] and not BlenderEnvironment.PyBundleActionAdded:
lenv.AddPostAction(prog,Action(UnixPyBundle,strfunction=my_unixpybundle_print))
+ BlenderEnvironment.PyBundleActionAdded = True
elif lenv['OURPLATFORM'].startswith('win') or lenv['OURPLATFORM'] == 'linuxcross': # windows or cross-compilation
if lenv['WITH_BF_PYTHON']:
- if not lenv['WITHOUT_BF_PYTHON_INSTALL']:
+ if not lenv['WITHOUT_BF_PYTHON_INSTALL'] and not BlenderEnvironment.PyBundleActionAdded:
lenv.AddPostAction(prog,Action(WinPyBundle,strfunction=my_winpybundle_print))
+ BlenderEnvironment.PyBundleActionAdded = True
return prog
def Glob(lenv, pattern):