Skip to content

Commit a2f14eb

Browse files
janwinkler1aignas
andauthored
fix(rules): make py_console_script_binary compatible with symbolic macros (#3195)
Fixes target naming to follow symbolic macro conventions introduced in Bazel 8.0. --------- Co-authored-by: Ignas Anikevicius <[email protected]>
1 parent 7eebd60 commit a2f14eb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ END_UNRELEASED_TEMPLATE
108108
variants. Setting {obj}`--py_linux_libc=musl` and `--py_freethreaded=yes` now
109109
activate them, respectively.
110110
([#3262](https://github.com/bazel-contrib/rules_python/issues/3262)).
111+
* (rules) {obj}`py_console_script_binary` is now compatible with symbolic macros
112+
([#3195](https://github.com/bazel-contrib/rules_python/pull/3195)).
111113

112114
{#v0-0-0-added}
113115
### Added

python/private/py_console_script_binary.bzl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def py_console_script_binary(
5353
script = None,
5454
binary_rule = py_binary,
5555
shebang = "",
56+
main = None,
5657
**kwargs):
5758
"""Generate a py_binary for a console_script entry_point.
5859
@@ -66,20 +67,22 @@ def py_console_script_binary(
6667
package as the `pkg` Label.
6768
script: {type}`str`, The console script name that the py_binary is going to be
6869
generated for. Defaults to the normalized name attribute.
70+
main: {type}`str`, the python file to be generated, defaults to `<name>_entry_point.py` to
71+
be compatible with symbolic macros.
6972
binary_rule: {type}`callable`, The rule/macro to use to instantiate
7073
the target. It's expected to behave like {obj}`py_binary`.
7174
Defaults to {obj}`py_binary`.
7275
shebang: {type}`str`, The shebang to use for the entry point python file.
7376
Defaults to empty string.
7477
**kwargs: Extra parameters forwarded to `binary_rule`.
7578
"""
76-
main = "rules_python_entry_point_{}.py".format(name)
79+
main = main or name + "_entry_point.py"
7780

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

8184
py_console_script_gen(
82-
name = "_{}_gen".format(name),
85+
name = name + "_gen__",
8386
entry_points_txt = entry_points_txt or _dist_info(pkg),
8487
out = main,
8588
console_script = script,

0 commit comments

Comments
 (0)