From b3080953dcfc7931e1bd0a3e70a1e1a15c0f0272 2024-02-10 11:09:54 From: Branko Majic Date: 2024-02-10 11:09:54 Subject: [PATCH] MAR-193: Fix deprecation warnings coming from newer versions of pip-tools: - In more recent versions of pip-tools, a new option has been added (--strip-extras) that will become a new default in next major release. Not using this option causes some warnings on Debian 11 Bullseye when pip-tools is brought up to date. - Refactor the invocation of pip-compile to make it more modular. - No test expansion for this since it would make it a bit harder to target both Debian 10 Buster and Debian 11 Bullseye. --- diff --git a/docs/releasenotes.rst b/docs/releasenotes.rst index 8b8f19d816030b20e95045cefd5762d14191931c..a89cb0483a48e910d9b9df3612a0413cef0703ee 100644 --- a/docs/releasenotes.rst +++ b/docs/releasenotes.rst @@ -2,6 +2,18 @@ Release notes ============= +x.y.z +----- + +**Bug fixes:** + +* ``common`` role + + * Fix deprecation warnings for Python requirements upgrade checks + when using pip-tools 7.3.0. This would result in unnecessary + notifications being sent out to server administrator. + + 7.1.0 ----- diff --git a/roles/common/files/pip_check_requirements_upgrades.sh b/roles/common/files/pip_check_requirements_upgrades.sh index 7a6f321b980d8f6348135a81428eea0ec9ba0b8b..0ed3d5030ce8e4fb97a0e6d8d1b692c16e3f8cce 100755 --- a/roles/common/files/pip_check_requirements_upgrades.sh +++ b/roles/common/files/pip_check_requirements_upgrades.sh @@ -237,17 +237,33 @@ for environment in "$config_dir"/*; do # package versioning information. current=$(sed -e 's/[[:blank:]]*#.*//' "$req_txt" | grep -v "^$" | sort -u) - # Calculate up-to-date requirements. Use backtracking resolver if available. + # Set-up pip-compile invocation based on available options, + # partially in order to get rid of the warnings. + pip_compile_invocation=( + "pip-compile" + "--quiet" + "--allow-unsafe" + "--no-header" + "--no-annotate" + "--no-emit-index-url" + ) + if pip-compile --help | grep -q -- --resolver; then - new=$(pip-compile --quiet --resolver backtracking --allow-unsafe --no-header --no-annotate --no-emit-index-url --output-file - --upgrade "$req_in") - result="$?" - else - new=$(pip-compile --quiet --allow-unsafe --no-header --no-annotate --no-emit-index-url --output-file - --upgrade "$req_in") - result="$?" + pip_compile_invocation+=("--resolver=backtracking") fi - if [[ $result != 0 ]]; then - error "Failed while running pip-compile command against (see error stack trace above): $req_in" + if pip-compile --help | grep -q -- --strip-extras; then + pip_compile_invocation+=("--strip-extras") + fi + + pip_compile_invocation+=( + "--output-file" "-" + "--upgrade" "$req_in" + ) + + # Calculate up-to-date requirements. + if ! new=$("${pip_compile_invocation[@]}"); then + error "Failed while running pip-compile command against (see error stack trace above): $req_in" continue fi