From 7d7e95a2dfcc8ec01e8b3169b67fbe51c8a8cd34 Mon Sep 17 00:00:00 2001 From: Hongxin Liang Date: Tue, 21 May 2024 20:46:30 +0200 Subject: [PATCH] feat: Enable header generation --- examples/typical/requirements.txt | 2 ++ examples/typical/requirements_linux.txt | 2 ++ uv/private/pip.bzl | 1 + uv/private/pip_compile.sh | 5 +++-- uv/private/pip_compile_test.sh | 3 ++- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/typical/requirements.txt b/examples/typical/requirements.txt index 55eed4b..73497ce 100644 --- a/examples/typical/requirements.txt +++ b/examples/typical/requirements.txt @@ -1,3 +1,5 @@ +# This file was autogenerated by uv via the following command: +# bazel run @@//:generate_requirements_txt --index-url https://pypi.org/simple click==8.1.7 \ diff --git a/examples/typical/requirements_linux.txt b/examples/typical/requirements_linux.txt index 55eed4b..3c95dea 100644 --- a/examples/typical/requirements_linux.txt +++ b/examples/typical/requirements_linux.txt @@ -1,3 +1,5 @@ +# This file was autogenerated by uv via the following command: +# bazel run @@//:generate_requirements_linux_txt --index-url https://pypi.org/simple click==8.1.7 \ diff --git a/uv/private/pip.bzl b/uv/private/pip.bzl index ef2f3af..9699fd7 100644 --- a/uv/private/pip.bzl +++ b/uv/private/pip.bzl @@ -25,6 +25,7 @@ def _uv_pip_compile(ctx, template, executable): "{{requirements_txt}}": ctx.file.requirements_txt.short_path, "{{resolved_python}}": py_toolchain.py3_runtime.interpreter.short_path, "{{python_platform}}": _python_platform(ctx.attr.python_platform), + "{{label}}": str(ctx.label), }, ) diff --git a/uv/private/pip_compile.sh b/uv/private/pip_compile.sh index 48c3d85..d394e1d 100644 --- a/uv/private/pip_compile.sh +++ b/uv/private/pip_compile.sh @@ -7,6 +7,7 @@ PYTHON_PLATFORM="{{python_platform}}" RESOLVED_PYTHON="{{resolved_python}}" REQUIREMENTS_IN="{{requirements_in}}" REQUIREMENTS_TXT="{{requirements_txt}}" +LABEL="{{label}}" RESOLVED_PYTHON_BIN="$(dirname "$RESOLVED_PYTHON")" @@ -19,10 +20,10 @@ PYTHON_VERSION="$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys. $UV pip compile \ --generate-hashes \ --emit-index-url \ - --no-header \ --no-strip-extras \ + --custom-compile-command "bazel run $LABEL" \ --python-version=$PYTHON_VERSION \ $(echo $PYTHON_PLATFORM) \ -o $REQUIREMENTS_TXT \ $REQUIREMENTS_IN \ - $@ + "$@" diff --git a/uv/private/pip_compile_test.sh b/uv/private/pip_compile_test.sh index 2808830..7f872fc 100644 --- a/uv/private/pip_compile_test.sh +++ b/uv/private/pip_compile_test.sh @@ -7,6 +7,7 @@ PYTHON_PLATFORM="{{python_platform}}" RESOLVED_PYTHON="{{resolved_python}}" REQUIREMENTS_IN="{{requirements_in}}" REQUIREMENTS_TXT="{{requirements_txt}}" +LABEL="{{label}}" RESOLVED_PYTHON_BIN="$(dirname "$RESOLVED_PYTHON")" @@ -24,8 +25,8 @@ $UV pip compile \ --no-cache \ --generate-hashes \ --emit-index-url \ - --no-header \ --no-strip-extras \ + --custom-compile-command "bazel run $LABEL" \ --python-version=$PYTHON_VERSION \ $(echo $PYTHON_PLATFORM) \ -o __updated__ \