4242import inspect
4343import logging
4444import os
45- import platform
4645import re
4746import signal
4847import socket
@@ -1410,9 +1409,12 @@ def __repr__(self):
14101409 # their respective values.
14111410 # * CONTEXT_NAME must be prefixed with the name of the Python binary in
14121411 # order to allow virtualenvs to detect their install prefix.
1413- # * For Darwin, OS X installs a craptacular argv0-introspecting Python
1414- # version switcher as /usr/bin/python. Override attempts to call it
1415- # with an explicit call to python2.7
1412+ # * macOS <= 10.14 (Darwin <= 18) install an unreliable Python version
1413+ # switcher as /usr/bin/python, which introspects argv0. To workaround
1414+ # it we redirect attempts to call /usr/bin/python with an explicit
1415+ # call to /usr/bin/python2.7. macOS 10.15+ (Darwin 19+) removed it.
1416+ # On these versions /usr/bin/python is a symlink to
1417+ # /System/Library/Frameworks/Python.framework/Versions/2.7/.../Python
14161418 #
14171419 # Locals:
14181420 # R: read side of interpreter stdin.
@@ -1435,11 +1437,7 @@ def _first_stage():
14351437 os .close (r )
14361438 os .close (W )
14371439 os .close (w )
1438- # this doesn't apply anymore to Mac OSX 10.15+ (Darwin 19+), new interpreter looks like this:
1439- # /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
1440- if sys .platform == 'darwin' and sys .executable == '/usr/bin/python' and \
1441- int (platform .release ()[:2 ]) < 19 :
1442- sys .executable += sys .version [:3 ]
1440+ if sys .executable + sys .platform == '/usr/bin/pythondarwin' and os .uname ()[2 ]< '19' :sys .executable += '2.7'
14431441 os .environ ['ARGV0' ]= sys .executable
14441442 os .execl (sys .executable ,sys .executable + '(mitogen:CONTEXT_NAME)' )
14451443 os .write (1 ,'MITO000\n ' .encode ())
0 commit comments