scons support for extracting python from the system on unix os's
authorCampbell Barton <ideasman42@gmail.com>
Mon, 17 Aug 2009 07:34:41 +0000 (07:34 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 17 Aug 2009 07:34:41 +0000 (07:34 +0000)
SConstruct
source/creator/CMakeLists.txt
tools/Blender.py

index 406a65ac5fa9d6cf4f528033edbf18fae215f901..884dd1fb2bd8ff50a869a29da2b981386eb97674 100644 (file)
@@ -60,7 +60,6 @@ B = tools.Blender
 platform = sys.platform
 quickie = None
 quickdebug = None
-nsis_build = None
 
 ##### BEGIN SETUP #####
 
@@ -425,8 +424,6 @@ if  env['OURPLATFORM']=='darwin':
                bundle = '%s.app' % prg[0]
                bundledir = os.path.dirname(bundle)
                for dp, dn, df in os.walk(bundle):
-                       if 'CVS' in dn:
-                               dn.remove('CVS')
                        if '.svn' in dn:
                                dn.remove('.svn')
                        dir=env['BF_INSTALLDIR']+dp[len(bundledir):]
@@ -443,8 +440,6 @@ scriptinstall = []
 
 if  env['OURPLATFORM']!='darwin':
                for dp, dn, df in os.walk('bin/.blender'):
-                       if 'CVS' in dn:
-                               dn.remove('CVS')
                        if '.svn' in dn:
                                dn.remove('.svn')
                        
@@ -471,8 +466,6 @@ if  env['OURPLATFORM']!='darwin':
                        scriptpaths=['release/scripts', 'release/ui', 'release/io']
                        for scriptpath in scriptpaths:
                                for dp, dn, df in os.walk(scriptpath):
-                                       if 'CVS' in dn:
-                                               dn.remove('CVS')
                                        if '.svn' in dn:
                                                dn.remove('.svn')
                                        dir=env['BF_INSTALLDIR']+'/.blender/'+os.path.basename(scriptpath)+dp[len(scriptpath):]
@@ -485,8 +478,6 @@ if env['OURPLATFORM']=='linux2':
        icontargetlist = []
 
        for tp, tn, tf in os.walk('release/freedesktop/icons'):
-               if 'CVS' in tn:
-                       tn.remove('CVS')
                if '.svn' in tn:
                        tn.remove('.svn')
                for f in tf:
@@ -509,8 +500,6 @@ if env['OURPLATFORM']=='linuxcross':
 pluglist = []
 plugtargetlist = []
 for tp, tn, tf in os.walk('release/plugins'):
-       if 'CVS' in tn:
-               tn.remove('CVS')
        if '.svn' in tn:
                tn.remove('.svn')
        for f in tf:
@@ -541,8 +530,6 @@ for targetdir,srcfile in zip(plugtargetlist, pluglist):
 textlist = []
 texttargetlist = []
 for tp, tn, tf in os.walk('release/text'):
-       if 'CVS' in tn:
-               tn.remove('CVS')
        if '.svn' in tn:
                tn.remove('.svn')
        for f in tf:
index c3931a0df1f93e8b914035416b600ac4971da4aa..a0ebf627e2c958410ed21098a9383eddcf570b88 100644 (file)
@@ -121,6 +121,7 @@ IF(WITH_INSTALL)
       )
       
       # Copy the systems python into the install directory
+      # Scons copy in tools/Blender.py
       ADD_CUSTOM_COMMAND(
         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
         COMMENT "copying a subset of the systems python..."
index db888c38935f8f362265cca8f1b6900433bd0cfc..0d2671dbfac0d0a5f029865eded1ed9c65a53bf8 100644 (file)
@@ -383,6 +383,48 @@ def AppIt(target=None, source=None, env=None):
        cmd = 'find %s/%s.app -name .DS_Store -exec rm -rf {} \;'%(builddir, binary)
        commands.getoutput(cmd)
 
+# 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):
+       pass
+
+def PyInstall(target=None, source=None, env=None):
+       # Any Unix except osx
+       #-- .blender/python/lib/python3.1
+       
+       import commands
+       
+       def run(cmd):
+               print 'Install command:', cmd
+               commands.getoutput(cmd)
+       
+       py_src =        env.subst( env['BF_PYTHON_LIBPATH'] + '/python'+env['BF_PYTHON_VERSION'] )
+       py_target =     env.subst( env['BF_INSTALLDIR'] + '/.blender/python/lib/python'+env['BF_PYTHON_VERSION'] )
+       
+       # 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
+       
+       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 "%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 #########
 
 def bsc(env, target, source):
@@ -543,6 +585,11 @@ class BlenderEnvironment(SConsEnvironment):
                if  lenv['OURPLATFORM']=='darwin':
                        lenv['BINARYKIND'] = binarykind
                        lenv.AddPostAction(prog,Action(AppIt,strfunction=my_appit_print))
+               elif os.sep == '/': # any unix
+                       if lenv['WITH_BF_PYTHON']:
+                               if not lenv['WITHOUT_BF_INSTALL']:
+                                       lenv.AddPostAction(prog,Action(PyInstall,strfunction=my_pyinst_print))
+               
                return prog
 
        def Glob(lenv, pattern):