From 35041bf3bf7cb7a3e7901282b01a1f8677d8c77d Mon Sep 17 00:00:00 2001 From: Artemy Granat Date: Sun, 28 Jun 2026 22:54:20 +0300 Subject: [PATCH] fix: add explicit `data` attribute to `compile_pip_requirements` and forward it to the generated `py_binary` --- news/3858.fixed.md | 2 ++ python/private/pypi/pip_compile.bzl | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 news/3858.fixed.md diff --git a/news/3858.fixed.md b/news/3858.fixed.md new file mode 100644 index 0000000000..5cb1d029a2 --- /dev/null +++ b/news/3858.fixed.md @@ -0,0 +1,2 @@ +(compile_pip_requirements) Add the explicit `data` attribute and forward it to +the generated `py_binary`. diff --git a/python/private/pypi/pip_compile.bzl b/python/private/pypi/pip_compile.bzl index 3ef2cdb39c..de7e12892a 100644 --- a/python/private/pypi/pip_compile.bzl +++ b/python/private/pypi/pip_compile.bzl @@ -39,6 +39,7 @@ def pip_compile( visibility = ["//visibility:private"], tags = None, constraints = [], + data = [], **kwargs): """Generates targets for managing pip dependencies with pip-compile (piptools). @@ -81,6 +82,7 @@ def pip_compile( tags: tagging attribute common to all build rules, passed to both the _test and .update rules. visibility: passed to both the _test and .update rules. constraints: a list of files containing constraints to pass to pip-compile with `--constraint`. + data: A list of labels to include as part of the `data` attribute in the generated `py_binary`. **kwargs: other bazel attributes passed to the "_test" rule. """ if len([x for x in [srcs, src, requirements_in] if x != None]) > 1: @@ -100,11 +102,11 @@ def pip_compile( # for a requirements file that does `-r ../other/requirements.txt` native.filegroup( name = name, - srcs = kwargs.pop("data", []) + [requirements_txt], + srcs = data + [requirements_txt], visibility = visibility, ) - data = [name, requirements_txt] + srcs + [f for f in (requirements_linux, requirements_darwin, requirements_windows) if f != None] + constraints + data = data + [name, requirements_txt] + srcs + [f for f in (requirements_linux, requirements_darwin, requirements_windows) if f != None] + constraints # Use the Label constructor so this is expanded in the context of the file # where it appears, which is to say, in @rules_python