Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9a57ccd

Browse files
committedAug 21, 2024·
feat(pip): add --pre filter to install_args
1 parent 04e4d4c commit 9a57ccd

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed
 

‎manifests/pip.pp

+16-8
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,22 @@
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",
223-
" | sed -nE 's/.*\\(from versions: (.*, )*(.*)\\)/\\2/p'",
224-
' | tr -d "[:space:]"',
225-
])
218+
# Public version identifiers: [N!]N(.N)*[{a|b|rc}N][.postN][.devN]
219+
if $install_args and $install_args =~ /--pre/ {
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",
223+
" | sed -nE 's/.*\\(from versions: (.*, )*(.*)\\)/\\2/p'",
224+
' | tr -d "[:space:]"',
225+
])
226+
} else {
227+
$latest_version = join([
228+
"${pip_install} ${legacy_resolver} ${pypi_index} ${pypi_extra_index} ${proxy_flag}",
229+
" ${install_args} ${install_editable} ${real_pkgname}==9!0dev0+x 2>&1",
230+
" | sed -nE 's/.*\\(from versions: ([^\\)]*)\\)/\\1/p'",
231+
' | awk \'BEGIN {RS=", "} {if ($0 !~ /(a|b|rc|dev)/) {gsub(/\n/,"");stable[arraylen++]=$0}} END {print stable[arraylen-1] }\'',
232+
])
233+
}
226234

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

0 commit comments

Comments
 (0)
Please sign in to comment.