From 6d88eb88f3ec00655a25f9cb83efd58f293ef4fe Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 15:25:27 -0500 Subject: Fix wheel support and pip version compatability Fix wheel support and compatability for older pip versions by detecting suppport when running the pip command inside a virtualenv. --- manifests/pip.pp | 20 ++++++++++---------- manifests/virtualenv.pp | 7 ++++--- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'manifests') diff --git a/manifests/pip.pp b/manifests/pip.pp index ba83658..a818e23 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -70,13 +70,6 @@ define python::pip ( default => "--proxy=${proxy}", } - # Python 2.6 and older don't support setuptools > 0.8 which is required - # for pip wheel support, pip therefor requires --no-use-wheel flag - if ( versioncmp($::python_version,'2.6') > 0 ) { - $wheel_support_flag = '--no-use-wheel' - } else { - $wheel_support_flag = '' - } $grep_regex = $name ? { /==/ => "^${name}\$", @@ -93,10 +86,17 @@ define python::pip ( default => "${url}#egg=${egg_name}", } + # Python 2.6 and older don't support setuptools/distribute > 0.8 which is required + # for pip wheel support, pip therefor requires --no-use-wheel flag if the + # pip version is more recent thatn 1.4.1 but using an old python or + # setuputils/distribute version + # To check for this we test for wheel parameter using help and then using + # version, this makes sure we only use wheels if they are supported + case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install $install_args ${wheel_support_flag} ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag="--no-use-wheel"; $pip_env --log ${cwd}/pip.log install $install_args \$wheel_support_flag ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -106,7 +106,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install --upgrade ${wheel_support_flag} ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag="--no-use-wheel"; $pip_env x--log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], @@ -115,7 +115,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install -U $install_args ${wheel_support_flag} ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag="--no-use-wheel"; $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, } diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 7b4b53c..7b39212 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -110,9 +110,10 @@ define python::virtualenv ( $system_pkgs_flag = '' } - # Python 2.6 and older don't support setuptools > 0.8 which is required - # for pip wheel support, pip therefor requires --no-use-wheel flag - if ( versioncmp($::python_version,'2.6') > 0 ) { + # Python 2.6 and older don't support setuptools/distribute > 0.8 which is required + # for pip wheel support, pip therefor requires --no-use-wheel flag if the + # version is newer than 1.4.1 when they added wheels + if (( versioncmp($::python_version,'2.6') > 0 and ( versioncmp($::pip_version,'1.4.1') > 0)) { $wheel_support_flag = '--no-use-wheel' } else { $wheel_support_flag = '' -- cgit v1.2.3