| 1 | """Create an applet from a Python script.
|
|---|
| 2 |
|
|---|
| 3 | This puts up a dialog asking for a Python source file ('TEXT').
|
|---|
| 4 | The output is a file with the same name but its ".py" suffix dropped.
|
|---|
| 5 | It is created by copying an applet template and then adding a 'PYC '
|
|---|
| 6 | resource named __main__ containing the compiled, marshalled script.
|
|---|
| 7 | """
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 | import sys
|
|---|
| 11 | sys.stdout = sys.stderr
|
|---|
| 12 |
|
|---|
| 13 | import os
|
|---|
| 14 | import MacOS
|
|---|
| 15 | import EasyDialogs
|
|---|
| 16 | import buildtools
|
|---|
| 17 | import getopt
|
|---|
| 18 |
|
|---|
| 19 | if 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 |
|
|---|
| 31 | def main():
|
|---|
| 32 | try:
|
|---|
| 33 | buildapplet()
|
|---|
| 34 | except buildtools.BuildError, detail:
|
|---|
| 35 | EasyDialogs.Message(detail)
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
|
|---|