Skip to content

Commit

Permalink
Merge pull request #627 from zanyou/fix-duplicated-args
Browse files Browse the repository at this point in the history
Remove duplicate arguments in the pip install command
  • Loading branch information
bastelfreak authored Dec 10, 2021
2 parents c5a7944 + fe1c018 commit 0c5e66c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
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

0 comments on commit 0c5e66c

Please sign in to comment.