|
20 | 20 | # @param log_dir Log directory |
21 | 21 | # @param egg The egg name to use |
22 | 22 | # @param umask |
23 | | -# @param pre_release if ye allow to install with --pre |
24 | 23 | # |
25 | 24 | # @example Install Flask to /var/www/project1 using a proxy |
26 | 25 | # python::pip { 'flask': |
|
71 | 70 | String[1] $log_dir = '/tmp', |
72 | 71 | Array[String] $path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], |
73 | 72 | String[1] $exec_provider = 'shell', |
74 | | - Boolean $pre_release = false, |
75 | 73 | ) { |
76 | 74 | $python_provider = getparam(Class['python'], 'provider') |
77 | 75 | $python_version = getparam(Class['python'], 'version') |
|
135 | 133 | $install_editable = '' |
136 | 134 | } |
137 | 135 |
|
138 | | - $prerelease_flag = $pre_release ? { |
139 | | - false => '', |
140 | | - default => '--pre' |
141 | | - } |
142 | | - |
143 | 136 | # TODO: Do more robust argument checking, but below is a start |
144 | 137 | if ($ensure == absent) and $install_args { |
145 | 138 | fail('python::pip cannot provide install_args with ensure => absent') |
|
222 | 215 | } |
223 | 216 |
|
224 | 217 | # 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. |
227 | 218 | # 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([ |
236 | 221 | "${pip_install} ${legacy_resolver} ${pypi_index} ${pypi_extra_index} ${proxy_flag}", |
237 | 222 | " ${install_args} ${install_editable} ${real_pkgname}==0.0 2>&1", |
238 | 223 | " | sed -nE 's/.*\\(from versions: (.*, )*(.*)\\)/\\2/p'", |
239 | 224 | ' | tr -d "[:space:]"', |
240 | 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}==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 | + ]) |
241 | 233 | } |
242 | 234 |
|
243 | 235 | # Packages with underscores in their names are listed with dashes in their place in `pip freeze` output |
|
0 commit comments