-
-
Notifications
You must be signed in to change notification settings - Fork 621
Make py_console_script_binary
compatible with symbolic macros
#3195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
||
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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is making the target as There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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.