Changeset - b3080953dcfc
[Not reviewed]
0 2 0
Branko Majic (branko) - 8 months ago 2024-02-10 11:09:54
branko@majic.rs
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.
2 files changed with 36 insertions and 8 deletions:
0 comments (0 inline, 0 general)
docs/releasenotes.rst
Show inline comments
 
@@ -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
 
-----
 

	
roles/common/files/pip_check_requirements_upgrades.sh
Show inline comments
 
@@ -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
 

	
0 comments (0 inline, 0 general)