]> granicus.if.org Git - python/commitdiff
Finding a suitable interpreter to spawn needed tweaking on the Mac
authorTony Lownds <tony@lownds.com>
Sun, 29 Sep 2002 00:34:10 +0000 (00:34 +0000)
committerTony Lownds <tony@lownds.com>
Sun, 29 Sep 2002 00:34:10 +0000 (00:34 +0000)
Lib/idlelib/PyShell.py

index 3a819a8317fefeddc6c3ea23cedcc58985f81f9b..195942fd259097baa286a3f001f07d9fbdcffe7e 100644 (file)
@@ -160,12 +160,25 @@ class ModifiedInterpreter(InteractiveInterpreter):
     rpcclt = None
     rpcpid = None
 
-    def spawn_subprocess(self):
-        w = ['-W' + s for s in sys.warnoptions]
-        args = [sys.executable] + w + ["-c", "__import__('run').main()",
-                                       str(self.port)]
+    def spawn_subprocess(self):         
+        w = ['-W' + s for s in sys.warnoptions]        
+        args = [self.find_executable()] + w \
+             + ["-c", "__import__('run').main()", str(self.port)]
         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)
+            #
+            # Instead, find the executable by looking relative to
+            # sys.prefix.
+            executable = os.path.join(sys.prefix, 'Resources', 
+                                'Python.app', 'Contents', 'MacOS', 'python')
+            return executable
+        else:
+            return sys.executable 
+
     def start_subprocess(self):
         addr = ("localhost", self.port)
         self.spawn_subprocess()