Skip to content

Commit 2f4f671

Browse files
author
Thai Pham
committed
More fixes and tests
1 parent 4fbfc0d commit 2f4f671

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

manifests/install.pp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
$python = $python_version ? {
1111
'system' => 'python',
1212
'pypy' => 'pypy',
13-
/\A(python)?([0-9](\.?[0-9])+)/ => "python${1}",
13+
/\A(python)?([0-9](\.?[0-9])+)/ => "python${2}",
1414
default => "python${python::version}",
1515
}
1616

@@ -74,19 +74,29 @@
7474
}
7575
}
7676

77-
# Install pip without pip, see https://pip.pypa.io/en/stable/installing/.
78-
include 'python::pip::bootstrap'
77+
# Respect the $pip_ensure setting
78+
unless $pip_ensure == 'absent' {
79+
# Install pip without pip, see https://pip.pypa.io/en/stable/installing/.
80+
include 'python::pip::bootstrap'
7981

80-
Exec['bootstrap pip'] -> File['pip-python'] -> Package <| provider == pip |>
82+
Exec['bootstrap pip'] -> File['pip-python'] -> Package <| provider == pip |>
8183

82-
Package <| title == 'pip' |> {
83-
name => 'pip',
84-
provider => 'pip',
85-
}
86-
Package <| title == 'virtualenv' |> {
87-
name => 'virtualenv',
88-
provider => 'pip',
89-
require => Package[$pythondev],
84+
Package <| title == 'pip' |> {
85+
name => 'pip',
86+
provider => 'pip',
87+
}
88+
if $pythondev {
89+
Package <| title == 'virtualenv' |> {
90+
name => 'virtualenv',
91+
provider => 'pip',
92+
require => Package['python-dev'],
93+
}
94+
} else {
95+
Package <| title == 'virtualenv' |> {
96+
name => 'virtualenv',
97+
provider => 'pip',
98+
}
99+
}
90100
}
91101
}
92102
'scl': {

manifests/pip.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244
# Unfortunately this is the smartest way of getting the latest available package version with pip as of now
245245
# Note: we DO need to repeat ourselves with "from version" in both grep and sed as on some systems pip returns
246246
# more than one line with paretheses.
247-
$latest_version = join(["${pip_env} install ${proxy_flag} ${pkgname}==notreallyaversion 2>&1",
247+
$latest_version = join(["${pip_install} ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${pkgname}==notreallyaversion 2>&1",
248248
' | grep -oP "\(from versions: .*\)" | sed -E "s/\(from versions: (.*?, )*(.*)\)/\2/g"',
249249
' | tr -d "[:space:]"'])
250250

spec/classes/python_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
describe 'with python::provider' do
6363
context 'pip' do
64-
let(:params) { { provider: 'pip' } }
64+
let(:params) { { pip: 'present', provider: 'pip' } }
6565

6666
it {
6767
is_expected.to contain_package('virtualenv').with(
@@ -384,7 +384,7 @@
384384

385385
describe 'with python::provider' do
386386
context 'pip' do
387-
let(:params) { { provider: 'pip' } }
387+
let(:params) { { pip: 'present', provider: 'pip' } }
388388

389389
it {
390390
is_expected.to contain_package('virtualenv').with(

0 commit comments

Comments
 (0)