diff --git a/manifests/pip.pp b/manifests/pip.pp index bfc269a7..86c28d4c 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -162,21 +162,6 @@ default => "${url}#egg=${egg_name}", } - # We need to jump through hoops to make sure we issue the correct pip command - # depending on wheel support and versions. - # - # Pip does not support wheels prior to version 1.4.0 - # Pip wheels require setuptools/distribute > 0.8 - # Python 2.6 and older does not support setuptools/distribute > 0.8 - # Pip >= 1.5 tries to use wheels by default, even if wheel package is not - # installed, in this case the --no-use-wheel flag needs to be passed - # Versions prior to 1.5 don't support the --no-use-wheel flag - # - # To check for this we test for wheel parameter using help and then using - # show, this makes sure we only use wheels if they are supported and - # installed - $wheel_check = "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} show wheel > /dev/null 2>&1 || wheel_support_flag='--no-binary :all:'; }" - $pip_install = "${pip_env} --log ${log}/pip.log install" $pip_common_args = "${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source}" @@ -184,7 +169,7 @@ if $source =~ /^(git\+|hg\+|bzr\+|svn\+)(http|https|ssh|svn|sftp|ftp|lp)(:\/\/).+$/ { if $ensure != present and $ensure != latest { exec { "pip_install_${name}": - command => "${wheel_check} ; { ${pip_install} ${install_args} \$wheel_support_flag ${pip_common_args}@${ensure}#egg=${egg_name} || ${pip_install} ${install_args} ${pip_common_args}@${ensure}#egg=${egg_name} ;}", + command => "${pip_install} ${install_args} ${pip_common_args}@${ensure}#egg=${egg_name}", unless => "${pip_env} freeze --all | grep -i -e ${grep_regex}", user => $owner, group => $group, @@ -196,7 +181,7 @@ } } else { exec { "pip_install_${name}": - command => "${wheel_check} ; { ${pip_install} ${install_args} \$wheel_support_flag ${pip_common_args} || ${pip_install} ${install_args} ${pip_common_args} ;}", + command => "${pip_install} ${install_args} ${pip_common_args}", unless => "${pip_env} freeze --all | grep -i -e ${grep_regex}", user => $owner, group => $group, @@ -213,7 +198,7 @@ # Version formats as per http://guide.python-distribute.org/specification.html#standard-versioning-schemes # Explicit version. exec { "pip_install_${name}": - command => "${wheel_check} ; { ${pip_install} ${install_args} \$wheel_support_flag ${pip_common_args}==${ensure} || ${pip_install} ${install_args} ${pip_common_args}==${ensure} ;}", + command => "${pip_install} ${install_args} ${pip_common_args}==${ensure}", unless => "${pip_env} freeze --all | grep -i -e ${grep_regex} || ${pip_env} list | sed -e 's/[ ]\\+/==/' -e 's/[()]//g' | grep -i -e ${grep_regex}", user => $owner, group => $group, @@ -228,7 +213,7 @@ 'present': { # Whatever version is available. exec { "pip_install_${name}": - command => "${wheel_check} ; { ${pip_install} \$wheel_support_flag ${pip_common_args} || ${pip_install} ${pip_common_args} ;}", + command => "${pip_install} ${pip_common_args}", unless => "${pip_env} freeze --all | grep -i -e ${grep_regex} || ${pip_env} list | sed -e 's/[ ]\\+/==/' -e 's/[()]//g' | grep -i -e ${grep_regex}", user => $owner, group => $group, @@ -259,7 +244,7 @@ # Latest version. exec { "pip_install_${name}": - command => "${wheel_check} ; { ${pip_install} --upgrade \$wheel_support_flag ${pip_common_args} || ${pip_install} --upgrade ${pip_common_args} ;}", + command => "${pip_install} --upgrade ${pip_common_args}", unless => $unless_command, user => $owner, group => $group, diff --git a/spec/defines/pip_spec.rb b/spec/defines/pip_spec.rb index 1548b7b6..345de99b 100644 --- a/spec/defines/pip_spec.rb +++ b/spec/defines/pip_spec.rb @@ -67,7 +67,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 wheel --help > /dev/null 2>&1 && { pip show wheel > /dev/null 2>&1 || wheel_support_flag='--no-binary :all:'; } ; { pip --log /tmp/pip.log install $wheel_support_flag --proxy=http://my.proxy:3128 rpyc || 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 @@ -80,7 +80,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 wheel --help > /dev/null 2>&1 && { pip show wheel > /dev/null 2>&1 || wheel_support_flag='--no-binary :all:'; } ; { pip --log /tmp/pip.log install $wheel_support_flag --index-url=http://www.example.com/simple/ rpyc || 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 @@ -133,12 +133,12 @@ context 'suceeds with no extras' do let(:params) { {} } - it { is_expected.to contain_exec('pip_install_requests').with_command("pip wheel --help > /dev/null 2>&1 && { pip show wheel > /dev/null 2>&1 || wheel_support_flag='--no-binary :all:'; } ; { pip --log /tmp/pip.log install $wheel_support_flag requests || pip --log /tmp/pip.log install requests ;}") } + it { is_expected.to contain_exec('pip_install_requests').with_command('pip --log /tmp/pip.log install requests') } end context 'succeeds with extras' do let(:params) { { extras: ['security'] } } - it { is_expected.to contain_exec('pip_install_requests').with_command("pip wheel --help > /dev/null 2>&1 && { pip show wheel > /dev/null 2>&1 || wheel_support_flag='--no-binary :all:'; } ; { pip --log /tmp/pip.log install $wheel_support_flag requests[security] || pip --log /tmp/pip.log install requests[security] ;}") } + it { is_expected.to contain_exec('pip_install_requests').with_command('pip --log /tmp/pip.log install requests[security]') } end end end