Skip to content

Commit 3df0af6

Browse files
authored
Merge pull request #4754 from mwichmann/test/runtest-py
Minor test-releated tweak for Python selection
2 parents ef5ab0b + 7c10faa commit 3df0af6

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
162162
- Improve the wording of Configure methods.
163163
- Add unit test cases for AppendUnique, PrependUnique - verify behavior
164164
if existing value already contained more than one of added value.
165+
- Tweak runtest.py and test framework to more reliably get the requested
166+
Python binary (for odd Windows setups + Python launcher)
165167

166168

167169
RELEASE 4.9.1 - Thu, 27 Mar 2025 11:40:20 -0700

RELEASE.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ FIXES
8383
as the default path for temporary files includes the username. Setting
8484
(existing) TEMPFILEDIR may also help in this case.
8585

86+
- Tweak runtest.py and test framework to more reliably get the requested
87+
Python binary (for odd Windows setups + Python launcher)
88+
8689
IMPROVEMENTS
8790
------------
8891

runtest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/python
22
#
3-
# Copyright The SCons Foundation
3+
# SPDX-License-Identifier: MIT
44
#
5+
# Copyright The SCons Foundation
6+
57
"""runtest - wrapper script for running SCons tests
68
79
The SCons test suite consists of:

testing/framework/TestSCons.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)