source: trunk/essentials/dev-lang/python/Mac/scripts/BuildApplet.py

Last change on this file was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 5.2 KB
Line 
1"""Create an applet from a Python script.
2
3This puts up a dialog asking for a Python source file ('TEXT').
4The output is a file with the same name but its ".py" suffix dropped.
5It is created by copying an applet template and then adding a 'PYC '
6resource named __main__ containing the compiled, marshalled script.
7"""
8
9
10import sys
11sys.stdout = sys.stderr
12
13import os
14import MacOS
15import EasyDialogs
16import buildtools
17import getopt
18
19if not sys.executable.startswith(sys.exec_prefix):
20 # Oh, the joys of using a python script to bootstrap applicatin bundles
21 # sys.executable points inside the current application bundle. Because this
22 # path contains blanks (two of them actually) this path isn't usable on
23 # #! lines. Reset sys.executable to point to the embedded python interpreter
24 sys.executable = os.path.join(sys.prefix,
25 'Resources/Python.app/Contents/MacOS/Python')
26
27 # Just in case we're not in a framework:
28 if not os.path.exists(sys.executable):
29 sys.executable = os.path.join(sys.exec_prefix, 'bin/python')
30
31def main():
32 try:
33 buildapplet()
34 except buildtools.BuildError, detail:
35 EasyDialogs.Message(detail)
36
37