|
23 | 23 | # redhat/package: /usr/bin/pip (sha a8a3a3)
|
24 | 24 | # omnibus/source: /opt/local/bin/pip (sha 29ce9874)
|
25 | 25 |
|
| 26 | +major_version = node['platform_version'].split('.').first.to_i |
| 27 | +if node['python']['install_method'] == 'package' |
| 28 | + # COOK-1016 Handle RHEL/CentOS namings of python packages, by installing EPEL |
| 29 | + # repo & package |
| 30 | + case node["platform_family"] |
| 31 | + when 'rhel' |
| 32 | + include_recipe 'yum::epel' |
| 33 | + if major_version < 6 |
| 34 | + # rhel 5 defaults of py24 is laffable, better use source. |
| 35 | + install_ez_from_source = true |
| 36 | + install_pip_from_source = true |
| 37 | + else |
| 38 | + pip_pkgs = ["python-setuptools", "python-pip"] |
| 39 | + end |
| 40 | + when 'debian' |
| 41 | + pip_pkgs = ["python-pip", "python-setuptools"] |
| 42 | + else |
| 43 | + install_ez_from_source = true |
| 44 | + install_pip_from_source = true |
| 45 | + end |
| 46 | + if pip_pkgs |
| 47 | + pip_pkgs.each do |pkg| |
| 48 | + package pkg do |
| 49 | + action :install |
| 50 | + end |
| 51 | + end |
| 52 | + end |
| 53 | +end |
| 54 | + |
26 | 55 | if node['python']['install_method'] == 'source'
|
27 | 56 | pip_binary = "#{node['python']['prefix_dir']}/bin/pip"
|
28 |
| -elsif platform_family?("rhel") |
29 |
| - pip_binary = "/usr/bin/pip" |
30 |
| -elsif platform_family?("smartos") |
31 |
| - pip_binary = "/opt/local/bin/pip" |
| 57 | + install_ez_from_source = true |
| 58 | + install_pip_from_source = true |
32 | 59 | else
|
33 |
| - pip_binary = "/usr/local/bin/pip" |
34 |
| -end |
35 |
| - |
36 |
| -cookbook_file "#{Chef::Config[:file_cache_path]}/ez_setup.py" do |
37 |
| - source 'ez_setup.py' |
38 |
| - mode "0644" |
39 |
| - not_if "#{node['python']['binary']} -c 'import setuptools'" |
40 |
| -end |
41 |
| - |
42 |
| -cookbook_file "#{Chef::Config[:file_cache_path]}/get-pip.py" do |
43 |
| - source 'get-pip.py' |
44 |
| - mode "0644" |
45 |
| - not_if { ::File.exists?(pip_binary) } |
| 60 | + if platform_family?("rhel") |
| 61 | + pip_binary = "/usr/bin/pip" |
| 62 | + elsif platform_family?("smartos") |
| 63 | + pip_binary = "/opt/local/bin/pip" |
| 64 | + else |
| 65 | + pip_binary = "/usr/local/bin/pip" |
| 66 | + end |
46 | 67 | end
|
47 | 68 |
|
48 |
| -execute "install-setuptools" do |
49 |
| - cwd Chef::Config[:file_cache_path] |
50 |
| - command <<-EOF |
51 |
| - #{node['python']['binary']} ez_setup.py |
52 |
| - EOF |
53 |
| - not_if "#{node['python']['binary']} -c 'import setuptools'" |
| 69 | +if install_ez_from_source |
| 70 | + cookbook_file "#{Chef::Config[:file_cache_path]}/ez_setup.py" do |
| 71 | + source 'ez_setup.py' |
| 72 | + mode "0644" |
| 73 | + not_if "#{node['python']['binary']} -c 'import setuptools'" |
| 74 | + end |
| 75 | + execute "install-setuptools" do |
| 76 | + cwd Chef::Config[:file_cache_path] |
| 77 | + command <<-EOF |
| 78 | + #{node['python']['binary']} ez_setup.py |
| 79 | + EOF |
| 80 | + not_if "#{node['python']['binary']} -c 'import setuptools'" |
| 81 | + end |
54 | 82 | end
|
55 | 83 |
|
56 |
| -execute "install-pip" do |
57 |
| - cwd Chef::Config[:file_cache_path] |
58 |
| - command <<-EOF |
59 |
| - #{node['python']['binary']} get-pip.py |
60 |
| - EOF |
61 |
| - not_if { ::File.exists?(pip_binary) } |
| 84 | +if install_pip_from_source |
| 85 | + cookbook_file "#{Chef::Config[:file_cache_path]}/get-pip.py" do |
| 86 | + source 'get-pip.py' |
| 87 | + mode "0644" |
| 88 | + not_if { ::File.exists?(pip_binary) } |
| 89 | + end |
| 90 | + execute "install-pip" do |
| 91 | + cwd Chef::Config[:file_cache_path] |
| 92 | + command <<-EOF |
| 93 | + #{node['python']['binary']} get-pip.py |
| 94 | + EOF |
| 95 | + not_if { ::File.exists?(pip_binary) } |
| 96 | + end |
62 | 97 | end
|
0 commit comments