Blender V2.61 - r43446
|
00001 # ***** BEGIN GPL LICENSE BLOCK ***** 00002 # 00003 # This program is free software; you can redistribute it and/or 00004 # modify it under the terms of the GNU General Public License 00005 # as published by the Free Software Foundation; either version 2 00006 # of the License, or (at your option) any later version. 00007 # 00008 # This program is distributed in the hope that it will be useful, 00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 # GNU General Public License for more details. 00012 # 00013 # You should have received a copy of the GNU General Public License 00014 # along with this program; if not, write to the Free Software Foundation, 00015 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00016 # 00017 # Contributor(s): Campbell Barton 00018 # 00019 # #**** END GPL LICENSE BLOCK #**** 00020 00021 # <pep8 compliant> 00022 00023 """ 00024 This script runs inside blender and compiles all scripts into pyc files which 00025 blender uses as modules. 00026 00027 ./blender.bin --background -noaudio --python source/tools/compile_scripts.py 00028 """ 00029 00030 00031 def main(): 00032 try: 00033 import bpy 00034 except ImportError: 00035 print("Run this script from within blender") 00036 return 00037 00038 import os 00039 import compileall 00040 00041 compile_paths = [] 00042 00043 print("compiling blender/python scripts") 00044 00045 # check for portable python install 00046 path_user = bpy.utils.resource_path('USER') 00047 path_local = bpy.utils.resource_path('LOCAL') 00048 if bpy.path.is_subdir(os.__file__, path_user): 00049 print(" found local python:", path_user) 00050 compile_paths.append(os.path.join(path_user, "python", "lib")) 00051 elif bpy.path.is_subdir(os.__file__, path_local): 00052 print(" found user python:", path_user) 00053 compile_paths.append(os.path.join(path_local, "python", "lib")) 00054 else: 00055 print(" found system python - skipping compile") 00056 00057 # blender script dirs 00058 scripts = os.path.normpath(os.path.join(bpy.__file__, "..", "..", "..")) 00059 print(" found `bpy` scripts:", scripts) 00060 compile_paths.extend((os.path.join(scripts, "startup"), 00061 os.path.join(scripts, "modules"), 00062 os.path.join(scripts, "addons"), 00063 )) 00064 00065 print(" compiling paths...") 00066 for fp in compile_paths: 00067 print(" %r" % fp) 00068 00069 for fp in compile_paths: 00070 compileall.compile_dir(fp, force=True) 00071 00072 00073 if __name__ == '__main__': 00074 main()