From 332d1999c3fb16496240d74ee555a253ea939693 Mon Sep 17 00:00:00 2001 From: Mark Elliot <123787712+mark-thm@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:35:45 -0500 Subject: [PATCH 1/2] Add support for uv's --universal arg --- uv/pip.bzl | 4 ++++ uv/private/pip.bzl | 3 +++ 2 files changed, 7 insertions(+) diff --git a/uv/pip.bzl b/uv/pip.bzl index eaec087..a8fe003 100644 --- a/uv/pip.bzl +++ b/uv/pip.bzl @@ -10,6 +10,7 @@ def pip_compile( requirements_txt = None, target_compatible_with = None, python_platform = None, + universal = False, args = None, data = None, tags = None, @@ -23,6 +24,7 @@ def pip_compile( May also be provided as a list of strings which represent the requirements file lines. 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. + universal: (optional, default False) use UV's `--universal` option target_compatible_with: (optional) specify that a particular target is compatible only with certain Bazel platforms. args: (optional) override the default arguments passed to uv pip compile, default arguments are: @@ -55,6 +57,7 @@ def pip_compile( requirements_in = requirements_in, requirements_txt = requirements_txt, python_platform = python_platform, + universal = universal, target_compatible_with = target_compatible_with, data = data, uv_args = args, @@ -74,6 +77,7 @@ def pip_compile( requirements_in = requirements_in, requirements_txt = requirements_txt, python_platform = python_platform or "", + universal = universal, target_compatible_with = target_compatible_with, data = data, uv_args = args, diff --git a/uv/private/pip.bzl b/uv/private/pip.bzl index 0dd7a90..2239ec7 100644 --- a/uv/private/pip.bzl +++ b/uv/private/pip.bzl @@ -15,6 +15,7 @@ _COMMON_ATTRS = { "requirements_in": attr.label(mandatory = True, allow_single_file = True), "requirements_txt": attr.label(mandatory = True, allow_single_file = True), "python_platform": attr.string(), + "universal": attr.bool(), "py3_runtime": attr.label(), "data": attr.label_list(allow_files = True), "uv_args": attr.string_list(default = _DEFAULT_ARGS), @@ -52,6 +53,8 @@ def _uv_pip_compile( args.append("--python-version={version}".format(version = _python_version(py3_runtime))) if ctx.attr.python_platform: args.append("--python-platform={platform}".format(platform = ctx.attr.python_platform)) + elif ctx.attr.universal: + args.append("--universal") ctx.actions.expand_template( template = template, From ba478debce97c631c38d5b399e149bac174c5c81 Mon Sep 17 00:00:00 2001 From: Mark Elliot <123787712+mark-thm@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:51:56 -0500 Subject: [PATCH 2/2] Update pip.bzl --- uv/pip.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uv/pip.bzl b/uv/pip.bzl index a8fe003..91197af 100644 --- a/uv/pip.bzl +++ b/uv/pip.bzl @@ -24,7 +24,7 @@ def pip_compile( May also be provided as a list of strings which represent the requirements file lines. 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. - universal: (optional, default False) use UV's `--universal` option + universal: (optional, default False) use uv's `--universal` option target_compatible_with: (optional) specify that a particular target is compatible only with certain Bazel platforms. args: (optional) override the default arguments passed to uv pip compile, default arguments are: