BuildIDE.py 1.13 KB
Newer Older
Just van Rossum's avatar
Just van Rossum committed
1 2 3 4
"""Build a "big" applet for the IDE, and put it in the Python home 
directory. It will contain all IDE-specific modules as PYC resources,
which reduces the startup time (especially on slower machines)."""

Just van Rossum's avatar
Just van Rossum committed
5 6 7
import sys
import os
import buildtools
8
from Carbon import Res
Just van Rossum's avatar
Just van Rossum committed
9 10 11 12 13 14 15 16 17 18 19 20 21
import py_resource

buildtools.DEBUG=1

template = buildtools.findtemplate()

ide_home = os.path.join(sys.exec_prefix, ":Mac:Tools:IDE")

mainfilename = os.path.join(ide_home, "PythonIDE.py")
dstfilename = os.path.join(sys.exec_prefix, "Python IDE")

buildtools.process(template, mainfilename, dstfilename, 1)

22
targetref = Res.FSpOpenResFile(dstfilename, 3)
Just van Rossum's avatar
Just van Rossum committed
23 24 25 26
Res.UseResFile(targetref)

files = os.listdir(ide_home)

Just van Rossum's avatar
Just van Rossum committed
27 28 29
# skip this script and the main program
files = filter(lambda x: x[-3:] == '.py' and 
		x not in ("BuildIDE.py", "PythonIDE.py"), files)
Just van Rossum's avatar
Just van Rossum committed
30

Just van Rossum's avatar
Just van Rossum committed
31
# add the modules as PYC resources
Just van Rossum's avatar
Just van Rossum committed
32 33 34 35 36 37
for name in files:
	print "adding", name
	fullpath = os.path.join(ide_home, name)
	id, name = py_resource.frompyfile(fullpath, name[:-3], preload=1,
		ispackage=0)

Just van Rossum's avatar
Just van Rossum committed
38
# add W resources
39
wresref = Res.FSpOpenResFile(os.path.join(ide_home, "Widgets.rsrc"), 1)
Just van Rossum's avatar
Just van Rossum committed
40
buildtools.copyres(wresref, targetref, [], 0)
Just van Rossum's avatar
Just van Rossum committed
41