diff options
author | Tony Lownds <tony@lownds.com> | 2002-12-20 04:24:43 +0000 |
---|---|---|
committer | Tony Lownds <tony@lownds.com> | 2002-12-20 04:24:43 +0000 |
commit | f53dec2e4e8a017641db4de73456a2724a75e64b (patch) | |
tree | ecf208ab3789dd429ac9757287dc60cbe7835bbc /Lib/idlelib/macosx_main.py | |
parent | 24475896dd7c80695cb1b632fba37afd99d3b71b (diff) | |
download | cpython-git-f53dec2e4e8a017641db4de73456a2724a75e64b.tar.gz |
Update way a subprocess is launched for Mac OS X.
Another applet mechanism has been developed for Python on Mac OS X and
trying to use the -c "__import__('run').main()" trick is just not working.
macosx_main.py is a new file which should be used as the startup file for
Mac OS X applet bundles. This startup file understands a -p option, which
when seen will start run.main(). When running as an applet, this seems like
the best approach.
Diffstat (limited to 'Lib/idlelib/macosx_main.py')
-rw-r--r-- | Lib/idlelib/macosx_main.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Lib/idlelib/macosx_main.py b/Lib/idlelib/macosx_main.py new file mode 100644 index 0000000000..88e4197e85 --- /dev/null +++ b/Lib/idlelib/macosx_main.py @@ -0,0 +1,46 @@ +"""IDLE.app + +Installation: + see the install_IDLE target in python/dist/src/Mac/OSX/Makefile + +Usage: + +1. Double clicking IDLE icon will open IDLE. +2. Dropping file on IDLE icon will open that file in IDLE. +3. Launch from command line with files with this command-line: + + /Applications/Python/IDLE.app/Contents/MacOS/python file1 file2 file3 + +""" + +# Add IDLE.app/Contents/Resources/idlelib to path. +# __file__ refers to this file when it is used as a module, sys.argv[0] +# refers to this file when it is used as a script (pythonw macosx_main.py) +import sys + +from os.path import split, join, isdir +try: + __file__ +except NameError: + __file__ = sys.argv[0] +idlelib = join(split(__file__)[0], 'idlelib') +if isdir(idlelib): + sys.path.append(idlelib) + +# Make sure True, False, bool() builtins exist. +# - preserves 2.2 compatibility - 2.2.1 includes bool, 2.2 does not. +# - important for Mac OS X because it ships python 2.2 +import boolcheck + +# see if we are being asked to execute the subprocess code +if '-p' in sys.argv: + # run expects only the port number in sys.argv + sys.argv.remove('-p') + + # this module will become the namepsace used by the interactive + # interpreter; remove all variables we have defined. + del sys, __file__, boolcheck, split, join + __import__('run').main() +else: + # Load idlelib/idle.py which starts the application. + import idle |