aboutsummaryrefslogtreecommitdiff
path: root/python/private/bzlmod/requirements.bzl.tmpl
diff options
context:
space:
mode:
Diffstat (limited to 'python/private/bzlmod/requirements.bzl.tmpl')
-rw-r--r--python/private/bzlmod/requirements.bzl.tmpl46
1 files changed, 46 insertions, 0 deletions
diff --git a/python/private/bzlmod/requirements.bzl.tmpl b/python/private/bzlmod/requirements.bzl.tmpl
new file mode 100644
index 0000000..b99322d
--- /dev/null
+++ b/python/private/bzlmod/requirements.bzl.tmpl
@@ -0,0 +1,46 @@
+"""Starlark representation of locked requirements.
+
+@generated by rules_python pip.parse bzlmod extension.
+"""
+
+load("@rules_python//python:pip.bzl", "pip_utils")
+
+all_requirements = %%ALL_REQUIREMENTS%%
+
+all_whl_requirements_by_package = %%ALL_WHL_REQUIREMENTS_BY_PACKAGE%%
+
+all_whl_requirements = all_whl_requirements_by_package.values()
+
+all_data_requirements = %%ALL_DATA_REQUIREMENTS%%
+
+def requirement(name):
+ return "%%MACRO_TMPL%%".format(pip_utils.normalize_name(name), "pkg")
+
+def whl_requirement(name):
+ return "%%MACRO_TMPL%%".format(pip_utils.normalize_name(name), "whl")
+
+def data_requirement(name):
+ return "%%MACRO_TMPL%%".format(pip_utils.normalize_name(name), "data")
+
+def dist_info_requirement(name):
+ return "%%MACRO_TMPL%%".format(pip_utils.normalize_name(name), "dist_info")
+
+def entry_point(pkg, script = None):
+ """entry_point returns the target of the canonical label of the package entrypoints.
+ """
+ actual_script = script or pkg
+
+ fail("""Please replace this instance of entry_point with the following:
+
+```
+load("@rules_python//python/entry_points:py_console_script_binary.bzl", "py_console_script_binary")
+
+py_console_script_binary(
+ name = "{pkg}",
+ pkg = "@%%NAME%%//{pkg}",{script}
+)
+```
+""".format(
+ pkg = pip_utils.normalize_name(pkg),
+ script = "" if not script else "\n script = \"%s\"," % actual_script,
+ ))