Skip to content

Add constraints_txt argument.#308

Open
ryanli wants to merge 1 commit intobazel-contrib:mainfrom
ryanli:main
Open

Add constraints_txt argument.#308
ryanli wants to merge 1 commit intobazel-contrib:mainfrom
ryanli:main

Conversation

@ryanli
Copy link
Copy Markdown

@ryanli ryanli commented Feb 6, 2026

This fixes #281.

@thirtyseven
Copy link
Copy Markdown

thirtyseven commented Mar 26, 2026

Thanks for this PR! We've been testing this patch in our repo and noticed a bash 3.x compatibility issue with the array expansion approach.

macOS ships with bash 3.2, and with set -u, "${empty_array[@]}" triggers an "unbound variable" error on empty arrays. A fix is to replace the array with ${CONSTRAINTS_TXT:+--constraint="$CONSTRAINTS_TXT"} directly, which avoids the array entirely and works on bash 3.x:

CONSTRAINTS_TXT="{{constraints_txt}}"

{{uv}} pip compile \
    {{args}} \
    ${CONSTRAINTS_TXT:+--constraint="$CONSTRAINTS_TXT"} \
    --output-file="$REQUIREMENTS_TXT" \
    "$REQUIREMENTS_IN" \
    "$@"

This applies to both pip_compile.sh and pip_compile_test.sh.

@ryanli
Copy link
Copy Markdown
Author

ryanli commented Mar 26, 2026

Ah bash 3.2 ;-)

I've updated the commit, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for constraints.txt files

2 participants