From c8b909a7c7a292d0c5b9458f6fa4821ff015d6d2 Mon Sep 17 00:00:00 2001 From: willejs Date: Thu, 16 Jan 2014 11:25:10 -0500 Subject: [PATCH] added version checking to virtualenv install not_if statement --- recipes/pip.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/recipes/pip.rb b/recipes/pip.rb index 1f89070..ebab521 100644 --- a/recipes/pip.rb +++ b/recipes/pip.rb @@ -36,7 +36,9 @@ cookbook_file "#{Chef::Config[:file_cache_path]}/ez_setup.py" do source 'ez_setup.py' mode "0644" - not_if "#{node['python']['binary']} -c 'import setuptools'" + not_if "#{node['python']['binary']} -c 'import pkg_resources, sys;\ + sys.exit(1) if float(pkg_resources.get_distribution(\"setuptools\")\ + .version[:3]) < 0.8 else sys.exit(0)'" end cookbook_file "#{Chef::Config[:file_cache_path]}/get-pip.py" do @@ -50,7 +52,9 @@ command <<-EOF #{node['python']['binary']} ez_setup.py EOF - not_if "#{node['python']['binary']} -c 'import setuptools'" + not_if "#{node['python']['binary']} -c 'import pkg_resources, sys;\ + sys.exit(1) if float(pkg_resources.get_distribution(\"setuptools\")\ + .version[:3]) < 0.8 else sys.exit(0)'" end execute "install-pip" do