PageRenderTime 52ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/cookbooks/python/recipes/pip.rb

https://bitbucket.org/jimrhoskins/bam
Ruby | 46 lines | 18 code | 3 blank | 25 comment | 2 complexity | 8a64f1b7e848f0de4f201935e27f7671 MD5 | raw file
Possible License(s): Apache-2.0
  1. #
  2. # Author:: Seth Chisamore <schisamo@opscode.com>
  3. # Cookbook Name:: python
  4. # Recipe:: pip
  5. #
  6. # Copyright 2011, Opscode, Inc.
  7. #
  8. # Licensed under the Apache License, Version 2.0 (the "License");
  9. # you may not use this file except in compliance with the License.
  10. # You may obtain a copy of the License at
  11. #
  12. # http://www.apache.org/licenses/LICENSE-2.0
  13. #
  14. # Unless required by applicable law or agreed to in writing, software
  15. # distributed under the License is distributed on an "AS IS" BASIS,
  16. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. # See the License for the specific language governing permissions and
  18. # limitations under the License.
  19. #
  20. if platform_family?("rhel") and node['python']['install_method'] == 'package'
  21. pip_binary = "/usr/bin/pip"
  22. elsif platform_family?("smartos")
  23. pip_binary = "/opt/local/bin/pip"
  24. else
  25. pip_binary = "/usr/local/bin/pip"
  26. end
  27. # Ubuntu's python-setuptools, python-pip and python-virtualenv packages
  28. # are broken...this feels like Rubygems!
  29. # http://stackoverflow.com/questions/4324558/whats-the-proper-way-to-install-pip-virtualenv-and-distribute-for-python
  30. # https://bitbucket.org/ianb/pip/issue/104/pip-uninstall-on-ubuntu-linux
  31. remote_file "#{Chef::Config[:file_cache_path]}/distribute_setup.py" do
  32. source "http://python-distribute.org/distribute_setup.py"
  33. mode "0644"
  34. not_if { ::File.exists?(pip_binary) }
  35. end
  36. execute "install-pip" do
  37. cwd Chef::Config[:file_cache_path]
  38. command <<-EOF
  39. #{node['python']['binary']} distribute_setup.py
  40. #{::File.dirname(pip_binary)}/easy_install pip
  41. EOF
  42. not_if { ::File.exists?(pip_binary) }
  43. end