|
1 | 1 | # gh-91321: Build a basic C++ test extension to check that the Python C API is |
2 | 2 | # compatible with C++ and does not emit C++ compiler warnings. |
3 | 3 | import os |
4 | | -import platform |
5 | 4 | import shlex |
6 | 5 | import sys |
7 | 6 | import sysconfig |
@@ -48,6 +47,8 @@ def main(): |
48 | 47 | module_name = os.environ["CPYTHON_TEST_EXT_NAME"] |
49 | 48 | limited = bool(os.environ.get("CPYTHON_TEST_LIMITED", "")) |
50 | 49 | internal = bool(int(os.environ.get("TEST_INTERNAL_C_API", "0"))) |
| 50 | + incdirs = os.environ.get("CPYTHON_EXTRA_INCDIRS", "") |
| 51 | + libdirs = os.environ.get("CPYTHON_EXTRA_LIBDIRS", "") |
51 | 52 |
|
52 | 53 | cppflags = list(CPPFLAGS) |
53 | 54 | cppflags.append(f'-DMODULE_NAME={module_name}') |
@@ -90,19 +91,16 @@ def main(): |
90 | 91 | if extra_cflags: |
91 | 92 | cppflags.extend(shlex.split(extra_cflags)) |
92 | 93 |
|
93 | | - # On Windows, add PCbuild\amd64\ to include and library directories |
| 94 | + # Add additional include and library directories, typically for in-tree |
| 95 | + # testing where not all directories are inferred |
94 | 96 | include_dirs = [] |
95 | 97 | library_dirs = [] |
96 | | - if support.MS_WINDOWS: |
97 | | - srcdir = sysconfig.get_config_var('srcdir') |
98 | | - machine = platform.uname().machine |
99 | | - pcbuild = os.path.join(srcdir, 'PCbuild', machine) |
100 | | - if os.path.exists(pcbuild): |
101 | | - # pyconfig.h is generated in PCbuild\amd64\ |
102 | | - include_dirs.append(pcbuild) |
103 | | - # python313.lib is generated in PCbuild\amd64\ |
104 | | - library_dirs.append(pcbuild) |
105 | | - print(f"Add PCbuild directory: {pcbuild}") |
| 98 | + if incdirs: |
| 99 | + print("Add incdirs:", incdirs) |
| 100 | + include_dirs.extend(incdirs.split(os.pathsep)) |
| 101 | + if libdirs: |
| 102 | + print("Add libdirs:", libdirs) |
| 103 | + library_dirs.extend(libdirs.split(os.pathsep)) |
106 | 104 |
|
107 | 105 | # Display information to help debugging |
108 | 106 | for env_name in ('CC', 'CXX', 'CFLAGS', 'CPPFLAGS', 'CXXFLAGS'): |
|
0 commit comments