Skip to content

Commit

Permalink
feat(pip): add --pre filter to install_args
Browse files Browse the repository at this point in the history
  • Loading branch information
teluq-pbrideau committed Aug 21, 2024
1 parent 04e4d4c commit 9a57ccd
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,22 @@
}

# 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} ${legacy_resolver} ${pypi_index} ${pypi_extra_index} ${proxy_flag}",
" ${install_args} ${install_editable} '${real_pkgname}==9!0dev0+x' 2>&1",
" | sed -nE 's/.*\\(from versions: (.*, )*(.*)\\)/\\2/p'",
' | tr -d "[:space:]"',
])
# Public version identifiers: [N!]N(.N)*[{a|b|rc}N][.postN][.devN]
if $install_args and $install_args =~ /--pre/ {
$latest_version = join([
"${pip_install} ${legacy_resolver} ${pypi_index} ${pypi_extra_index} ${proxy_flag}",
" ${install_args} ${install_editable} ${real_pkgname}==9!0dev0+x 2>&1",
" | sed -nE 's/.*\\(from versions: (.*, )*(.*)\\)/\\2/p'",
' | tr -d "[:space:]"',
])
} else {
$latest_version = join([
"${pip_install} ${legacy_resolver} ${pypi_index} ${pypi_extra_index} ${proxy_flag}",
" ${install_args} ${install_editable} ${real_pkgname}==9!0dev0+x 2>&1",
" | sed -nE 's/.*\\(from versions: ([^\\)]*)\\)/\\1/p'",
' | awk \'BEGIN {RS=", "} {if ($0 !~ /(a|b|rc|dev)/) {gsub(/\n/,"");stable[arraylen++]=$0}} END {print stable[arraylen-1] }\'',
])
}

# Packages with underscores in their names are listed with dashes in their place in `pip freeze` output
$pkgname_with_dashes = regsubst($real_pkgname, '_', '-', 'G')
Expand Down

0 comments on commit 9a57ccd

Please sign in to comment.