Skip to content

Commit 6a42c5c

Browse files
fix(pip): filter with install_args instead of breaking change pre_release
1 parent b726520 commit 6a42c5c

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

manifests/pip.pp

+10-18
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
# @param log_dir Log directory
2121
# @param egg The egg name to use
2222
# @param umask
23-
# @param pre_release if ye allow to install with --pre
2423
#
2524
# @example Install Flask to /var/www/project1 using a proxy
2625
# python::pip { 'flask':
@@ -71,7 +70,6 @@
7170
String[1] $log_dir = '/tmp',
7271
Array[String] $path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'],
7372
String[1] $exec_provider = 'shell',
74-
Boolean $pre_release = false,
7573
) {
7674
$python_provider = getparam(Class['python'], 'provider')
7775
$python_version = getparam(Class['python'], 'version')
@@ -135,11 +133,6 @@
135133
$install_editable = ''
136134
}
137135

138-
$prerelease_flag = $pre_release ? {
139-
false => '',
140-
default => '--pre'
141-
}
142-
143136
# TODO: Do more robust argument checking, but below is a start
144137
if ($ensure == absent) and $install_args {
145138
fail('python::pip cannot provide install_args with ensure => absent')
@@ -186,7 +179,7 @@
186179
default => "'${url}#egg=${egg_name}'",
187180
}
188181

189-
$pip_install = "${pip_env} --log ${log}/pip.log install ${prerelease_flag}"
182+
$pip_install = "${pip_env} --log ${log}/pip.log install"
190183
$pip_common_args = "${pypi_index} ${pypi_extra_index} ${proxy_flag} ${install_editable} ${source}"
191184

192185
# Explicit version out of VCS when PIP supported URL is provided
@@ -222,22 +215,21 @@
222215
}
223216

224217
# Unfortunately this is the smartest way of getting the latest available package version with pip as of now
225-
# Note: we DO need to repeat ourselves with "from version" in both grep and sed as on some systems pip returns
226-
# more than one line with paretheses.
227218
# Public version identifiers: [N!]N(.N)*[{a|b|rc}N][.postN][.devN]
228-
$latest_version = $pre_release ? {
229-
false => join([
230-
"${pip_install} ${legacy_resolver} ${pypi_index} ${pypi_extra_index} ${proxy_flag}",
231-
" ${install_args} ${install_editable} ${real_pkgname}==0.0 2>&1",
232-
" | sed -nE 's/.*\\(from versions: ([^\\)]*)\\)/\\1/p'",
233-
' | awk \'BEGIN {RS=", "} {if ($0 !~ /(a|b|rc|dev)/) {gsub(/\n/,"");stable[arraylen++]=$0}} END {print stable[arraylen-1] }\'',
234-
]),
235-
default => join([
219+
if $install_args and $install_args =~ /--pre/ {
220+
$latest_version = join([
236221
"${pip_install} ${legacy_resolver} ${pypi_index} ${pypi_extra_index} ${proxy_flag}",
237222
" ${install_args} ${install_editable} ${real_pkgname}==0.0 2>&1",
238223
" | sed -nE 's/.*\\(from versions: (.*, )*(.*)\\)/\\2/p'",
239224
' | tr -d "[:space:]"',
240225
])
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}==0.0 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+
])
241233
}
242234

243235
# Packages with underscores in their names are listed with dashes in their place in `pip freeze` output

0 commit comments

Comments
 (0)