From b61a6d027915c0164608b428effabc8c12a40ba5 Mon Sep 17 00:00:00 2001 From: "Brideau, Patrick" Date: Mon, 17 Jun 2024 09:27:26 -0400 Subject: [PATCH] feat(pip): add --pre filter to install_args --- manifests/pip.pp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index 9d568207..99b05ad7 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -216,15 +216,23 @@ } # 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. + $version_processing_commands = if $install_args and $install_args =~ /--pre/ { + [ + " | sed -nE 's/.*\\(from versions: (.*, )*(.*)\\)/\\2/p'", + ' | tr -d "[:space:]"', + ] + } else { + [ + " | 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] }\'', + ] + } + $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:]"', - ], + ] + $version_processing_commands, ) # Packages with underscores in their names are listed with dashes in their place in `pip freeze` output