Skip to content

Commit e9dbed0

Browse files
authored
Merge pull request voxpupuli#483 from asottile/pip_can_use_wheels
Modern pip can install wheels without wheel installed
2 parents d0c3a99 + c3bb6b3 commit e9dbed0

2 files changed

Lines changed: 9 additions & 24 deletions

File tree

manifests/pip.pp

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -162,29 +162,14 @@
162162
default => "${url}#egg=${egg_name}",
163163
}
164164

165-
# We need to jump through hoops to make sure we issue the correct pip command
166-
# depending on wheel support and versions.
167-
#
168-
# Pip does not support wheels prior to version 1.4.0
169-
# Pip wheels require setuptools/distribute > 0.8
170-
# Python 2.6 and older does not support setuptools/distribute > 0.8
171-
# Pip >= 1.5 tries to use wheels by default, even if wheel package is not
172-
# installed, in this case the --no-use-wheel flag needs to be passed
173-
# Versions prior to 1.5 don't support the --no-use-wheel flag
174-
#
175-
# To check for this we test for wheel parameter using help and then using
176-
# show, this makes sure we only use wheels if they are supported and
177-
# installed
178-
$wheel_check = "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} show wheel > /dev/null 2>&1 || wheel_support_flag='--no-binary :all:'; }"
179-
180165
$pip_install = "${pip_env} --log ${log}/pip.log install"
181166
$pip_common_args = "${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source}"
182167

183168
# Explicit version out of VCS when PIP supported URL is provided
184169
if $source =~ /^(git\+|hg\+|bzr\+|svn\+)(http|https|ssh|svn|sftp|ftp|lp)(:\/\/).+$/ {
185170
if $ensure != present and $ensure != latest {
186171
exec { "pip_install_${name}":
187-
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} ;}",
172+
command => "${pip_install} ${install_args} ${pip_common_args}@${ensure}#egg=${egg_name}",
188173
unless => "${pip_env} freeze --all | grep -i -e ${grep_regex}",
189174
user => $owner,
190175
group => $group,
@@ -196,7 +181,7 @@
196181
}
197182
} else {
198183
exec { "pip_install_${name}":
199-
command => "${wheel_check} ; { ${pip_install} ${install_args} \$wheel_support_flag ${pip_common_args} || ${pip_install} ${install_args} ${pip_common_args} ;}",
184+
command => "${pip_install} ${install_args} ${pip_common_args}",
200185
unless => "${pip_env} freeze --all | grep -i -e ${grep_regex}",
201186
user => $owner,
202187
group => $group,
@@ -213,7 +198,7 @@
213198
# Version formats as per http://guide.python-distribute.org/specification.html#standard-versioning-schemes
214199
# Explicit version.
215200
exec { "pip_install_${name}":
216-
command => "${wheel_check} ; { ${pip_install} ${install_args} \$wheel_support_flag ${pip_common_args}==${ensure} || ${pip_install} ${install_args} ${pip_common_args}==${ensure} ;}",
201+
command => "${pip_install} ${install_args} ${pip_common_args}==${ensure}",
217202
unless => "${pip_env} freeze --all | grep -i -e ${grep_regex} || ${pip_env} list | sed -e 's/[ ]\\+/==/' -e 's/[()]//g' | grep -i -e ${grep_regex}",
218203
user => $owner,
219204
group => $group,
@@ -228,7 +213,7 @@
228213
'present': {
229214
# Whatever version is available.
230215
exec { "pip_install_${name}":
231-
command => "${wheel_check} ; { ${pip_install} \$wheel_support_flag ${pip_common_args} || ${pip_install} ${pip_common_args} ;}",
216+
command => "${pip_install} ${pip_common_args}",
232217
unless => "${pip_env} freeze --all | grep -i -e ${grep_regex} || ${pip_env} list | sed -e 's/[ ]\\+/==/' -e 's/[()]//g' | grep -i -e ${grep_regex}",
233218
user => $owner,
234219
group => $group,
@@ -259,7 +244,7 @@
259244

260245
# Latest version.
261246
exec { "pip_install_${name}":
262-
command => "${wheel_check} ; { ${pip_install} --upgrade \$wheel_support_flag ${pip_common_args} || ${pip_install} --upgrade ${pip_common_args} ;}",
247+
command => "${pip_install} --upgrade ${pip_common_args}",
263248
unless => $unless_command,
264249
user => $owner,
265250
group => $group,

spec/defines/pip_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
context 'adds proxy to install command if proxy set' do
6868
let(:params) { { proxy: 'http://my.proxy:3128' } }
6969

70-
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 ;}") }
70+
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip --log /tmp/pip.log install --proxy=http://my.proxy:3128 rpyc') }
7171
end
7272
end
7373

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

83-
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 ;}") }
83+
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') }
8484
end
8585
end
8686

@@ -133,12 +133,12 @@
133133
context 'suceeds with no extras' do
134134
let(:params) { {} }
135135

136-
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 ;}") }
136+
it { is_expected.to contain_exec('pip_install_requests').with_command('pip --log /tmp/pip.log install requests') }
137137
end
138138
context 'succeeds with extras' do
139139
let(:params) { { extras: ['security'] } }
140140

141-
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] ;}") }
141+
it { is_expected.to contain_exec('pip_install_requests').with_command('pip --log /tmp/pip.log install requests[security]') }
142142
end
143143
end
144144
end

0 commit comments

Comments
 (0)