MCPcopy
hub / github.com/pex-tool/pex / assert_expected_python

Function assert_expected_python

tests/integration/test_setproctitle.py:115–143  ·  view source on GitHub ↗
(exe)

Source from the content-addressed store, hash-verified

113 process.kill()
114
115 def assert_expected_python(exe):
116 # type: (Text) -> None
117 expected = PythonInterpreter.get().resolve_base_interpreter()
118 actual = PythonInterpreter.from_binary(str(exe)).resolve_base_interpreter()
119 python_framework = sysconfig.get_config_vars().get("PYTHONFRAMEWORKINSTALLDIR")
120 if IS_MAC and expected != actual and python_framework:
121 # Mac framework Python distributions have two Python binaries (starred) as well as
122 # several symlinks. The layout looks like so:
123 # /Library/Frameworks/
124 # Python.framework/ # sysconfig.get_config_var("PYTHONFRAMEWORKINSTALLDIR")
125 # Versions/X.Y/ # sys.prefix
126 # bin/
127 # python -> pythonX.Y
128 # pythonX -> pythonX.Y
129 # *pythonX.Y
130 # Resources/Python.app/
131 # Contents/MacOS/
132 # *Python
133 #
134 # In some versions of Python, the bin Python, when executed, gets a sys.executable of
135 # the corresponding Python resource. On others, they each retain a sys.executable
136 # faithful to their launcher file path. It's the latter type we're working around here.
137 assert python_framework == safe_commonpath(
138 (python_framework, expected.binary, actual.binary)
139 )
140 assert expected.prefix == actual.prefix
141 assert expected.version == actual.version
142 else:
143 assert expected == actual
144
145 pex_file = os.path.join(str(tmpdir), "pex.file")
146 exe, args = grab_ps(pex_file)

Callers 1

test_setproctitleFunction · 0.85

Calls 4

safe_commonpathFunction · 0.90
from_binaryMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected