Skip to content

Commit e85eae5

Browse files
feat(pip): add --pre filter to install_args
1 parent 04e4d4c commit e85eae5

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

manifests/pip.pp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,24 @@
215215
}
216216

217217
# Unfortunately this is the smartest way of getting the latest available package version with pip as of now
218-
# Note: we DO need to repeat ourselves with "from version" in both grep and sed as on some systems pip returns
219-
# more than one line with paretheses.
220-
$latest_version = join([
221-
"${pip_install} ${legacy_resolver} ${pypi_index} ${pypi_extra_index} ${proxy_flag}",
222-
" ${install_args} ${install_editable} '${real_pkgname}==9!0dev0+x' 2>&1",
218+
$version_processing_commands = if $install_args and $install_args =~ /--pre/ {
219+
[
223220
" | sed -nE 's/.*\\(from versions: (.*, )*(.*)\\)/\\2/p'",
224221
' | tr -d "[:space:]"',
225-
])
222+
]
223+
} else {
224+
[
225+
" | sed -nE 's/.*\\(from versions: ([^\\)]*)\\)/\\1/p'",
226+
' | awk \'BEGIN {RS=", "} {if ($0 !~ /(a|b|rc|dev)/) {gsub(/\n/,"");stable[arraylen++]=$0}} END {print stable[arraylen-1] }\'',
227+
]
228+
}
229+
230+
$latest_version = join(
231+
[
232+
"${pip_install} ${legacy_resolver} ${pypi_index} ${pypi_extra_index} ${proxy_flag}",
233+
" ${install_args} ${install_editable} '${real_pkgname}==9!0dev0+x' 2>&1",
234+
] + $version_processing_commands,
235+
)
226236

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

0 commit comments

Comments
 (0)