diff --git a/uv/pip.bzl b/uv/pip.bzl index eaec087..5e0897e 100644 --- a/uv/pip.bzl +++ b/uv/pip.bzl @@ -7,6 +7,7 @@ load("//uv/private:pip.bzl", "pip_compile_test", _pip_compile = "pip_compile") def pip_compile( name, requirements_in = None, + requirements_ins = [], requirements_txt = None, target_compatible_with = None, python_platform = None, @@ -21,6 +22,8 @@ def pip_compile( name: name of the primary compilation target. requirements_in: (optional, default "//:requirements.in") a label for the requirements.in file. May also be provided as a list of strings which represent the requirements file lines. + requirements_ins: (optional, default []) a list of labels for additional requirements.in files. + These files will be concatenated together in the order they are provided. requirements_txt: (optional, default "//:requirements.txt") a label for the requirements.txt file. python_platform: (optional) a uv pip compile compatible value for --python-platform. target_compatible_with: (optional) specify that a particular target is compatible only with certain @@ -38,6 +41,20 @@ def pip_compile( [name].update: an alias for [name] [name]_test: a testable target that will check that requirements_txt is up to date with requirements_in """ + + if requirements_ins: + if requirements_in: + fail("Cannot provide both requirements_in and requirements_ins") + write_target = "_{}.write".format(name) + native.genrule( + name = write_target, + srcs = requirements_ins, + outs = ["_{}.in".format(name)], + # use `awk 1` instead of `cat` ensures trailing newlines for each file + cmd = "awk 1 {} > $(OUTS)".format(" ".join(["$(location {})".format(r) for r in requirements_ins])), + ) + requirements_in = write_target + requirements_in = requirements_in or "//:requirements.in" requirements_txt = requirements_txt or "//:requirements.txt" tags = tags or []