From 57c5f23a7ba575637e30c792320387d5c7be1ae2 Mon Sep 17 00:00:00 2001 From: "Jan Winkler (jwi)" Date: Tue, 19 Aug 2025 16:19:59 +0200 Subject: [PATCH 1/3] Ensure symbolic macro compatibility for py_console_script_binary --- python/private/py_console_script_binary.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/private/py_console_script_binary.bzl b/python/private/py_console_script_binary.bzl index d98457dbe1..988e550c89 100644 --- a/python/private/py_console_script_binary.bzl +++ b/python/private/py_console_script_binary.bzl @@ -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", entry_points_txt = entry_points_txt or _dist_info(pkg), out = main, console_script = script, From 79b3f8665c38e387f3d647829b513d9e1df772aa Mon Sep 17 00:00:00 2001 From: "Jan Winkler (jwi)" Date: Tue, 19 Aug 2025 16:50:56 +0200 Subject: [PATCH 2/3] Reformat --- python/private/py_console_script_binary.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/private/py_console_script_binary.bzl b/python/private/py_console_script_binary.bzl index 988e550c89..f912fe5323 100644 --- a/python/private/py_console_script_binary.bzl +++ b/python/private/py_console_script_binary.bzl @@ -79,7 +79,7 @@ def py_console_script_binary( fail("passing 'srcs' attribute to py_console_script_binary is unsupported") py_console_script_gen( - name = name + "_gen", + name = name + "_gen", entry_points_txt = entry_points_txt or _dist_info(pkg), out = main, console_script = script, From 16d708d3a1125e6b81b216fc23462fca60dc8c88 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Sat, 11 Oct 2025 13:47:13 +0900 Subject: [PATCH 3/3] minor adjustments --- CHANGELOG.md | 2 ++ python/private/py_console_script_binary.bzl | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a86dd01a9f..04e01a9c03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -108,6 +108,8 @@ END_UNRELEASED_TEMPLATE variants. Setting {obj}`--py_linux_libc=musl` and `--py_freethreaded=yes` now activate them, respectively. ([#3262](https://github.com/bazel-contrib/rules_python/issues/3262)). +* (rules) {obj}`py_console_script_binary` is now compatible with symbolic macros + ([#3195](https://github.com/bazel-contrib/rules_python/pull/3195)). {#v0-0-0-added} ### Added diff --git a/python/private/py_console_script_binary.bzl b/python/private/py_console_script_binary.bzl index f912fe5323..0dda44e7b9 100644 --- a/python/private/py_console_script_binary.bzl +++ b/python/private/py_console_script_binary.bzl @@ -53,6 +53,7 @@ def py_console_script_binary( script = None, binary_rule = py_binary, shebang = "", + main = None, **kwargs): """Generate a py_binary for a console_script entry_point. @@ -66,6 +67,8 @@ def py_console_script_binary( package as the `pkg` Label. script: {type}`str`, The console script name that the py_binary is going to be generated for. Defaults to the normalized name attribute. + main: {type}`str`, the python file to be generated, defaults to `_entry_point.py` to + be compatible with symbolic macros. binary_rule: {type}`callable`, The rule/macro to use to instantiate the target. It's expected to behave like {obj}`py_binary`. Defaults to {obj}`py_binary`. @@ -73,13 +76,13 @@ def py_console_script_binary( Defaults to empty string. **kwargs: Extra parameters forwarded to `binary_rule`. """ - main = name + "_entry_point.py" + main = main or 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 = name + "_gen", + name = name + "_gen__", entry_points_txt = entry_points_txt or _dist_info(pkg), out = main, console_script = script,