Skip to content

refactor(tests): convert legacy py_extension in local_toolchains to official rule - #3988

Open
rickeylev wants to merge 4 commits into
bazel-contrib:mainfrom
rickeylev:convert_legacy_py_extension
Open

refactor(tests): convert legacy py_extension in local_toolchains to official rule#3988
rickeylev wants to merge 4 commits into
bazel-contrib:mainfrom
rickeylev:convert_legacy_py_extension

Conversation

@rickeylev

Copy link
Copy Markdown
Collaborator

The local_toolchains integration test workspace previously relied on a
custom, partial implementation of py_extension that predated the
official rule.

Replace this legacy test implementation with the official
@rules_python//python/cc:py_extension.bzl rule, simplifying the target
definition to use sources directly.

…fficial rule

The local_toolchains integration test workspace previously relied on a
custom, partial implementation of py_extension that predated the
official rule.

Replace this legacy test implementation with the official
@rules_python//python/cc:py_extension.bzl rule, simplifying the target
definition to use sources directly.
@rickeylev
rickeylev requested a review from aignas as a code owner August 1, 2026 22:14
@rickeylev
rickeylev enabled auto-merge August 1, 2026 22:16
…pansion

When py_extension is invoked from an external module/workspace, expanding  in user_link_flags failed on Windows because the label was not canonicalized to @rules_python//python/cc:current_py_cc_libs.

Use _PY_CC_LIBS_ACTUAL_CANONICAL_TARGET in user_link_flags on Windows.
…ch directories and handle empty link_files

On Windows, when get_local_runtime_info.py finds python3xx.dll in exec_dir, the import library python3xx.lib is typically located in exec_dir/libs. Search across all search_directories for the interface library. Also ensure current_py_cc_libs never outputs an empty DefaultInfo.files so  expansion in py_extension user_link_flags does not crash.
@rickeylev
rickeylev marked this pull request as draft August 1, 2026 22:30
auto-merge was automatically disabled August 1, 2026 22:30

Pull request was converted to draft

@rickeylev

Copy link
Copy Markdown
Collaborator Author

Oh windows...making this difficult again. Lets see how many commits it takes to figure it out this time

…ture Windows local toolchain import libraries

For local Python runtimes on Windows, the CPython interface library (python3xx.lib) is attached to py_cc_toolchain.headers rather than py_cc_toolchain.libs.

By checking the linking_context of both headers and libs in _current_py_cc_libs_impl, current_py_cc_libs properly collects the .lib import library on Windows so MSVC link.exe receives valid import libraries.
@rickeylev
rickeylev marked this pull request as ready for review August 2, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant