Skip to content

Commit

Permalink
Add Windows libs test to current_py_cc_libs tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nicholasjng committed Apr 5, 2024
1 parent 2ee0e92 commit 26af5b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 16 additions & 0 deletions tests/cc/current_py_cc_libs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,19 @@ cc_test(
"@rules_python//python/cc:current_py_cc_libs",
],
)

# This is technically a headers test, but since the pyconfig.h header
# designates the appropriate lib to link on Win+MSVC, this test verifies that
# the expected Windows libraries are all present in the expected location.
# Since we define the Py_LIMITED_API macro, we expect the linker to go search
# for libs/python3.lib.
# buildifier: disable=native-cc
cc_test(
name = "python_libs_linking_windows_test",
srcs = ["python_libs_linking_test.cc"],
defines = ["Py_LIMITED_API=0x030A0000"],
target_compatible_with = ["@platforms//os:windows"],
deps = [
"@rules_python//python/cc:current_py_cc_headers",
],
)
1 change: 0 additions & 1 deletion tests/cc/current_py_cc_libs/python_libs_linking_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ int main(int argc, char** argv) {
// To make it actually run, more custom initialization is necessary.
// See https://docs.python.org/3/c-api/intro.html#embedding-python
Py_Initialize();
PyRun_SimpleString("print('Hello, world')\n");
Py_Finalize();
return 0;
}

0 comments on commit 26af5b5

Please sign in to comment.