From 884a72ee86f7d62858aa1c6df1e4de7fbae34c5f Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sat, 23 Jun 2018 19:54:44 +0100 Subject: [PATCH] issue #277: core: move Darwin versioner check into first stage The 'versioner.c' dodging check added in 0ef23d86 was wrong, since the check occurred on the host machine, when the fix actually needs to apply to the Darwin target. Fixes ability to target OS X from a Red Hat controller, manifesting as an error like: D mitogen: mitogen.parent.TtyLogStream('local.2472'): 'python(mitogen:dmw@localhost.localdomain:2449): realpath couldn\'t resolve "/usr/bin/python(mitogen:dmw@localhost.localdomain:2449)"' The "realpath couldn't resolve" error comes from versioner.c: https://opensource.apple.com/source/perl/perl-104/versioner/versioner.c --- mitogen/parent.py | 10 +++++----- mitogen/ssh.py | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/mitogen/parent.py b/mitogen/parent.py index 899f8955..aeebc43a 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -686,11 +686,6 @@ class Stream(mitogen.core.Stream): self.max_message_size = max_message_size if python_path: self.python_path = python_path - if sys.platform == 'darwin' and self.python_path == '/usr/bin/python': - # 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 - self.python_path = '/usr/bin/python2.7' if connect_timeout: self.connect_timeout = connect_timeout if remote_name is None: @@ -775,6 +770,9 @@ class Stream(mitogen.core.Stream): # substituted with 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 @staticmethod def _first_stage(): R,W=os.pipe() @@ -787,6 +785,8 @@ class Stream(mitogen.core.Stream): os.close(r) os.close(W) os.close(w) + if sys.platform == 'darwin' and sys.executable == '/usr/bin/python': + sys.executable += sys.version[:3] os.environ['ARGV0']=sys.executable os.execl(sys.executable,sys.executable+'(mitogen:CONTEXT_NAME)') os.write(1,'EC0\n') diff --git a/mitogen/ssh.py b/mitogen/ssh.py index 5e81ff46..5c0df8dc 100644 --- a/mitogen/ssh.py +++ b/mitogen/ssh.py @@ -91,7 +91,6 @@ class HostKeyError(mitogen.core.StreamError): class Stream(mitogen.parent.Stream): create_child = staticmethod(mitogen.parent.hybrid_tty_create_child) child_is_immediate_subprocess = False - python_path = 'python2.7' #: Number of -v invocations to pass on command line. ssh_debug_level = 0