From e767385f4a730dc51bac3fa80e086ac74cd247df Mon Sep 17 00:00:00 2001 From: Thomas Cravey Date: Fri, 26 Jul 2013 11:59:19 -0500 Subject: [PATCH 1/8] source altinstall --- attributes/default.rb | 1 + recipes/pip.rb | 19 +++++++++++++++++++ recipes/source.rb | 3 ++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index aeeaa77..ad728d4 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -29,6 +29,7 @@ end else default['python']['prefix_dir'] = '/usr/local' + default['python']['install_type'] = 'install' end default['python']['binary'] = "#{python['prefix_dir']}/bin/python" diff --git a/recipes/pip.rb b/recipes/pip.rb index 65acfa7..0256ff1 100644 --- a/recipes/pip.rb +++ b/recipes/pip.rb @@ -25,6 +25,7 @@ if node['python']['install_method'] == 'source' pip_binary = "#{node['python']['prefix_dir']}/bin/pip" + major_minor_version = node['python']['version'][/\d\.\d/] elsif platform_family?("rhel") pip_binary = "/usr/bin/pip" elsif platform_family?("smartos") @@ -53,6 +54,15 @@ not_if "#{node['python']['binary']} -c 'import setuptools'" end +execute "altinstall-setuptools" do + cwd Chef::Config[:file_cache_path] + command <<-EOF + #{node['python']['binary']}#{major_minor_version} ez_setup.py + EOF + not_if "#{node['python']['binary']}-2.7 -c 'import setuptools'" + only_if {node['python']['install_type'] == "altinstall"} +end + execute "install-pip" do cwd Chef::Config[:file_cache_path] command <<-EOF @@ -60,3 +70,12 @@ EOF not_if { ::File.exists?(pip_binary) } end + +execute "altinstall-pip" do + cwd Chef::Config[:file_cache_path] + command <<-EOF + #{node['python']['binary']}#{major_minor_version} get-pip.py + EOF + not_if { ::File.exists?(pip_binary) } + only_if {node['python']['install_type'] == "altinstall"} +end diff --git a/recipes/source.rb b/recipes/source.rb index eb8288d..609a9d5 100644 --- a/recipes/source.rb +++ b/recipes/source.rb @@ -33,6 +33,7 @@ version = node['python']['version'] install_path = "#{node['python']['prefix_dir']}/bin/python#{version.split(/(^\d+\.\d+)/)[1]}" +install_type = node['python']['install_type'] remote_file "#{Chef::Config[:file_cache_path]}/Python-#{version}.tar.bz2" do source "#{node['python']['url']}/#{version}/Python-#{version}.tar.bz2" @@ -46,7 +47,7 @@ code <<-EOF tar -jxvf Python-#{version}.tar.bz2 (cd Python-#{version} && ./configure #{configure_options}) - (cd Python-#{version} && make && make install) + (cd Python-#{version} && make && make #{install_type}) EOF environment({ "LDFLAGS" => "-L#{node['python']['prefix_dir']} -L/usr/lib", From 72bab61c8444abaa088888fa3fc653f637d25c6a Mon Sep 17 00:00:00 2001 From: Thomas Cravey Date: Fri, 26 Jul 2013 12:35:53 -0500 Subject: [PATCH 2/8] altinstall retry --- recipes/pip.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/pip.rb b/recipes/pip.rb index 0256ff1..886eff8 100644 --- a/recipes/pip.rb +++ b/recipes/pip.rb @@ -25,7 +25,7 @@ if node['python']['install_method'] == 'source' pip_binary = "#{node['python']['prefix_dir']}/bin/pip" - major_minor_version = node['python']['version'][/\d\.\d/] + major_minor_version = "#{node['python']['version']}"[/\d\.\d/] elsif platform_family?("rhel") pip_binary = "/usr/bin/pip" elsif platform_family?("smartos") From 96f8fc50fa32789199b2703dc382eaf50253cb73 Mon Sep 17 00:00:00 2001 From: Thomas Cravey Date: Fri, 26 Jul 2013 12:46:32 -0500 Subject: [PATCH 3/8] altinstall retry --- recipes/pip.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/pip.rb b/recipes/pip.rb index 886eff8..3692117 100644 --- a/recipes/pip.rb +++ b/recipes/pip.rb @@ -25,7 +25,7 @@ if node['python']['install_method'] == 'source' pip_binary = "#{node['python']['prefix_dir']}/bin/pip" - major_minor_version = "#{node['python']['version']}"[/\d\.\d/] + major_minor_version = node['python']['version'][/\d\.\d/] elsif platform_family?("rhel") pip_binary = "/usr/bin/pip" elsif platform_family?("smartos") @@ -59,7 +59,7 @@ command <<-EOF #{node['python']['binary']}#{major_minor_version} ez_setup.py EOF - not_if "#{node['python']['binary']}-2.7 -c 'import setuptools'" + not_if "#{node['python']['binary']}#{major_minor_version} -c 'import setuptools'" only_if {node['python']['install_type'] == "altinstall"} end @@ -76,6 +76,6 @@ command <<-EOF #{node['python']['binary']}#{major_minor_version} get-pip.py EOF - not_if { ::File.exists?(pip_binary) } + not_if { ::File.exists?(pip_binary + "-" + major_minor_version) } only_if {node['python']['install_type'] == "altinstall"} end From 91a5754602264e76dd27308a446497d0a80397f2 Mon Sep 17 00:00:00 2001 From: "T.J. Cravey" Date: Fri, 26 Jul 2013 18:26:47 -0500 Subject: [PATCH 4/8] Noted new attribute, cleaned up errors. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index caad30f..534d319 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Attributes See `attributes/default.rb` for default values. * `node["python"]["install_method"]` - method to install python with, default `package`. +* `node["python"]["install_type"]` - when above attirbute is set to `source`, choose make `install` or make `altinstall` for installing compiled code, default `install`. The file also contains the following attributes: @@ -50,8 +51,6 @@ Install packages using the new hotness in Python package management...[`pip`](ht - :install: Install a pip package - if version is provided, install that specific version (default) - :upgrade: Upgrade a pip package - if version is provided, upgrade to that specific version - :remove: Remove a pip package -- :user: User to run pip as, for using with virtualenv -- :group: Group to run pip as, for using with virtualenv - :purge: Purge a pip package (this usually entails removing configuration files as well as the package itself). With pip packages this behaves the same as `:remove` # Attribute Parameters @@ -59,6 +58,8 @@ Install packages using the new hotness in Python package management...[`pip`](ht - package_name: name attribute. The name of the pip package to install - version: the version of the package to install/upgrade. If no version is given latest is assumed. - virtualenv: virtualenv environment to install pip package into +- user: User to run pip as, for using with virtualenv +- group: Group to run pip as, for using with virtualenv - options: Add additional options to the underlying pip package command - timeout: timeout in seconds for the command to execute. Useful for pip packages that may take a long time to install. Default 900 seconds. From 9c2cccec741642f8c1988735bb5f66e01b7b0c00 Mon Sep 17 00:00:00 2001 From: Thomas Cravey Date: Fri, 2 Aug 2013 13:38:37 -0500 Subject: [PATCH 5/8] removed separate sections for installing pip and setuptools with altinstall and instead changed binary for altinstall --- attributes/default.rb | 24 ++++++++++++++---------- recipes/pip.rb | 19 ------------------- 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index ad728d4..ffaedd6 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -20,6 +20,14 @@ default['python']['install_method'] = 'package' +default['python']['url'] = 'http://www.python.org/ftp/python' +default['python']['version'] = '2.7.5' +default['python']['checksum'] = '3b477554864e616a041ee4d7cef9849751770bc7c39adaf78a94ea145c488059' +default['python']['configure_options'] = %W{--prefix=#{python['prefix_dir']}} + +default['python']['setuptools_script_url'] = 'https://bitbucket.org/pypa/setuptools/raw/0.8/ez_setup.py' +default['python']['pip_script_url'] = 'https://raw.github.com/pypa/pip/master/contrib/get-pip.py' + if python['install_method'] == 'package' case platform when "smartos" @@ -27,17 +35,13 @@ else default['python']['prefix_dir'] = '/usr' end + default['python']['binary'] = "#{python['prefix_dir']}/bin/python" else default['python']['prefix_dir'] = '/usr/local' default['python']['install_type'] = 'install' + if node['python']['install_type'] == 'altinstall' + default['python']['binary'] = "#{python['prefix_dir']}/bin/python#{node['python']['version'].split(/(^\d+\.\d+)/)[1]}" + else + default['python']['binary'] = "#{python['prefix_dir']}/bin/python" + end end - -default['python']['binary'] = "#{python['prefix_dir']}/bin/python" - -default['python']['url'] = 'http://www.python.org/ftp/python' -default['python']['version'] = '2.7.5' -default['python']['checksum'] = '3b477554864e616a041ee4d7cef9849751770bc7c39adaf78a94ea145c488059' -default['python']['configure_options'] = %W{--prefix=#{python['prefix_dir']}} - -default['python']['setuptools_script_url'] = 'https://bitbucket.org/pypa/setuptools/raw/0.8/ez_setup.py' -default['python']['pip_script_url'] = 'https://raw.github.com/pypa/pip/master/contrib/get-pip.py' diff --git a/recipes/pip.rb b/recipes/pip.rb index 3692117..65acfa7 100644 --- a/recipes/pip.rb +++ b/recipes/pip.rb @@ -25,7 +25,6 @@ if node['python']['install_method'] == 'source' pip_binary = "#{node['python']['prefix_dir']}/bin/pip" - major_minor_version = node['python']['version'][/\d\.\d/] elsif platform_family?("rhel") pip_binary = "/usr/bin/pip" elsif platform_family?("smartos") @@ -54,15 +53,6 @@ not_if "#{node['python']['binary']} -c 'import setuptools'" end -execute "altinstall-setuptools" do - cwd Chef::Config[:file_cache_path] - command <<-EOF - #{node['python']['binary']}#{major_minor_version} ez_setup.py - EOF - not_if "#{node['python']['binary']}#{major_minor_version} -c 'import setuptools'" - only_if {node['python']['install_type'] == "altinstall"} -end - execute "install-pip" do cwd Chef::Config[:file_cache_path] command <<-EOF @@ -70,12 +60,3 @@ EOF not_if { ::File.exists?(pip_binary) } end - -execute "altinstall-pip" do - cwd Chef::Config[:file_cache_path] - command <<-EOF - #{node['python']['binary']}#{major_minor_version} get-pip.py - EOF - not_if { ::File.exists?(pip_binary + "-" + major_minor_version) } - only_if {node['python']['install_type'] == "altinstall"} -end From 57f7fe75e0abffbcd364c384cb1a0686aea68e4d Mon Sep 17 00:00:00 2001 From: Thomas Cravey Date: Fri, 2 Aug 2013 14:32:10 -0500 Subject: [PATCH 6/8] attribute if --- attributes/default.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index ffaedd6..78b2fec 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -39,7 +39,7 @@ else default['python']['prefix_dir'] = '/usr/local' default['python']['install_type'] = 'install' - if node['python']['install_type'] == 'altinstall' + if python['install_type'] == 'altinstall' default['python']['binary'] = "#{python['prefix_dir']}/bin/python#{node['python']['version'].split(/(^\d+\.\d+)/)[1]}" else default['python']['binary'] = "#{python['prefix_dir']}/bin/python" From 128d90b82d2c2b45366ba310a063777017d141a2 Mon Sep 17 00:00:00 2001 From: Thomas Cravey Date: Fri, 2 Aug 2013 14:55:41 -0500 Subject: [PATCH 7/8] building --- attributes/default.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 78b2fec..55ce064 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -19,14 +19,7 @@ # default['python']['install_method'] = 'package' - -default['python']['url'] = 'http://www.python.org/ftp/python' default['python']['version'] = '2.7.5' -default['python']['checksum'] = '3b477554864e616a041ee4d7cef9849751770bc7c39adaf78a94ea145c488059' -default['python']['configure_options'] = %W{--prefix=#{python['prefix_dir']}} - -default['python']['setuptools_script_url'] = 'https://bitbucket.org/pypa/setuptools/raw/0.8/ez_setup.py' -default['python']['pip_script_url'] = 'https://raw.github.com/pypa/pip/master/contrib/get-pip.py' if python['install_method'] == 'package' case platform @@ -40,8 +33,15 @@ default['python']['prefix_dir'] = '/usr/local' default['python']['install_type'] = 'install' if python['install_type'] == 'altinstall' - default['python']['binary'] = "#{python['prefix_dir']}/bin/python#{node['python']['version'].split(/(^\d+\.\d+)/)[1]}" + default['python']['binary'] = "#{python['prefix_dir']}/bin/python#{python['version'].split(/(^\d+\.\d+)/)[1]}" else default['python']['binary'] = "#{python['prefix_dir']}/bin/python" end end + +default['python']['url'] = 'http://www.python.org/ftp/python' +default['python']['checksum'] = '3b477554864e616a041ee4d7cef9849751770bc7c39adaf78a94ea145c488059' +default['python']['configure_options'] = %W{--prefix=#{python['prefix_dir']}} + +default['python']['setuptools_script_url'] = 'https://bitbucket.org/pypa/setuptools/raw/0.8/ez_setup.py' +default['python']['pip_script_url'] = 'https://raw.github.com/pypa/pip/master/contrib/get-pip.py' From b534eba022a33a61181e193845fb8c37b85b0515 Mon Sep 17 00:00:00 2001 From: "T.J. Cravey" Date: Fri, 23 Aug 2013 17:40:48 -0500 Subject: [PATCH 8/8] Corrected typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 534d319..7b7a679 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Attributes See `attributes/default.rb` for default values. * `node["python"]["install_method"]` - method to install python with, default `package`. -* `node["python"]["install_type"]` - when above attirbute is set to `source`, choose make `install` or make `altinstall` for installing compiled code, default `install`. +* `node["python"]["install_type"]` - when above attribute is set to `source`, choose make `install` or make `altinstall` for installing compiled code, default `install`. The file also contains the following attributes: