Skip to content

Commit b7236a8

Browse files
authored
Merge pull request #639 from saz/pip-resolver
use legacy pip resolver for pip versions < 21.1 > 20.2.4
2 parents 380a434 + d305819 commit b7236a8

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

manifests/pip.pp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,18 @@
207207
}
208208

209209
'latest': {
210+
$pip_version = $facts['pip_version']
211+
if $pip_version and versioncmp($pip_version, '21.1') == -1 and versioncmp($pip_version, '20.2.4') == 1 {
212+
$legacy_resolver = '--use-deprecated=legacy-resolver'
213+
} else {
214+
$legacy_resolver = ''
215+
}
216+
210217
# Unfortunately this is the smartest way of getting the latest available package version with pip as of now
211218
# Note: we DO need to repeat ourselves with "from version" in both grep and sed as on some systems pip returns
212219
# more than one line with paretheses.
213220
$latest_version = join( [
214-
"${pip_install} ${pypi_index} ${pypi_extra_index} ${proxy_flag}",
221+
"${pip_install} ${legacy_resolver} ${pypi_index} ${pypi_extra_index} ${proxy_flag}",
215222
" ${install_args} ${install_editable} ${real_pkgname}==notreallyaversion 2>&1",
216223
' | grep -oP "\(from versions: .*\)" | sed -E "s/\(from versions: (.*?, )*(.*)\)/\2/g"',
217224
' | tr -d "[:space:]"',

spec/defines/pip_spec.rb

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
operatingsystem: 'Debian',
2121
operatingsystemrelease: '6',
2222
path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
23-
concat_basedir: '/dne'
23+
concat_basedir: '/dne',
24+
pip_version: '18.1'
2425
}
2526
end
2627

@@ -126,6 +127,12 @@
126127
end
127128

128129
describe 'install latest' do
130+
context 'does not use legacy resolver in unless' do
131+
let(:params) { { ensure: 'latest' } }
132+
133+
it { is_expected.not_to contain_exec('pip_install_rpyc').with_unless(%r{--use-deprecated=legacy-resolver}) }
134+
end
135+
129136
context 'does not use pip search in unless' do
130137
let(:params) { { ensure: 'latest' } }
131138

@@ -158,6 +165,35 @@
158165
end
159166
end
160167
end
168+
169+
context 'on Debian OS with pip_version 20.3.4' do
170+
let :facts do
171+
{
172+
id: 'root',
173+
kernel: 'Linux',
174+
lsbdistcodename: 'buster',
175+
os: {
176+
family: 'Debian',
177+
release: { major: '10' },
178+
},
179+
osfamily: 'Debian',
180+
operatingsystem: 'Debian',
181+
operatingsystemrelease: '10.12',
182+
path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
183+
concat_basedir: '/dne',
184+
pip_version: '20.3.4'
185+
}
186+
end
187+
188+
describe 'install latest' do
189+
context 'with legacy resolver in unless cmd' do
190+
let(:params) { { ensure: 'latest' } }
191+
192+
it { is_expected.to compile.with_all_deps }
193+
it { is_expected.to contain_exec('pip_install_rpyc').with_unless(%r{--use-deprecated=legacy-resolver}) }
194+
end
195+
end
196+
end
161197
end
162198

163199
describe 'python::pip', type: :define do

0 commit comments

Comments
 (0)