Skip to content

Commit 26af5b5

Browse files
committed
Add Windows libs test to current_py_cc_libs tests
Reuses the existing cc_test targeting the stable ABI on Windows. Since this prompts MSVC to search for libs/python3.lib, it serves as a check that the library search path is intact on Windows.
1 parent 2ee0e92 commit 26af5b5

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

tests/cc/current_py_cc_libs/BUILD.bazel

+16
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,19 @@ cc_test(
3131
"@rules_python//python/cc:current_py_cc_libs",
3232
],
3333
)
34+
35+
# This is technically a headers test, but since the pyconfig.h header
36+
# designates the appropriate lib to link on Win+MSVC, this test verifies that
37+
# the expected Windows libraries are all present in the expected location.
38+
# Since we define the Py_LIMITED_API macro, we expect the linker to go search
39+
# for libs/python3.lib.
40+
# buildifier: disable=native-cc
41+
cc_test(
42+
name = "python_libs_linking_windows_test",
43+
srcs = ["python_libs_linking_test.cc"],
44+
defines = ["Py_LIMITED_API=0x030A0000"],
45+
target_compatible_with = ["@platforms//os:windows"],
46+
deps = [
47+
"@rules_python//python/cc:current_py_cc_headers",
48+
],
49+
)

tests/cc/current_py_cc_libs/python_libs_linking_test.cc

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ int main(int argc, char** argv) {
1212
// To make it actually run, more custom initialization is necessary.
1313
// See https://docs.python.org/3/c-api/intro.html#embedding-python
1414
Py_Initialize();
15-
PyRun_SimpleString("print('Hello, world')\n");
1615
Py_Finalize();
1716
return 0;
1817
}

0 commit comments

Comments
 (0)