diff --git a/README.md b/README.md index caad30f..7b7a679 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 attribute 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. diff --git a/attributes/default.rb b/attributes/default.rb index aeeaa77..55ce064 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -19,6 +19,7 @@ # default['python']['install_method'] = 'package' +default['python']['version'] = '2.7.5' if python['install_method'] == 'package' case platform @@ -27,14 +28,18 @@ 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 python['install_type'] == 'altinstall' + 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']['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']}} 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",