Skip to content

Commit

Permalink
use legacy pip resolver for pip versions < 21.1 > 20.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
saz committed Jul 23, 2022
1 parent ef2df5b commit 41422f0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,18 @@
}

'latest': {
$pip_version = $facts['pip_version']
if versioncmp($pip_version, '21.1') == -1 and versioncmp($pip_version, '20.2.4') == 1 {
$legacy_resolver = '--use-deprecated=legacy-resolver'
} else {
$legacy_resolver = ''
}

# Unfortunately this is the smartest way of getting the latest available package version with pip as of now
# Note: we DO need to repeat ourselves with "from version" in both grep and sed as on some systems pip returns
# more than one line with paretheses.
$latest_version = join( [
"${pip_install} ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${real_pkgname}==notreallyaversion 2>&1",
"${pip_install} ${legacy_resolver} ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${real_pkgname}==notreallyaversion 2>&1",
' | grep -oP "\(from versions: .*\)" | sed -E "s/\(from versions: (.*?, )*(.*)\)/\2/g"',
' | tr -d "[:space:]"',
])
Expand Down

0 comments on commit 41422f0

Please sign in to comment.