Steven M. Gava | d7b6ed2 | 2001-06-25 07:23:57 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | |
Tony Lownds | f53dec2 | 2002-12-20 04:24:43 +0000 | [diff] [blame] | 3 | # Add IDLE.app/Contents/Resources/idlelib to path. |
| 4 | # __file__ refers to this file when it is used as a module, sys.argv[0] |
| 5 | # refers to this file when it is used as a script (pythonw macosx_main.py) |
| 6 | import sys |
| 7 | from os.path import split, join |
| 8 | try: |
| 9 | __file__ |
| 10 | except NameError: |
| 11 | __file__ = sys.argv[0] |
| 12 | idlelib = join(split(__file__)[0], 'idlelib') |
| 13 | if os.path.isdir(idlelib): |
| 14 | sys.path.append(idlelib) |
| 15 | |
| 16 | # Make sure True, False, bool() builtins exist. |
| 17 | # - preserves 2.2 compatibility - 2.2.1 includes bool, 2.2 does not. |
| 18 | # - important for Mac OS X because it ships python 2.2 |
| 19 | import boolcheck |
| 20 | |
| 21 | # see if we are being asked to execute the subprocess code |
| 22 | if '-p' in sys.argv: |
| 23 | # run expects only the port number in sys.argv |
| 24 | sys.argv.remove('-p') |
| 25 | |
| 26 | # this module will become the namepsace used by the interactive |
| 27 | # interpreter; remove all variables we have defined. |
| 28 | del sys, __file__, boolcheck, split, join |
| 29 | __import__('run').main() |
| 30 | else: |
| 31 | # start the application. |
| 32 | import PyShell |
| 33 | PyShell.main() |