Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5e02477

Browse files
garrypolleysethvargo
authored andcommitted
[COOK-3719] Allow alternative install python and update pip location
Signed-off-by: Seth Vargo <[email protected]>
1 parent f932b36 commit 5e02477

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

attributes/default.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@
3131
default['python']['prefix_dir'] = '/usr/local'
3232
end
3333

34-
default['python']['binary'] = "#{python['prefix_dir']}/bin/python"
34+
default['python']['binary'] = "#{node['python']['prefix_dir']}/bin/python"
3535

3636
default['python']['url'] = 'http://www.python.org/ftp/python'
3737
default['python']['version'] = '2.7.5'
3838
default['python']['checksum'] = '3b477554864e616a041ee4d7cef9849751770bc7c39adaf78a94ea145c488059'
3939
default['python']['configure_options'] = %W{--prefix=#{python['prefix_dir']}}
40+
default['python']['make_options'] = %W{install}
4041

4142
default['python']['setuptools_script_url'] = 'https://bitbucket.org/pypa/setuptools/raw/0.8/ez_setup.py'
4243
default['python']['pip_script_url'] = 'https://raw.github.com/pypa/pip/master/contrib/get-pip.py'
44+
default['python']['pip_location'] = "#{node['python']['prefix_dir']}/bin/pip"
45+
default['python']['virtualenv_location'] = "#{node['python']['prefix_dir']}/bin/virtualenv"

providers/pip.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ def pip_cmd(subcommand, version='')
160160
def which_pip(nr)
161161
if (nr.respond_to?("virtualenv") && nr.virtualenv)
162162
::File.join(nr.virtualenv,'/bin/pip')
163-
elsif node['python']['install_method'].eql?("source")
164-
::File.join(node['python']['prefix_dir'], "/bin/pip")
163+
elsif ::File.exists?(node['python']['pip_location'])
164+
node['python']['pip_location']
165165
else
166166
'pip'
167167
end

providers/virtualenv.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def load_current_resource
6161
end
6262

6363
def virtualenv_cmd()
64-
if node['python']['install_method'].eql?("source")
65-
::File.join(node['python']['prefix_dir'], "/bin/virtualenv")
64+
if ::File.exists?(node['python']['virtualenv_location'])
65+
node['python']['virtualenv_location']
6666
else
6767
"virtualenv"
6868
end

recipes/source.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
include_recipe "build-essential"
2222

2323
configure_options = node['python']['configure_options'].join(" ")
24+
make_options = node['python']['make_options'].join(" ")
2425

2526
packages = value_for_platform_family(
2627
"rhel" => ["openssl-devel","bzip2-devel","zlib-devel","expat-devel","db4-devel","sqlite-devel","ncurses-devel","readline-devel"],
@@ -46,7 +47,7 @@
4647
code <<-EOF
4748
tar -jxvf Python-#{version}.tar.bz2
4849
(cd Python-#{version} && ./configure #{configure_options})
49-
(cd Python-#{version} && make && make install)
50+
(cd Python-#{version} && make && make #{make_options})
5051
EOF
5152
environment({
5253
"LDFLAGS" => "-L#{node['python']['prefix_dir']} -L/usr/lib",

0 commit comments

Comments
 (0)