@@ -1724,15 +1724,23 @@ def get_platform_python_info(self, python_h_required: bool = False):
17241724
17251725 Returns a path to a Python executable suitable for testing on
17261726 this platform and its associated include path, library path and
1727- library name.
1727+ library name. ``runtest.py`` sets an environment variable with the
1728+ desired Python path, so if we're started from there, use that.
1729+
1730+ This exists because of SWIG, which may need to build things against
1731+ the Python header and library. The approach is a bit of a large
1732+ hammer: we run a script like we would a test, and capture the results,
1733+ rather than querying the running Python. This supports the test
1734+ runner's ``-P`` option to specify an alternate Python, otherwise
1735+ we wouldn't need to be this complex.
17281736
17291737 If the Python executable or Python header (if required)
17301738 is not found, the test is skipped.
17311739
17321740 Returns:
17331741 tuple: path to python, include path, library path, library name
17341742 """
1735- python = os .environ .get ('python_executable' , self . where_is ( 'python' ) )
1743+ python = os .environ .get ('python_executable' , sys . executable )
17361744 if not python :
17371745 self .skip_test (
17381746 'Can not find installed "python", skipping test.\n ' , from_fw = True
0 commit comments