mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Finding a suitable interpreter to spawn needed tweaking on the Mac
This commit is contained in:
parent
bffa52f07f
commit
f2324b9e89
1 changed files with 17 additions and 4 deletions
|
@ -160,12 +160,25 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
||||||
rpcclt = None
|
rpcclt = None
|
||||||
rpcpid = None
|
rpcpid = None
|
||||||
|
|
||||||
def spawn_subprocess(self):
|
def spawn_subprocess(self):
|
||||||
w = ['-W' + s for s in sys.warnoptions]
|
w = ['-W' + s for s in sys.warnoptions]
|
||||||
args = [sys.executable] + w + ["-c", "__import__('run').main()",
|
args = [self.find_executable()] + w \
|
||||||
str(self.port)]
|
+ ["-c", "__import__('run').main()", str(self.port)]
|
||||||
self.rpcpid = os.spawnv(os.P_NOWAIT, args[0], args)
|
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):
|
def start_subprocess(self):
|
||||||
addr = ("localhost", self.port)
|
addr = ("localhost", self.port)
|
||||||
self.spawn_subprocess()
|
self.spawn_subprocess()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue