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,