|
70 | 70 | String[1] $log_dir = '/tmp',
|
71 | 71 | Array[String] $path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'],
|
72 | 72 | String[1] $exec_provider = 'shell',
|
| 73 | + Boolean $pre_release = false, |
73 | 74 | ) {
|
74 | 75 | $python_provider = getparam(Class['python'], 'provider')
|
75 | 76 | $python_version = getparam(Class['python'], 'version')
|
|
133 | 134 | $install_editable = ''
|
134 | 135 | }
|
135 | 136 |
|
| 137 | + $prerelease_flag = $pre_release ? { |
| 138 | + false => '', |
| 139 | + default => '--pre' |
| 140 | + } |
| 141 | + |
136 | 142 | # TODO: Do more robust argument checking, but below is a start
|
137 | 143 | if ($ensure == absent) and $install_args {
|
138 | 144 | fail('python::pip cannot provide install_args with ensure => absent')
|
|
179 | 185 | default => "'${url}#egg=${egg_name}'",
|
180 | 186 | }
|
181 | 187 |
|
182 |
| - $pip_install = "${pip_env} --log ${log}/pip.log install" |
| 188 | + $pip_install = "${pip_env} --log ${log}/pip.log install ${prerelease_flag}" |
183 | 189 | $pip_common_args = "${pypi_index} ${pypi_extra_index} ${proxy_flag} ${install_editable} ${source}"
|
184 | 190 |
|
185 | 191 | # Explicit version out of VCS when PIP supported URL is provided
|
|
217 | 223 | # Unfortunately this is the smartest way of getting the latest available package version with pip as of now
|
218 | 224 | # Note: we DO need to repeat ourselves with "from version" in both grep and sed as on some systems pip returns
|
219 | 225 | # 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}==notreallyaversion 2>&1", |
223 |
| - " | sed -nE 's/.*\\(from versions: (.*, )*(.*)\\)/\\2/p'", |
224 |
| - ' | tr -d "[:space:]"', |
225 |
| - ]) |
| 226 | + # Public version identifiers: [N!]N(.N)*[{a|b|rc}N][.postN][.devN] |
| 227 | + $latest_version = $pre_release ? { |
| 228 | + false => join([ |
| 229 | + "${pip_install} ${legacy_resolver} ${pypi_index} ${pypi_extra_index} ${proxy_flag}", |
| 230 | + " ${install_args} ${install_editable} ${real_pkgname}==notreallyaversion 2>&1", |
| 231 | + " | sed -nE 's/.*\\(from versions: ([^\\)]*)\\)/\\1/p'", |
| 232 | + ' | awk \'BEGIN {RS=", "} {if ($0 !~ /(a|b|rc|dev)/) {gsub(/\n/,"");stable[arraylen++]=$0}} END {print stable[arraylen-1] }\'', |
| 233 | + ]), |
| 234 | + default => join([ |
| 235 | + "${pip_install} ${legacy_resolver} ${pypi_index} ${pypi_extra_index} ${proxy_flag}", |
| 236 | + " ${install_args} ${install_editable} ${real_pkgname}==notreallyaversion 2>&1", |
| 237 | + " | sed -nE 's/.*\\(from versions: (.*, )*(.*)\\)/\\2/p'", |
| 238 | + ' | tr -d "[:space:]"', |
| 239 | + ]) |
| 240 | + } |
226 | 241 |
|
227 | 242 | # Packages with underscores in their names are listed with dashes in their place in `pip freeze` output
|
228 | 243 | $pkgname_with_dashes = regsubst($real_pkgname, '_', '-', 'G')
|
|
0 commit comments