Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/private/py_console_script_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ def py_console_script_binary(
Defaults to empty string.
**kwargs: Extra parameters forwarded to `binary_rule`.
"""
main = "rules_python_entry_point_{}.py".format(name)
main = name + "_entry_point.py"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity, could you please explain why you've selected to use this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, too, is required for symbolic macro compatibility. The original .format() approach created filenames that also violated the naming rules [1].

[1] https://bazel.build/extending/macros - "Naming conventions for targets created"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention here was to create a file with the same name as the legacy entry point python file within the whl_library repository rule. I am OK with this being changed though.


if kwargs.pop("srcs", None):
fail("passing 'srcs' attribute to py_console_script_binary is unsupported")

py_console_script_gen(
name = "_{}_gen".format(name),
name = name + "_gen",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is making the target as foo_gen instead of _foo_gen that it previously was.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this naming change is intentional. The underscore prefix violates Bazel's symbolic macro naming rules. Per the documentation [1], targets created by a symbolic macro must be named either the same as the macro or prefixed by the macro name followed by _, ., or -. The new naming satisfies this requirement.

[1] https://bazel.build/extending/macros - "Naming conventions for targets created"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial implementation was on purpose - we did not want this target to be depended upon. How would you propose we do this moving to the future?

entry_points_txt = entry_points_txt or _dist_info(pkg),
out = main,
console_script = script,
Expand Down