From 7b032234193c12841f3ede0a5947fa032b8c30db Mon Sep 17 00:00:00 2001 From: Luca Marturana Date: Wed, 28 May 2014 11:17:40 +0200 Subject: [PATCH 1/2] Install pip on debian system from packages --- recipes/pip.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/recipes/pip.rb b/recipes/pip.rb index 17110fa..7acdccb 100644 --- a/recipes/pip.rb +++ b/recipes/pip.rb @@ -29,6 +29,11 @@ pip_binary = "/usr/bin/pip" elsif platform_family?("smartos") pip_binary = "/opt/local/bin/pip" +elsif platform_family?("debian") + package "python-pip" do + action :install + end + pip_binary = "/usr/bin/pip" else pip_binary = "/usr/local/bin/pip" end From 89b20dc16d66e6de4b1119f6ff3b4497ca766f1f Mon Sep 17 00:00:00 2001 From: Luca Marturana Date: Fri, 30 May 2014 13:15:52 +0200 Subject: [PATCH 2/2] Better implementation --- recipes/pip.rb | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/recipes/pip.rb b/recipes/pip.rb index 7acdccb..cf9f4cf 100644 --- a/recipes/pip.rb +++ b/recipes/pip.rb @@ -30,26 +30,29 @@ elsif platform_family?("smartos") pip_binary = "/opt/local/bin/pip" elsif platform_family?("debian") - package "python-pip" do - action :install - end pip_binary = "/usr/bin/pip" else pip_binary = "/usr/local/bin/pip" end -cookbook_file "#{Chef::Config[:file_cache_path]}/get-pip.py" do - source 'get-pip.py' - mode "0644" - not_if { ::File.exists?(pip_binary) } -end +if node['python']['pip_install_method'] == 'package' + package "python-pip" do + action :install + end +else + cookbook_file "#{Chef::Config[:file_cache_path]}/get-pip.py" do + source 'get-pip.py' + mode "0644" + not_if { ::File.exists?(pip_binary) } + end -execute "install-pip" do - cwd Chef::Config[:file_cache_path] - command <<-EOF - #{node['python']['binary']} get-pip.py - EOF - not_if { ::File.exists?(pip_binary) } + execute "install-pip" do + cwd Chef::Config[:file_cache_path] + command <<-EOF + #{node['python']['binary']} get-pip.py + EOF + not_if { ::File.exists?(pip_binary) } + end end python_pip 'setuptools' do