Skip to content
This repository was archived by the owner on Oct 2, 2018. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like one too many variables to me - isn't it really just another install method - package, source, source-altinstall? Right now if you were to typo install_type you'd get a random command line passed into the make install step which might not fail, but leave you with a real headscratcher as to why Python's not where you thought it would be...


The file also contains the following attributes:

Expand All @@ -50,15 +51,15 @@ 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

- 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.

Expand Down
11 changes: 8 additions & 3 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#

default['python']['install_method'] = 'package'
default['python']['version'] = '2.7.5'

if python['install_method'] == 'package'
case platform
Expand All @@ -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']}}

Expand Down
3 changes: 2 additions & 1 deletion recipes/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
Expand Down