Skip to content

Commit b88ea19

Browse files
author
Robert Vincent
committed
Fix version-check.
1 parent 4347e91 commit b88ea19

7 files changed

Lines changed: 37 additions & 29 deletions

File tree

manifests/init.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@
6565
default => '',
6666
}
6767

68-
unless $version =~ Pattern[/\A(python)?[0-9](\.[0-9])+/,
68+
unless $version =~ Pattern[/\A(python)?[0-9](\.?[0-9])+/,
6969
/\Apypy\Z/, /\Asystem\Z/, /\Arh-python[0-9]{2}(?:-python)?\Z/] {
70-
fail("version needs to be pypy, system or a version string like '3.5' or 'python3.5)")
70+
fail("version needs to be pypy, system or a version string like '36', '3.6' or 'python3.6' )")
7171
}
7272

7373
# Module compatibility check

manifests/install.pp

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
#
77
class python::install {
88

9-
$python_version = getparam(Class['python'], 'version')
10-
$python = $python_version ? {
11-
'system' => 'python',
12-
'pypy' => 'pypy',
13-
/\A(python)?([0-9](\.?[0-9])+)/ => "python${2}",
14-
/\Arh-python[0-9]{2}/ => $python_version,
15-
default => "python${python::version}",
9+
$python = $python::version ? {
10+
'system' => 'python',
11+
'pypy' => 'pypy',
12+
/\A(python)?([0-9]+)/ => "python${2}",
13+
/\Arh-python[0-9]{2}/ => $python::version,
14+
default => "python${python::version}",
1615
}
1716

1817
$pythondev = $facts['os']['family'] ? {
@@ -57,6 +56,7 @@
5756

5857
package { 'virtualenv':
5958
ensure => $venv_ensure,
59+
name => "${python}-virtualenv",
6060
require => Package['python'],
6161
}
6262

@@ -144,10 +144,10 @@
144144
}
145145
'rhscl': {
146146
# rhscl is RedHat SCLs from softwarecollections.org
147-
if $::python::rhscl_use_public_repository {
148-
$scl_package = "rhscl-${::python::version}-epel-${::operatingsystemmajrelease}-${::architecture}"
147+
if $python::rhscl_use_public_repository {
148+
$scl_package = "rhscl-${python::version}-epel-${::operatingsystemmajrelease}-${::architecture}"
149149
package { $scl_package:
150-
source => "https://www.softwarecollections.org/en/scls/rhscl/${::python::version}/epel-${::operatingsystemmajrelease}-${::architecture}/download/${scl_package}.noarch.rpm",
150+
source => "https://www.softwarecollections.org/en/scls/rhscl/${python::version}/epel-${::operatingsystemmajrelease}-${::architecture}/download/${scl_package}.noarch.rpm",
151151
provider => 'rpm',
152152
tag => 'python-scl-repo',
153153
}
@@ -171,7 +171,7 @@
171171
tag => 'python-pip-package',
172172
}
173173

174-
if $::python::rhscl_use_public_repository {
174+
if $python::rhscl_use_public_repository {
175175
Package <| tag == 'python-scl-repo' |>
176176
-> Package <| tag == 'python-scl-package' |>
177177
}
@@ -183,24 +183,24 @@
183183
$installer_path = '/var/tmp/anaconda_installer.sh'
184184

185185
file { $installer_path:
186-
source => $::python::anaconda_installer_url,
186+
source => $python::anaconda_installer_url,
187187
mode => '0700',
188188
}
189189
-> exec { 'install_anaconda_python':
190-
command => "${installer_path} -b -p ${::python::anaconda_install_path}",
191-
creates => $::python::anaconda_install_path,
190+
command => "${installer_path} -b -p ${python::anaconda_install_path}",
191+
creates => $python::anaconda_install_path,
192192
logoutput => true,
193193
}
194194
-> exec { 'install_anaconda_virtualenv':
195-
command => "${::python::anaconda_install_path}/bin/pip install virtualenv",
196-
creates => "${::python::anaconda_install_path}/bin/virtualenv",
195+
command => "${python::anaconda_install_path}/bin/pip install virtualenv",
196+
creates => "${python::anaconda_install_path}/bin/virtualenv",
197197
}
198198
}
199199
default: {
200200
case $facts['os']['family'] {
201201
'AIX': {
202-
if "${python_version}" =~ /^python3/ { #lint:ignore:only_variable_string
203-
class { 'python::pip::bootstap':
202+
if String($python::version) =~ /^python3/ {
203+
class { 'python::pip::bootstrap':
204204
version => 'pip3',
205205
}
206206
} else {
@@ -268,25 +268,33 @@
268268
}
269269
}
270270

271-
if "${::python::version}" =~ /^python3/ { #lint:ignore:only_variable_string
271+
if String($python::version) =~ /^python3/ {
272272
$pip_category = undef
273-
$pip_package = 'python3-pip'
273+
$pip_package = "${python}-pip"
274+
$pip_provider = $python.regsubst(/^.*python3\.?/,'pip3.').regsubst(/\.$/,'')
274275
} elsif ($::osfamily == 'RedHat') and (versioncmp($::operatingsystemmajrelease, '7') >= 0) {
275276
$pip_category = undef
276277
$pip_package = 'python2-pip'
278+
$pip_provider = pip2
277279
} elsif $::osfamily == 'Gentoo' {
278280
$pip_category = 'dev-python'
279281
$pip_package = 'pip'
282+
$pip_provider = 'pip'
280283
} else {
281284
$pip_category = undef
282285
$pip_package = 'python-pip'
286+
$pip_provider = 'pip'
283287
}
284288

285289
Package <| title == 'pip' |> {
286290
name => $pip_package,
287291
category => $pip_category,
288292
}
289293

294+
Python::Pip <| |> {
295+
pip_provider => $pip_provider,
296+
}
297+
290298
Package <| title == 'virtualenv' |> {
291299
name => $virtualenv_package,
292300
}

manifests/pip.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
}
8686

8787
$_path = $python_provider ? {
88-
'anaconda' => concat(["${::python::anaconda_install_path}/bin"], $path),
88+
'anaconda' => concat(["${python::anaconda_install_path}/bin"], $path),
8989
default => $path,
9090
}
9191

manifests/pip/bootstrap.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
Enum['pip', 'pip3'] $version = 'pip',
1414
Variant[Boolean, String] $manage_python = false,
1515
Optional[Stdlib::HTTPUrl] $http_proxy = undef,
16-
) inherits ::python::params {
16+
) inherits python::params {
1717
if $manage_python {
1818
include python
1919
} else {

manifests/pyvenv.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
$virtualenv_cmd = "${python::exec_prefix}pyvenv-${normalized_python_version}"
6666
}
6767

68-
$_path = $::python::provider ? {
69-
'anaconda' => concat(["${::python::anaconda_install_path}/bin"], $path),
68+
$_path = $python::provider ? {
69+
'anaconda' => concat(["${python::anaconda_install_path}/bin"], $path),
7070
default => $path,
7171
}
7272

manifests/requirements.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
}
6464

6565
$pip_env = $virtualenv ? {
66-
'system' => "${::python::exec_prefix} ${pip_provider}",
67-
default => "${::python::exec_prefix} ${virtualenv}/bin/${pip_provider}",
66+
'system' => "${python::exec_prefix} ${pip_provider}",
67+
default => "${python::exec_prefix} ${virtualenv}/bin/${pip_provider}",
6868
}
6969

7070
$proxy_flag = $proxy ? {

spec/defines/pip_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
describe 'path as' do
8888
context 'adds anaconda path to pip invocation if provider is anaconda' do
8989
let(:params) { {} }
90-
let(:pre_condition) { 'class {"::python": provider => "anaconda", anaconda_install_path => "/opt/python3"}' }
90+
let(:pre_condition) { 'class {"python": provider => "anaconda", anaconda_install_path => "/opt/python3"}' }
9191

9292
it { is_expected.to contain_exec('pip_install_rpyc').with_path(['/opt/python3/bin', '/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin']) }
9393
end

0 commit comments

Comments
 (0)