[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40794] trunk/blender/source/tools/ compile_scripts.py: script to compile all python scripts from within blender, making pyc files for portable python dir, addons, modules and startup scripts.
Campbell Barton
ideasman42 at gmail.com
Wed Oct 5 01:46:40 CEST 2011
Revision: 40794
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40794
Author: campbellbarton
Date: 2011-10-04 23:46:40 +0000 (Tue, 04 Oct 2011)
Log Message:
-----------
script to compile all python scripts from within blender, making pyc files for portable python dir, addons, modules and startup scripts.
Added Paths:
-----------
trunk/blender/source/tools/compile_scripts.py
Added: trunk/blender/source/tools/compile_scripts.py
===================================================================
--- trunk/blender/source/tools/compile_scripts.py (rev 0)
+++ trunk/blender/source/tools/compile_scripts.py 2011-10-04 23:46:40 UTC (rev 40794)
@@ -0,0 +1,74 @@
+ # ***** BEGIN GPL LICENSE BLOCK *****
+ #
+ # This program is free software; you can redistribute it and/or
+ # modify it under the terms of the GNU General Public License
+ # as published by the Free Software Foundation; either version 2
+ # of the License, or (at your option) any later version.
+ #
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software Foundation,
+ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ #
+ # Contributor(s): Campbell Barton
+ #
+ # #**** END GPL LICENSE BLOCK #****
+
+# <pep8 compliant>
+
+"""
+This script runs inside blender and compiles all scripts into pyc files which
+blender uses as modules.
+
+./blender.bin --background --python source/tools/compile_scripts.py
+"""
+
+
+def main():
+ try:
+ import bpy
+ except ImportError:
+ print("Run this script from within blender")
+ return
+
+ import os
+ import compileall
+
+ compile_paths = []
+
+ print("compiling blender/python scripts")
+
+ # check for portable python install
+ path_user = bpy.utils.resource_path('USER')
+ path_local = bpy.utils.resource_path('LOCAL')
+ if bpy.path.is_subdir(os.__file__, path_user):
+ print(" found local python:", path_user)
+ compile_paths.append(os.path.join(path_user, "python", "lib"))
+ elif bpy.path.is_subdir(os.__file__, path_local):
+ print(" found user python:", path_user)
+ compile_paths.append(os.path.join(path_local, "python", "lib"))
+ else:
+ print(" found system python - skipping compile")
+
+ # blender script dirs
+ scripts = os.path.normpath(os.path.join(bpy.__file__, "..", "..", ".."))
+ print(" found `bpy` scripts:", scripts)
+ compile_paths.extend((os.path.join(scripts, "startup"),
+ os.path.join(scripts, "modules"),
+ os.path.join(scripts, "addons"),
+ ))
+
+ print(" compiling paths...")
+ for fp in compile_paths:
+ print(" %r" % fp)
+
+ for fp in compile_paths:
+ compileall.compile_dir(fp, force=True)
+
+
+if __name__ == '__main__':
+ main()
More information about the Bf-blender-cvs
mailing list