poise / poise-python

A Chef cookbook to provide a unified interface for installing Python, managing Python packages, and creating virtualenvs.
Apache License 2.0
124 stars 108 forks source link

python_execute with virtualenv specified can't see pip it just installed #54

Open jblaine opened 8 years ago

jblaine commented 8 years ago

I can't win this week :(

python_runtime '2' do
  provider :system
end

python_virtualenv node['r701-graphite']['server']['approot'] do
  user node['r701-graphite']['server']['user']
end

python_package 'whisper' do
  version node['r701-graphite']['server']['whisper_version']
end

python_package 'carbon' do
  version node['r701-graphite']['server']['carbon_version']
end

# graphite-web 0.9.15 package has a bug:
# https://github.com/graphite-project/graphite-web/issues/1508
# led to me using options with python_package
# which led to:
# https://github.com/poise/poise-python/issues/53
# which led to this code being commented out :(
# python_package 'graphite-web' do
#   options '--install-option="--prefix=/opt/graphite" --install-option="--install-lib=/opt/graphite/webapp"'
#   version node['r701-graphite']['server']['graphite_web_version']
# end

python_execute 'Install graphite-web a specific way' do
  command "pip install graphite-web==#{node['r701-graphite']['server']['graphite_web_version']} --install-option='--prefix=/opt/graphite' --install-option='--install-lib=/opt/graphite/webapp'"
  virtualenv node['r701-graphite']['server']['approot']
end
* python_runtime_pip[2] action install (up to date)
* python_package[setuptools] action install (up to date)
* python_package[wheel] action install (up to date)
* python_package[virtualenv] action install (up to date)
 (up to date)
* python_virtualenv[/etc-metrics.our.org/graphite] action create
  * python_runtime_pip[/etc-metrics.our.org/graphite] action install (up to date)
  * python_package[setuptools] action install (up to date)
  * python_package[wheel] action install (up to date)
   (up to date)
* python_package[whisper] action install (up to date)
* python_package[carbon] action install (up to date)
* python_execute[Install graphite-web a specific way] action run
  [execute] /etc-metrics.our.org/graphite/bin/python: can't open file 'pip': [Errno 2] No such file or directory
...
  Mixlib::ShellOut::ShellCommandFailed
  ------------------------------------
  Expected process to exit with [0], but received '2'
  ---- Begin output of /etc-metrics.our.org/graphite/bin/python pip install graphite-web==0.9.15 --install-option='--prefix=/opt/graphite' --install-option='--install-lib=/opt/graphite/webapp' ----
  STDOUT:
  STDERR: /etc-metrics.our.org/graphite/bin/python: can't open file 'pip': [Errno 2] No such file or directory
  ---- End output of /etc-metrics.our.org/graphite/bin/python pip install graphite-web==0.9.15 --install-option='--prefix=/opt/graphite' --install-option='--install-lib=/opt/graphite/webapp' ----
  Ran /etc-metrics.our.org/graphite/bin/python pip install graphite-web==0.9.15 --install-option='--prefix=/opt/graphite' --install-option='--install-lib=/opt/graphite/webapp' returned 2
jblaine commented 8 years ago
tmp:etc-metrics# ls /etc-metrics.our.org/graphite/bin/pip*
pip     pip2    pip2.7
tmp:etc-metrics#
coderanger commented 8 years ago

Change your execute to be -m pip and it will work 1000% better and more consistently :) It skips the pip binary and runs it internally as a module.