From 3e4f860429b8a9986ba0489f57f5d9b97dcf0f9c Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Wed, 7 Aug 2024 22:06:05 +0000 Subject: [PATCH] Use tempfile instead of __updated__ Fixes https://github.com/theoremlp/rules_uv/issues/91 --- uv/private/pip_compile_test.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/uv/private/pip_compile_test.sh b/uv/private/pip_compile_test.sh index e63d6ae..13c4c31 100644 --- a/uv/private/pip_compile_test.sh +++ b/uv/private/pip_compile_test.sh @@ -8,17 +8,19 @@ REQUIREMENTS_TXT="{{requirements_txt}}" COMPILE_COMMAND="{{compile_command}}" # make a writable copy of incoming requirements -cp "$REQUIREMENTS_TXT" __updated__ +updated_file=$(mktemp) +trap 'rm -f "$updated_file"' EXIT +cp "$REQUIREMENTS_TXT" "$updated_file" {{uv}} pip compile \ --quiet \ --no-cache \ {{args}} \ - --output-file="__updated__" \ + --output-file="$updated_file" \ "$REQUIREMENTS_IN" # check files match -DIFF="$(diff "$REQUIREMENTS_TXT" "__updated__" || true)" +DIFF="$(diff "$REQUIREMENTS_TXT" "$updated_file" || true)" if [ "$DIFF" != "" ] then echo >&2 "FAIL: $REQUIREMENTS_TXT is out-of-date. Run '$COMPILE_COMMAND' to update."