Skip to content

refactor(cc): simplify _current_py_cc_libs_impl - #3993

Merged
rickeylev merged 3 commits into
bazel-contrib:mainfrom
rickeylev:simplify_py_cc_libs
Aug 4, 2026
Merged

refactor(cc): simplify _current_py_cc_libs_impl#3993
rickeylev merged 3 commits into
bazel-contrib:mainfrom
rickeylev:simplify_py_cc_libs

Conversation

@rickeylev

@rickeylev rickeylev commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Commit 0d6016f accidentally added complex filtering logic for static libraries and DLLs to _current_py_cc_libs_impl in python/private/current_py_cc_libs.bzl. That extra filtering logic was actually a hack to support another hack in py_extension, and shouldn't have been added.

To simplify, update _current_py_cc_libs_impl to return py_cc_toolchain.libs.providers_map.values() directly.

Since Windows was relying on that hack, move it into a helper rule in the
py_extension implementation.

…filtering

Commit 0d6016f accidentally added complex
filtering logic for static libraries, DLLs, and runfiles to
_current_py_cc_libs_impl. Simplify the rule implementation to return
py_cc_toolchain.libs.providers_map.values() directly.
…oolchain rule

Windows toolchain libraries use system_provided=True in cc_import, which
leaves DefaultInfo empty and causes $(locations //python/cc:current_py_cc_libs)
to expand to no files. Introduce a private py_extension_libs rule in
py_extension_rule.bzl that uses toolchain resolution to extract linkable .lib
files from CcInfo.linking_context and returns them in DefaultInfo for MSVC link.exe.
…target

Add tags = ["manual"] to the internal py_extension_libs helper target in
py_extension_macro.bzl to prevent it from being implicitly built when
wildcard target patterns are built.
@rickeylev
rickeylev force-pushed the simplify_py_cc_libs branch from d2acb97 to efe13fe Compare August 3, 2026 23:30
@rickeylev
rickeylev marked this pull request as ready for review August 4, 2026 02:50
@rickeylev
rickeylev requested a review from aignas as a code owner August 4, 2026 02:50
@rickeylev

Copy link
Copy Markdown
Collaborator Author

Ok, this is ready now. I think there's a more proper fix that needs to go into the toolchain, but i couldn't figure out how windows .lib files are supposed to make their way into downstream consumers. So this works for now.

@rickeylev
rickeylev enabled auto-merge August 4, 2026 02:51
@rickeylev
rickeylev added this pull request to the merge queue Aug 4, 2026
Merged via the queue into bazel-contrib:main with commit 7eb4a6b Aug 4, 2026
6 checks passed
@rickeylev
rickeylev deleted the simplify_py_cc_libs branch August 4, 2026 13:17
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.

2 participants