~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/tools/compile_scripts.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 # ***** BEGIN GPL LICENSE BLOCK *****
 
2
 #
 
3
 # This program is free software; you can redistribute it and/or
 
4
 # modify it under the terms of the GNU General Public License
 
5
 # as published by the Free Software Foundation; either version 2
 
6
 # of the License, or (at your option) any later version.
 
7
 #
 
8
 # This program is distributed in the hope that it will be useful,
 
9
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 # GNU General Public License for more details.
 
12
 #
 
13
 # You should have received a copy of the GNU General Public License
 
14
 # along with this program; if not, write to the Free Software Foundation,
 
15
 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
16
 #
 
17
 # Contributor(s): Campbell Barton
 
18
 #
 
19
 # #**** END GPL LICENSE BLOCK #****
 
20
 
 
21
# <pep8 compliant>
 
22
 
 
23
"""
 
24
This script runs inside blender and compiles all scripts into pyc files which
 
25
blender uses as modules.
 
26
 
 
27
./blender.bin --background -noaudio --python source/tools/compile_scripts.py
 
28
"""
 
29
 
 
30
 
 
31
def main():
 
32
    try:
 
33
        import bpy
 
34
    except ImportError:
 
35
        print("Run this script from within blender")
 
36
        return
 
37
 
 
38
    import os
 
39
    import compileall
 
40
 
 
41
    compile_paths = []
 
42
 
 
43
    print("compiling blender/python scripts")
 
44
 
 
45
    # check for portable python install
 
46
    path_user = bpy.utils.resource_path('USER')
 
47
    path_local = bpy.utils.resource_path('LOCAL')
 
48
    if bpy.path.is_subdir(os.__file__, path_user):
 
49
        print("  found local python:", path_user)
 
50
        compile_paths.append(os.path.join(path_user, "python", "lib"))
 
51
    elif bpy.path.is_subdir(os.__file__, path_local):
 
52
        print("  found user python:", path_user)
 
53
        compile_paths.append(os.path.join(path_local, "python", "lib"))
 
54
    else:
 
55
        print("  found system python - skipping compile")
 
56
 
 
57
    # blender script dirs
 
58
    scripts = os.path.normpath(os.path.join(bpy.__file__, "..", "..", ".."))
 
59
    print("  found `bpy` scripts:", scripts)
 
60
    compile_paths.extend((os.path.join(scripts, "startup"),
 
61
                          os.path.join(scripts, "modules"),
 
62
                          os.path.join(scripts, "addons"),
 
63
                          ))
 
64
 
 
65
    print("  compiling paths...")
 
66
    for fp in compile_paths:
 
67
        print("  %r" % fp)
 
68
 
 
69
    for fp in compile_paths:
 
70
        compileall.compile_dir(fp, force=True)
 
71
 
 
72
 
 
73
if __name__ == '__main__':
 
74
    main()