Skip to content

Commit 32b7228

Browse files
feat(pip): add --pre filter to install_args
1 parent dfef775 commit 32b7228

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
@@ -216,14 +216,24 @@
216216
}
217217

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

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

0 commit comments

Comments
 (0)