summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/PyShell.py
diff options
context:
space:
mode:
authorTony Lownds <tony@lownds.com>2002-12-20 04:24:43 (GMT)
committerTony Lownds <tony@lownds.com>2002-12-20 04:24:43 (GMT)
commitf53dec2e4e8a017641db4de73456a2724a75e64b (patch)
treeecf208ab3789dd429ac9757287dc60cbe7835bbc /Lib/idlelib/PyShell.py
parent24475896dd7c80695cb1b632fba37afd99d3b71b (diff)
downloadcpython-f53dec2e4e8a017641db4de73456a2724a75e64b.zip
cpython-f53dec2e4e8a017641db4de73456a2724a75e64b.tar.gz
cpython-f53dec2e4e8a017641db4de73456a2724a75e64b.tar.bz2
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/PyShell.py')
-rw-r--r--Lib/idlelib/PyShell.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index 5af9ca0..e13bafc 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -298,24 +298,27 @@ class ModifiedInterpreter(InteractiveInterpreter):
rpcpid = None
def spawn_subprocess(self):
- w = ['-W' + s for s in sys.warnoptions]
- args = [self.find_executable()] + w \
- + ["-c", "__import__('run').main()", str(self.port)]
+ args = self.build_subprocess_arglist()
self.rpcpid = os.spawnv(os.P_NOWAIT, args[0], args)
- def find_executable(self):
- if sys.platform == 'darwin' and sys.executable.count('.app'):
- # On Mac OS X, avoid calling sys.executable because it ignores
- # command-line options (sys.executable is an applet)
+ def build_subprocess_arglist(self):
+ if sys.platform == 'darwin' and sys.argv[0].count('.app'):
+ # We need to avoid using sys.executable because it fails on some
+ # of the applet architectures On Mac OS X.
#
- # Instead, find the executable by looking relative to
- # sys.prefix.
- executable = os.path.join(sys.prefix, 'Resources',
- 'Python.app', 'Contents',
- 'MacOS', 'python')
- return executable
+ # here are the applet architectures tried:
+ #
+ # framework applet: sys.executable + -p is correct
+ # python 2.2 + pure python main applet:
+ # sys.executable + -p is correct
+ # pythonw idle.py: sys.executable + -c is correct
+ #
+ # XXX what about warnoptions?
+ return [sys.executable, '-p', str(self.port)]
else:
- return sys.executable
+ w = ['-W' + s for s in sys.warnoptions]
+ return [sys.executable] + w \
+ + ["-c", "__import__('run').main()", str(self.port)]
def start_subprocess(self):
addr = ("localhost", self.port)
@@ -1174,6 +1177,7 @@ def main():
fixwordbreaks(root)
root.withdraw()
flist = PyShellFileList(root)
+
if enable_edit:
if not (cmd or script):
for filename in args: