tests: Skip "discovered python matches invoked" on macOS 11/Python 2.7/Vanilla

pull/1032/head
Alex Willmer 8 months ago
parent 5ad3d14ceb
commit 92c00d913e

@ -2,6 +2,7 @@
# https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/?view=azure-pipelines&viewFallbackFrom=azure-devops#tool # https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/?view=azure-pipelines&viewFallbackFrom=azure-devops#tool
# `{script: ...}` is shorthand for `{task: CmdLine@<mumble>, inputs: {script: ...}}`. # `{script: ...}` is shorthand for `{task: CmdLine@<mumble>, inputs: {script: ...}}`.
# The shell is bash.
# https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/steps-script?view=azure-pipelines # https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/steps-script?view=azure-pipelines
# https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/cmd-line-v2?view=azure-pipelines # https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/cmd-line-v2?view=azure-pipelines
@ -20,9 +21,23 @@ steps:
condition: and(eq(variables['python.version'], ''), eq(variables['Agent.OS'], 'Linux')) condition: and(eq(variables['python.version'], ''), eq(variables['Agent.OS'], 'Linux'))
- script: | - script: |
type python && python --version # macOS builders lack a realpath command
type python2 && python2 --version type python && python -c"import os.path;print(os.path.realpath('$(type -p python)'))" && python --version
type python3 && python3 --version type python2 && python2 -c"import os.path;print(os.path.realpath('$(type -p python2)'))" && python2 --version
type python3 && python3 -c"import os.path;print(os.path.realpath('$(type -p python3)'))" && python3 --version
echo
if [ -e /usr/bin/python ]; then
echo "/usr/bin/python: sys.executable: $(/usr/bin/python -c 'import sys; print(sys.executable)')"
fi
if [ -e /usr/bin/python2 ]; then
echo "/usr/bin/python2: sys.executable: $(/usr/bin/python2 -c 'import sys; print(sys.executable)')"
fi
if [ -e /usr/bin/python2.7 ]; then
echo "/usr/bin/python2.7: sys.executable: $(/usr/bin/python2.7 -c 'import sys; print(sys.executable)')"
fi
displayName: Show python versions displayName: Show python versions
- script: | - script: |

@ -54,6 +54,15 @@
fail_msg: fail_msg:
- "auto_out: {{ auto_out }}" - "auto_out: {{ auto_out }}"
- "echoout: {{ echoout }}" - "echoout: {{ echoout }}"
when:
# On macOS 11 (Darwin 20) CI runners the Python 2.7 binary always
# reports the same path. I can't reach via symlinks.
# >>> sys.executable
# /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
- is_mitogen
or echoout.running_python.sys.version_info.major != 2
or not (echoout.running_python.sys.platform == "darwin"
and echoout.running_python.platform.release.major == 20)
- name: test that auto_legacy gives a dep warning when /usr/bin/python present but != auto result - name: test that auto_legacy gives a dep warning when /usr/bin/python present but != auto result

@ -23,11 +23,11 @@ def main():
# revert the Mitogen OSX tweak since discover_interpreter() doesn't return this info # revert the Mitogen OSX tweak since discover_interpreter() doesn't return this info
# NB This must be synced with mitogen.parent.Connection.get_boot_command() # NB This must be synced with mitogen.parent.Connection.get_boot_command()
platform_release_major = int(platform.release().partition('.')[0])
if sys.modules.get('mitogen') and sys.platform == 'darwin': if sys.modules.get('mitogen') and sys.platform == 'darwin':
darwin_major = int(platform.release().partition('.')[0]) if platform_release_major < 19 and sys.executable == '/usr/bin/python2.7':
if darwin_major < 19 and sys.executable == '/usr/bin/python2.7':
sys.executable = '/usr/bin/python' sys.executable = '/usr/bin/python'
if darwin_major in (20, 21) and sys.version_info[:2] == (2, 7): if platform_release_major in (20, 21) and sys.version_info[:2] == (2, 7):
# only for tests to check version of running interpreter -- Mac 10.15+ changed python2 # only for tests to check version of running interpreter -- Mac 10.15+ changed python2
# so it looks like it's /usr/bin/python but actually it's /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python # so it looks like it's /usr/bin/python but actually it's /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
sys.executable = "/usr/bin/python" sys.executable = "/usr/bin/python"
@ -46,12 +46,21 @@ def main():
'resolved': os.path.realpath(discovered_interpreter_python), 'resolved': os.path.realpath(discovered_interpreter_python),
}, },
'running_python': { 'running_python': {
'platform': {
'release': {
'major': platform_release_major,
},
},
'sys': { 'sys': {
'executable': { 'executable': {
'as_seen': sys.executable, 'as_seen': sys.executable,
'resolved': os.path.realpath(sys.executable), 'resolved': os.path.realpath(sys.executable),
}, },
'platform': sys.platform, 'platform': sys.platform,
'version_info': {
'major': sys.version_info[0],
'minor': sys.version_info[1],
},
}, },
}, },
} }

Loading…
Cancel
Save