diff --git a/docs/changelog.rst b/docs/changelog.rst index 7a1ae039..5609430f 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -25,6 +25,7 @@ v0.3.1.dev0 (unreleased) * :gh:issue:`869` Continuous Integration tests are now run with Tox * :gh:issue:`869` Continuous Integration tests now cover CentOS 6 & 8, Debian 9 & 11, Ubuntu 16.04 & 20.04 * :gh:issue:`860` Add initial support for podman connection (w/o Ansible support yet) +* :gh:issue:`873` `python -c ...` first stage no longer uses :py:mod:`platform`` to detect the macOS release v0.3.0 (2021-11-24) diff --git a/mitogen/parent.py b/mitogen/parent.py index 7ca90ab4..251aee66 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -42,7 +42,6 @@ import heapq import inspect import logging import os -import platform import re import signal import socket @@ -1410,9 +1409,12 @@ class Connection(object): # their respective values. # * CONTEXT_NAME must be prefixed with the name of the Python binary in # order to allow virtualenvs to detect their install prefix. - # * For Darwin, OS X installs a craptacular argv0-introspecting Python - # version switcher as /usr/bin/python. Override attempts to call it - # with an explicit call to python2.7 + # * macOS <= 10.14 (Darwin <= 18) install an unreliable Python version + # switcher as /usr/bin/python, which introspects argv0. To workaround + # it we redirect attempts to call /usr/bin/python with an explicit + # call to /usr/bin/python2.7. macOS 10.15+ (Darwin 19+) removed it. + # On these versions /usr/bin/python is a symlink to + # /System/Library/Frameworks/Python.framework/Versions/2.7/.../Python # # Locals: # R: read side of interpreter stdin. @@ -1435,11 +1437,7 @@ class Connection(object): os.close(r) os.close(W) os.close(w) - # this doesn't apply anymore to Mac OSX 10.15+ (Darwin 19+), new interpreter looks like this: - # /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python - if sys.platform == 'darwin' and sys.executable == '/usr/bin/python' and \ - int(platform.release()[:2]) < 19: - sys.executable += sys.version[:3] + if sys.executable+sys.platform=='/usr/bin/pythondarwin'and os.uname()[2]<'19':sys.executable+='2.7' os.environ['ARGV0']=sys.executable os.execl(sys.executable,sys.executable+'(mitogen:CONTEXT_NAME)') os.write(1,'MITO000\n'.encode())