xref: /aosp_15_r20/external/bazelbuild-rules_python/examples/bzlmod/entry_points/BUILD.bazel (revision 60517a1edbc8ecf509223e9af94a7adec7d736b8)
1load("@python_versions//3.9:defs.bzl", py_console_script_binary_3_9 = "py_console_script_binary")
2load("@rules_python//python/entry_points:py_console_script_binary.bzl", "py_console_script_binary")
3
4# This is how you can define a `pylint` entrypoint which uses the default python version.
5py_console_script_binary(
6    name = "pylint",
7    pkg = "@pip//pylint",
8    visibility = ["//entry_points:__subpackages__"],
9)
10
11# We can also specify extra dependencies for the binary, which is useful for
12# tools like flake8, pylint, pytest, which have plugin discovery methods.
13py_console_script_binary(
14    name = "pylint_with_deps",
15    pkg = "@pip//pylint",
16    # Because `pylint` has multiple console_scripts available, we have to
17    # specify which we want if the name of the target name 'pylint_with_deps'
18    # cannot be used to guess the entry_point script.
19    script = "pylint",
20    visibility = ["//entry_points:__subpackages__"],
21    deps = [
22        # One can add extra dependencies to the entry point.
23        "@pip//pylint_print",
24    ],
25)
26
27# A specific Python version can be forced by using the generated version-aware
28# wrappers, e.g. to force Python 3.9:
29py_console_script_binary_3_9(
30    name = "yamllint",
31    pkg = "@pip//yamllint:pkg",
32    visibility = ["//entry_points:__subpackages__"],
33)
34