|
25 | 25 | # [*group*] |
26 | 26 | # The group of the virtualenv being manipulated. Default: root |
27 | 27 | # |
| 28 | +# [*index*] |
| 29 | +# Base URL of Python package index. Default: none (http://pypi.python.org/simple/) |
| 30 | +# |
28 | 31 | # [*proxy*] |
29 | 32 | # Proxy server to use for outbound connections. Default: none |
30 | 33 | # |
|
53 | 56 | # python::pip { 'flask': |
54 | 57 | # virtualenv => '/var/www/project1', |
55 | 58 | # proxy => 'http://proxy.domain.com:3128', |
| 59 | +# index => 'http://www.example.com/simple/', |
56 | 60 | # } |
57 | 61 | # |
58 | 62 | # === Authors |
|
67 | 71 | $url = false, |
68 | 72 | $owner = 'root', |
69 | 73 | $group = 'root', |
| 74 | + $index = false, |
70 | 75 | $proxy = false, |
71 | 76 | $egg = false, |
72 | 77 | $editable = false, |
|
103 | 108 | default => "${virtualenv}/bin/pip", |
104 | 109 | } |
105 | 110 |
|
| 111 | + $pypi_index = $index ? { |
| 112 | + false => '', |
| 113 | + default => "--index-url=${index}", |
| 114 | + } |
| 115 | + |
106 | 116 | $proxy_flag = $proxy ? { |
107 | 117 | false => '', |
108 | 118 | default => "--proxy=${proxy}", |
|
162 | 172 |
|
163 | 173 | # Explicit version out of VCS when PIP supported URL is provided |
164 | 174 | if $source =~ /^(git\+|hg\+|bzr\+|svn\+)(http|https|ssh|svn|sftp|ftp|lp)(:\/\/).+$/ { |
165 | | - if $ensure != present and $ensure != latest { |
166 | | - exec { "pip_install_${name}": |
167 | | - command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install ${install_args} \$wheel_support_flag ${proxy_flag} ${install_args} ${install_editable} ${source}@${ensure}#egg=${egg_name} || ${pip_env} --log ${log}/pip.log install ${install_args} ${proxy_flag} ${install_args} ${install_editable} ${source}@${ensure}#egg=${egg_name} ;}", |
168 | | - unless => "${pip_env} freeze | grep -i -e ${grep_regex}", |
169 | | - user => $owner, |
170 | | - group => $group, |
171 | | - cwd => $cwd, |
172 | | - environment => $environment, |
173 | | - path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], |
174 | | - timeout => $timeout, |
175 | | - } |
176 | | - } |
177 | | - else { |
178 | | - exec { "pip_install_${name}": |
179 | | - command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install ${install_args} \$wheel_support_flag ${proxy_flag} ${install_args} ${install_editable} ${source} || ${pip_env} --log ${log}/pip.log install ${install_args} ${proxy_flag} ${install_args} ${install_editable} ${source} ;}", |
180 | | - unless => "${pip_env} freeze | grep -i -e ${grep_regex}", |
181 | | - user => $owner, |
182 | | - group => $group, |
183 | | - cwd => $cwd, |
184 | | - environment => $environment, |
185 | | - path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], |
186 | | - timeout => $timeout, |
187 | | - } |
| 175 | + if $ensure != present and $ensure != latest { |
| 176 | + exec { "pip_install_${name}": |
| 177 | + command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install ${install_args} \$wheel_support_flag ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source}@${ensure}#egg=${egg_name} || ${pip_env} --log ${log}/pip.log install ${install_args} ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source}@${ensure}#egg=${egg_name} ;}", |
| 178 | + unless => "${pip_env} freeze | grep -i -e ${grep_regex}", |
| 179 | + user => $owner, |
| 180 | + group => $group, |
| 181 | + cwd => $cwd, |
| 182 | + environment => $environment, |
| 183 | + path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], |
| 184 | + timeout => $timeout, |
| 185 | + } |
| 186 | + } else { |
| 187 | + exec { "pip_install_${name}": |
| 188 | + command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install ${install_args} \$wheel_support_flag ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source} || ${pip_env} --log ${log}/pip.log install ${install_args} ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source} ;}", |
| 189 | + unless => "${pip_env} freeze | grep -i -e ${grep_regex}", |
| 190 | + user => $owner, |
| 191 | + group => $group, |
| 192 | + cwd => $cwd, |
| 193 | + environment => $environment, |
| 194 | + path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], |
| 195 | + timeout => $timeout, |
| 196 | + } |
188 | 197 | } |
189 | | - } |
190 | | - else { |
| 198 | + } else { |
191 | 199 | case $ensure { |
192 | 200 | /^((19|20)[0-9][0-9]-(0[1-9]|1[1-2])-([0-2][1-9]|3[0-1])|[0-9]+\.[0-9]+(\.[0-9]+)?)$/: { |
193 | 201 | # Version formats as per http://guide.python-distribute.org/specification.html#standard-versioning-schemes |
194 | 202 | # Explicit version. |
195 | 203 | exec { "pip_install_${name}": |
196 | | - command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install ${install_args} \$wheel_support_flag ${proxy_flag} ${install_args} ${install_editable} ${source}==${ensure} || ${pip_env} --log ${log}/pip.log install ${install_args} ${proxy_flag} ${install_args} ${install_editable} ${source}==${ensure} ;}", |
| 204 | + command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install ${install_args} \$wheel_support_flag ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source}==${ensure} || ${pip_env} --log ${log}/pip.log install ${install_args} ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source}==${ensure} ;}", |
197 | 205 | unless => "${pip_env} freeze | grep -i -e ${grep_regex}", |
198 | 206 | user => $owner, |
199 | 207 | group => $group, |
|
207 | 215 | present: { |
208 | 216 | # Whatever version is available. |
209 | 217 | exec { "pip_install_${name}": |
210 | | - command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install \$wheel_support_flag ${proxy_flag} ${install_args} ${install_editable} ${source} || ${pip_env} --log ${log}/pip.log install ${proxy_flag} ${install_args} ${install_editable} ${source} ;}", |
| 218 | + command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install \$wheel_support_flag ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source} || ${pip_env} --log ${log}/pip.log install ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source} ;}", |
211 | 219 | unless => "${pip_env} freeze | grep -i -e ${grep_regex}", |
212 | 220 | user => $owner, |
213 | 221 | group => $group, |
|
221 | 229 | latest: { |
222 | 230 | # Latest version. |
223 | 231 | exec { "pip_install_${name}": |
224 | | - command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${install_args} ${install_editable} ${source} || ${pip_env} --log ${log}/pip.log install --upgrade ${proxy_flag} ${install_args} ${install_editable} ${source} ;}", |
| 232 | + command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install --upgrade \$wheel_support_flag ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source} || ${pip_env} --log ${log}/pip.log install --upgrade ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source} ;}", |
225 | 233 | unless => "${pip_env} search ${proxy_flag} ${source} | grep -i INSTALLED | grep -i latest", |
226 | 234 | user => $owner, |
227 | 235 | group => $group, |
|
0 commit comments