diff --git a/attributes/default.rb b/attributes/default.rb index 85c96eb..6a457de 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -38,6 +38,7 @@ default['python']['checksum'] = '3b477554864e616a041ee4d7cef9849751770bc7c39adaf78a94ea145c488059' default['python']['configure_options'] = %W{--prefix=#{python['prefix_dir']}} default['python']['make_options'] = %W{install} +default['python']['recompile'] = false default['python']['pip_location'] = "#{node['python']['prefix_dir']}/bin/pip" default['python']['virtualenv_location'] = "#{node['python']['prefix_dir']}/bin/virtualenv" diff --git a/recipes/source.rb b/recipes/source.rb index ac8ed86..fbcaac2 100644 --- a/recipes/source.rb +++ b/recipes/source.rb @@ -34,28 +34,30 @@ version = node['python']['version'] install_path = "#{node['python']['prefix_dir']}/bin/python#{version.split(/(^\d+\.\d+)/)[1]}" +recompile = node['python']['recompile'] remote_file "#{Chef::Config[:file_cache_path]}/Python-#{version}.tgz" do source "#{node['python']['url']}/#{version}/Python-#{version}.tgz" checksum node['python']['checksum'] mode "0644" - not_if { ::File.exists?(install_path) } + not_if { !recompile && ::File.exists?(install_path) && `#{install_path} --version 2>&1`.strip =~ /#{version}/ } end bash "build-and-install-python" do cwd Chef::Config[:file_cache_path] code <<-EOF + rm -rf Python-#{version} tar -zxvf Python-#{version}.tgz (cd Python-#{version} && ./configure #{configure_options}) (cd Python-#{version} && make && make #{make_options}) EOF environment({ - "LDFLAGS" => "-L#{node['python']['prefix_dir']} -L/usr/lib", - "CPPFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/lib", - "CXXFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/lib", - "CFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/lib" + "LDFLAGS" => "-L#{node['python']['prefix_dir']} -L/usr/local/ssl/lib -L/usr/lib", + "CPPFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/local/ssl/lib -I/usr/lib", + "CXXFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/local/ssl/lib -I/usr/lib", + "CFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/local/ssl/lib -I/usr/lib" }) if platform?("ubuntu") && node['platform_version'].to_f >= 12.04 - not_if { ::File.exists?(install_path) } + not_if { !recompile && ::File.exists?(install_path) && `#{install_path} --version 2>&1`.strip =~ /#{version}/ } end # Link install as the default python, to support Python 3.x