Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use legacy pip resolver for pip versions < 21.1 > 20.2.4 #639

Merged
merged 1 commit into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,18 @@
}

'latest': {
$pip_version = $facts['pip_version']
if $pip_version and versioncmp($pip_version, '21.1') == -1 and versioncmp($pip_version, '20.2.4') == 1 {
$legacy_resolver = '--use-deprecated=legacy-resolver'
} else {
$legacy_resolver = ''
}

# Unfortunately this is the smartest way of getting the latest available package version with pip as of now
# Note: we DO need to repeat ourselves with "from version" in both grep and sed as on some systems pip returns
# more than one line with paretheses.
$latest_version = join( [
"${pip_install} ${pypi_index} ${pypi_extra_index} ${proxy_flag}",
"${pip_install} ${legacy_resolver} ${pypi_index} ${pypi_extra_index} ${proxy_flag}",
" ${install_args} ${install_editable} ${real_pkgname}==notreallyaversion 2>&1",
' | grep -oP "\(from versions: .*\)" | sed -E "s/\(from versions: (.*?, )*(.*)\)/\2/g"',
' | tr -d "[:space:]"',
Expand Down
38 changes: 37 additions & 1 deletion spec/defines/pip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
operatingsystem: 'Debian',
operatingsystemrelease: '6',
path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
concat_basedir: '/dne'
concat_basedir: '/dne',
pip_version: '18.1'
}
end

Expand Down Expand Up @@ -126,6 +127,12 @@
end

describe 'install latest' do
context 'does not use legacy resolver in unless' do
let(:params) { { ensure: 'latest' } }

it { is_expected.not_to contain_exec('pip_install_rpyc').with_unless(%r{--use-deprecated=legacy-resolver}) }
end

context 'does not use pip search in unless' do
let(:params) { { ensure: 'latest' } }

Expand Down Expand Up @@ -158,6 +165,35 @@
end
end
end

context 'on Debian OS with pip_version 20.3.4' do
let :facts do
{
id: 'root',
kernel: 'Linux',
lsbdistcodename: 'buster',
os: {
saz marked this conversation as resolved.
Show resolved Hide resolved
family: 'Debian',
release: { major: '10' },
},
osfamily: 'Debian',
operatingsystem: 'Debian',
operatingsystemrelease: '10.12',
path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
concat_basedir: '/dne',
pip_version: '20.3.4'
}
end

describe 'install latest' do
context 'with legacy resolver in unless cmd' do
let(:params) { { ensure: 'latest' } }

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_exec('pip_install_rpyc').with_unless(%r{--use-deprecated=legacy-resolver}) }
saz marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
end

describe 'python::pip', type: :define do
Expand Down