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

Remove duplicate arguments in the pip install command #627

Merged
merged 3 commits into from
Dec 10, 2021
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
6 changes: 3 additions & 3 deletions manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
}

$pip_install = "${pip_env} --log ${log}/pip.log install"
$pip_common_args = "${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source}"
$pip_common_args = "${pypi_index} ${proxy_flag} ${install_editable} ${source}"

# Explicit version out of VCS when PIP supported URL is provided
if $source =~ /^'(git\+|hg\+|bzr\+|svn\+)(http|https|ssh|svn|sftp|ftp|lp|git)(:\/\/).+'$/ {
Expand All @@ -195,7 +195,7 @@

'present': {
# Whatever version is available.
$command = "${pip_install} ${pip_common_args}"
$command = "${pip_install} ${install_args} ${pip_common_args}"
$unless_command = "${pip_env} list | grep -i -e '${grep_regex}'"
}

Expand All @@ -214,7 +214,7 @@
$grep_regex_pkgname_with_dashes = "^${pkgname_with_dashes}=="
$installed_version = join( ["${pip_env} freeze --all", " | grep -i -e ${grep_regex_pkgname_with_dashes} | cut -d= -f3", " | tr -d '[:space:]'",])

$command = "${pip_install} --upgrade ${pip_common_args}"
$command = "${pip_install} --upgrade ${install_args} ${pip_common_args}"
$unless_command = "[ \$(${latest_version}) = \$(${installed_version}) ]"
}

Expand Down
12 changes: 10 additions & 2 deletions spec/defines/pip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
context 'adds proxy to install command if proxy set' do
let(:params) { { proxy: 'http://my.proxy:3128' } }

it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip --log /tmp/pip.log install --proxy=http://my.proxy:3128 rpyc') }
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip --log /tmp/pip.log install --proxy=http://my.proxy:3128 rpyc') }
end
end

Expand All @@ -81,7 +81,7 @@
context 'adds index to install command if index set' do
let(:params) { { index: 'http://www.example.com/simple/' } }

it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip --log /tmp/pip.log install --index-url=http://www.example.com/simple/ rpyc') }
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip --log /tmp/pip.log install --index-url=http://www.example.com/simple/ rpyc') }
end
end

Expand All @@ -94,6 +94,14 @@
end
end

describe 'install_args as' do
context 'adds install_args to install command if install_args set' do
let(:params) { { install_args: '--pre' } }

it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip --log /tmp/pip.log install --pre rpyc') }
end
end

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