Skip to content

Commit

Permalink
Add support for uv's --universal arg (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-thm authored Dec 2, 2024
1 parent 2f9c114 commit 3bcf79b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions uv/pip.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions uv/private/pip.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 3bcf79b

Please sign in to comment.