[Idle-dev] CVS: idle PyShell.py,1.27,1.28

Tony Lownds tonylownds@users.sourceforge.net
Sat, 28 Sep 2002 17:34:13 -0700


Update of /cvsroot/idlefork/idle
In directory usw-pr-cvs1:/tmp/cvs-serv3073

Modified Files:
	PyShell.py 
Log Message:
Finding a suitable interpreter to spawn needed tweaking on the Mac

Index: PyShell.py
===================================================================
RCS file: /cvsroot/idlefork/idle/PyShell.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -r1.27 -r1.28
*** PyShell.py	23 Sep 2002 04:10:37 -0000	1.27
--- PyShell.py	29 Sep 2002 00:34:10 -0000	1.28
***************
*** 161,169 ****
      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)]
          self.rpcpid = os.spawnv(os.P_NOWAIT, args[0], args)
  
      def start_subprocess(self):
--- 161,182 ----
      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)]
          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):