GithubHelp home page GithubHelp logo

poise / python Goto Github PK

View Code? Open in Web Editor NEW
567.0 567.0 607.0 5.98 MB

THIS COOKBOOK IS DEPRECATED – Chef cookbook to install Python and related tools

License: Apache License 2.0

Ruby 1.94% Python 98.00% Shell 0.07%

python's Introduction

python Cookbook

Build Status

Installs and configures Python. Also includes LWRPs for managing python packages with pip and virtualenv isolated Python environments.

THIS COOKBOOK IS DEPRECATED

Poise-python is a vastly better cookbook for managing Python-related things. This cookbook will remain for compatibility but any future release will only be to gut it and turn it into a wrapper for poise-python.

I REPEAT, THIS COOKBOOK IS DEPRECATED

Requirements

Platforms

  • Debian, Ubuntu
  • CentOS, Red Hat, Fedora

Cookbooks

  • build-essential
  • yum

NOTE: The yum cookbook is a dependency of the cookbook, and will be used to install EPEL on RedHet/CentOS 5.x systems to provide the Python 2.6 packages.

Attributes

See attributes/default.rb for default values.

  • node["python"]["install_method"] - method to install python with, default package.

The file also contains the following attributes:

  • platform specific locations and settings
  • source installation settings

Resource/Provider

This cookbook includes LWRPs for managing:

  • pip packages
  • virtualenv isolated Python environments

python_pip

Install packages using the new hotness in Python package management...pip. Yo dawg...easy_install is so 2009, you better ask your local Pythonista if you don't know! The usage semantics are like that of any normal package provider.

Actions

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

Examples

# install latest gunicorn into system path
python_pip "gunicorn"

# target a virtualenv
python_pip "gunicorn" do
  virtualenv "/home/ubuntu/my_ve"
end
# install Django 1.1.4
python_pip "django" do
  version "1.1.4"
end

python_virtualenv

virtualenv is a great tool that creates isolated python environments. Think of it as RVM without all those hipsters and tight jeans.

Actions

  • :create: creates a new virtualenv
  • :delete: deletes an existing virtualenv

Attribute Parameters

  • path: name attribute. The path where the virtualenv will be created
  • interpreter: The Python interpreter to use. default is null (i.e. use whatever python the virtualenv command is using).
  • owner: The owner for the virtualenv
  • group: The group owner of the file (string or id)
  • options : Command line options (string)

Examples

# create a 2.6 virtualenv owned by ubuntu user
python_virtualenv "/home/ubuntu/my_cool_ve" do
  owner "ubuntu"
  group "ubuntu"
  action :create
end
# create a Python 2.4 virtualenv
python_virtualenv "/home/ubuntu/my_old_ve" do
  interpreter "python2.4"
  owner "ubuntu"
  group "ubuntu"
  action :create
end
# create a Python 2.6 virtualenv with access to the global packages owned by ubuntu user
python_virtualenv "/home/ubuntu/my_old_ve" do
  owner "ubuntu"
  group "ubuntu"
  options "--system-site-packages"
  action :create
end

Usage

default

Include default recipe in a run list, to get python, pip and virtualenv. Installs python by package or source depending on the platform.

package

Installs Python from packages.

source

Installs Python from source.

pip

Installs pip from source.

virtualenv

Installs virtualenv using the python_pip resource.

License & Authors

Copyright:: 2011, Chef Software, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

python's People

Contributors

akiernan avatar benjaminws avatar btm avatar captnswing avatar chr4 avatar coderanger avatar comandrei avatar e100 avatar frick avatar garrypolley avatar guilhem avatar hectcastro avatar hltbra avatar jjhuff avatar joestump avatar ka2n avatar kamaradclimber avatar mal avatar miketheman avatar nathanph avatar nathenharvey avatar prajaktapurohit avatar rgbkrk avatar rody avatar schisamo avatar scottmlikens avatar sethvargo avatar spheromak avatar tk0miya avatar zakkie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python's Issues

Create release and push to Chef Supermarket

Hi, it looks like the current version, 1.4.7, does not have a release here on Github and it has not been pushed to the Supermarket. Can you please push this to the Supermarket?

Allow python_pip to pass --allow-external and --allow-unverified in order to download externally hosted packages

As of pip 1.5.x, the user is required to add --allow-external and --allow-unverified in order to download a package from an external site. By default python_pip doesn't pass this argument and in pip 1.5.x chef throws error as pip doesn't look into external sites. Here is the pip issue link => pypa/pip#1586 .
In my case I was not able to install pyodbc using chef with pip 1.5, and I had to revert back to pip 1.4.1 after which pyodbc was successfully installed

FAIL ::pip installer CentOS 5.x

It fails because default python version is pretty old.
We must match it first and include_recipe 'python::package' if here RHEL 5.x.

get-pip.py got no attribute 'PROTOCOL_SSLv3' error

The AttributeError: 'module' object has no attribute 'PROTOCOL_SSLv3' is showed when running get-pip.py. The problem is that the requests package in get-pip.py is old one which expects ssl.PROTOCOL_SSLv3 exists. However, this is not the case because SSLv3 is insecure now and distro likes Debian remove it from OpenSSL using OPENSSL_NO_SSLv3. This behavior is compliance with official Python document, and requests upstream had fix not to assume ssl.PROTOCOL_SSLv3 exists.

Please help to update the content of get-pip.py so that the error will not happen, thanks.

cookbook says it updates setuptools, but it doesn't

I am experiencing a strange corner case where the python cookbook's python_pip[virtualenv] fails because setuptools is at a really old version (0.6c11). python_pip[setuptools] runs before it, and says it will update setuptools, but it doesn't actually; I have to run 'pip install --upgrade setuptools' for it to work.

[2014-05-06 14:32:35,746][INFO] INFO: Processing execute[install-pip] action run (python::pip line 42)
[2014-05-06 14:32:35,746][INFO] INFO: Processing python_pip[setuptools] action upgrade (python::pip line 50)
[2014-05-06 14:32:36,443][INFO] INFO: Upgrading python_pip[setuptools] version from uninstalled to latest
[2014-05-06 14:32:42,556][INFO] INFO: Processing python_pip[virtualenv] action upgrade (python::virtualenv line 23)
[2014-05-06 14:32:42,860][INFO] INFO: Upgrading python_pip[virtualenv] version from 1.10.1 to latest
[2014-05-06 14:32:43,838][INFO] ================================================================================
[2014-05-06 14:32:43,838][INFO] Error executing action `upgrade` on resource 'python_pip[virtualenv]'
[2014-05-06 14:32:43,839][INFO] ================================================================================
[2014-05-06 14:32:43,839][INFO] Mixlib::ShellOut::ShellCommandFailed
[2014-05-06 14:32:43,839][INFO] ------------------------------------
[2014-05-06 14:32:43,839][INFO] Expected process to exit with [0], but received '1'
[2014-05-06 14:32:43,839][INFO] ---- Begin output of pip install  --upgrade virtualenv ----
[2014-05-06 14:32:43,839][INFO] STDOUT: Downloading/unpacking virtualenv from https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.11.5.tar.gz#md5=f61636143193499e7700ec9b70756ff6
[2014-05-06 14:32:43,839][INFO]   Running setup.py egg_info for package virtualenv
[2014-05-06 14:32:43,839][INFO]     /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'entry_points'
[2014-05-06 14:32:43,839][INFO]       warnings.warn(msg)
[2014-05-06 14:32:43,839][INFO]     /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'zip_safe'
[2014-05-06 14:32:43,839][INFO]       warnings.warn(msg)
[2014-05-06 14:32:43,839][INFO]     /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'test_suite'
[2014-05-06 14:32:43,840][INFO]       warnings.warn(msg)
[2014-05-06 14:32:43,840][INFO]     /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'tests_require'
[2014-05-06 14:32:43,840][INFO]       warnings.warn(msg)
[2014-05-06 14:32:43,840][INFO]     usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
[2014-05-06 14:32:43,840][INFO]        or: -c --help [cmd1 cmd2 ...]
[2014-05-06 14:32:43,840][INFO]        or: -c --help-commands
[2014-05-06 14:32:43,840][INFO]        or: -c cmd --help
[2014-05-06 14:32:43,840][INFO]     error: invalid command 'egg_info'
[2014-05-06 14:32:43,840][INFO]     Complete output from command python setup.py egg_info:
[2014-05-06 14:32:43,840][INFO]     /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'entry_points'
[2014-05-06 14:32:43,840][INFO]   warnings.warn(msg)
[2014-05-06 14:32:43,841][INFO] /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'zip_safe'
[2014-05-06 14:32:43,841][INFO]   warnings.warn(msg)
[2014-05-06 14:32:43,841][INFO] /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'test_suite'
[2014-05-06 14:32:43,841][INFO]   warnings.warn(msg)
[2014-05-06 14:32:43,841][INFO] /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'tests_require'
[2014-05-06 14:32:43,841][INFO]   warnings.warn(msg)
[2014-05-06 14:32:43,841][INFO] usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
[2014-05-06 14:32:43,842][INFO]    or: -c --help [cmd1 cmd2 ...]
[2014-05-06 14:32:43,842][INFO]    or: -c --help-commands
[2014-05-06 14:32:43,842][INFO]    or: -c cmd --help
[2014-05-06 14:32:43,842][INFO] error: invalid command 'egg_info'
[2014-05-06 14:32:43,842][INFO] ----------------------------------------
[2014-05-06 14:32:43,842][INFO] Cleaning up...
[2014-05-06 14:32:43,842][INFO] Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/virtualenv
[2014-05-06 14:32:43,842][INFO] Storing complete log in /home/ubuntu/.pip/pip.log
[2014-05-06 14:32:43,842][INFO] STDERR:
[2014-05-06 14:32:43,842][INFO] ---- End output of pip install  --upgrade virtualenv ----
[2014-05-06 14:32:43,843][INFO] Ran pip install  --upgrade virtualenv returned 1

source installation fails to install to prefix_dir with solo

I am using chef-solo to install python to a specific location.
When wrapping the python cookbook, modifying the default prefix_dir is not taking effect unless it's done in solo.json.

The problem arises due to the loading order of the default attributes.
https://github.com/poise/python/blob/master/attributes/default.rb#L39:

default['python']['configure_options'] = %W{--prefix=#{python['prefix_dir']}}

Loads first and creates the configure_options from the prefix_dir that is used for the source configuration
https://github.com/poise/python/blob/master/recipes/source.rb#L23:

 configure_options = node['python']['configure_options'].join(" ")

and https://github.com/poise/python/blob/master/recipes/source.rb#L49:

  (cd Python-#{version} && ./configure #{configure_options})

Is this intentional?
It might be more appropriate to calculate the configure_options directly in source.rb.

execute[install-pip] fails on Debian 8 #SSLv3

reason: http://stackoverflow.com/questions/28987891/patch-pyopenssl-for-sslv3-issue

log:

      Recipe: python::pip
         * cookbook_file[/tmp/kitchen/cache/get-pip.py] action create (up to date)
       * execute[install-pip] action run

           ================================================================================
           Error executing action `run` on resource 'execute[install-pip]'
           ================================================================================

       Mixlib::ShellOut::ShellCommandFailed
           ------------------------------------
           Expected process to exit with [0], but received '1'
           ---- Begin output of   /usr/bin/python get-pip.py
        ----
           STDOUT: 
           STDERR: Traceback (most recent call last):
             File "get-pip.py", line 21529, in <module>
        do_exec(entry, locals())
             File "<string>", line 1, in do_exec
             File "<string>", line 2, in <module>
             File "/tmp/unpacker-GcT6oV-scratchdir/pip/__init__.py", line 11, in <module>
             File "/tmp/unpacker-GcT6oV-scratchdir/pip/vcs/mercurial.py", line 9, in <module>
             File "/tmp/unpacker-GcT6oV-scratchdir/pip/download.py", line 22, in <module>
             File "/tmp/unpacker-GcT6oV-scratchdir/pip/_vendor/requests/__init__.py", line 53, in <module>
             File "/tmp/unpacker-GcT6oV-scratchdir/pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py", line 62, in <module>
           AttributeError: 'module' object has no attribute 'PROTOCOL_SSLv3'
           ---- End output of   /usr/bin/python get-pip.py
            ----
           Ran   /usr/bin/python get-pip.py
            returned 1

           Resource Declaration:
       ---------------------
           # In /tmp/kitchen/cookbooks/python/recipes/pip.rb


            43:   cwd Chef::Config[:file_cache_path]
            44:   command <<-EOF
            45:   #{node['python']['binary']} get-pip.py
            46:   EOF
            47:   not_if { ::File.exists?(pip_binary) }
            48: end
            49: 

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cookbooks/python/recipes/pip.rb:42:in `from_file'

           execute("install-pip") do
             action "run"
         retries 0
             retry_delay 2
             default_guard_interpreter :execute
             command "  /usr/bin/python get-pip.py\n"
             backup 5
             cwd "/tmp/kitchen/cache"
             returns 0
         declared_type :execute
             cookbook_name :python
             recipe_name "pip"
             not_if { #code block }
           end

Alternative python install takes over easy_install

I used poise-python to add python3 to a machine that by default only has python 2:

python_runtime "3"

however after i did this the default easy_install on the path switched from being the python 2 version to the python 3 version. this breaks the easy_install_package, which was used by some other cookbooks and now suddenly started installing things for python3 instead of python2

Integration test broken

The integration tests have been broken for a while, it will be nice if we can fix it.
I am running the tests locally in an effort to fix the issues.
Any help will be appreciated!

Deprecated features used with Chef: 12.5.1

Using version "1.4.6", I've got:

Deprecated features used!
  version nil currently does not overwrite the value of version.
 This will change in Chef 13, and the value will be set to nil instead.
 Please change your code to explicitly accept nil using "property :version, [MyType, nil]", or stop setting this value to nil. at 3 locations:
    - /var/chef/cache/cookbooks/python/recipes/pip.rb:52:in `block in from_file'
    - /var/chef/cache/cookbooks/python/recipes/virtualenv.rb:25:in `block in from_file'
    - /var/chef/cache/cookbooks/python/providers/pip.rb:98:in `load_current_resource'

I saw the deprecated warning, so i'm not sure if it will be fixed :)

Thanks anyway!

Notifications Triggered Every Run

Posting this here to see if others are having the issue. I am guessing I am getting an edge case, since the behavior is too annoying to be prevalent yet unreported here.

Seeing an issue where notifications from a python_pip block are triggered every Chef run. The cause is twofold:

  1. The code checks the boolean value of status, which is a Mixlib::ShellOut object. I don't believe this correctly translates the value of Mixlib::Shellout.status when being evaluated as a boolean. Not 100% sure on this chain though.
  2. pip returns an exit code of 0 when it installs a package successfully. "Success" in this case can involve installing new files, or just confirming that everything is installed already. In the case where you only want to take action upon a changing of requirements we have to inspect the output from pip and check each line.

I don't think this is a big issue for most people since the checks around new_resource.version == current_resource.version bypass this most of the time. However, I seem to never have a current_resource populated during Chef runs, so I am hitting the edge case inside status.

undefined method `user' for Chef::Resource::Package

If i try execute this recipe (chef-client 11.14.6 --local-mode):

package 'python-package' do
  provider Chef::Provider::PythonPip
  version 'latest'
  action :install
end

i get error:

NoMethodError
-------------
undefined method `user' for Chef::Resource::Package

Allow idempotent upgrade [COOK-2843]

This is from COOK-2843.

Creating a recipe like:

python_pip 'diamond' do
  notifies :restart, 'service[diamond]'
  action :upgrade
end

Will always do the upgrade and trigger the notifies. Example output, using diamond:

Processing python_pip[diamond] action upgrade (docwhat-diamond::default line 29)
Upgrading python_pip[diamond] version from 4.0.435 to latest

Even though 4.0.435 is the latest version

The only workaround at the moment is to set a version number.

There was a pull request at one point for this: #38

AttributeError: 'module' object has no attribute 'PROTOCOL_SSLv3'

I'm currently getting this error when installing pip on Debian 7:

[2015-12-27T15:41:31-05:00] ERROR: execute[install-pip] (python::pip line 42) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of   /usr/bin/python get-pip.py
 ----
STDOUT: 
STDERR: Traceback (most recent call last):
  File "get-pip.py", line 21529, in <module>
    do_exec(entry, locals())
  File "<string>", line 1, in do_exec
  File "<string>", line 2, in <module>
  File "/tmp/unpacker-rbXmOj-scratchdir/pip/__init__.py", line 11, in <module>
  File "/tmp/unpacker-rbXmOj-scratchdir/pip/vcs/mercurial.py", line 9, in <module>
  File "/tmp/unpacker-rbXmOj-scratchdir/pip/download.py", line 22, in <module>
  File "/tmp/unpacker-rbXmOj-scratchdir/pip/_vendor/requests/__init__.py", line 53, in <module>
  File "/tmp/unpacker-rbXmOj-scratchdir/pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py", line 62, in <module>
AttributeError: 'module' object has no attribute 'PROTOCOL_SSLv3'
---- End output of   /usr/bin/python get-pip.py

python_pip action :purge doesn't work

The LWRP and documentation for python_pip says it supports :purge but there is no code to actually perform that action.

python_pip "ez_setup" do
  action :purge
end

The error:
NameError: Cannot find a resource for action_purge on ubuntu version 12.04

Upgrading setuptools leaves behind broken symlink

Recently started having this issue.
when running python::default on new node, chef will fail when trying to upgrade virtualenv.

here is the log:

[2015-03-06T11:47:56+00:00] ERROR: python_pip[virtualenv] (python::virtualenv line 23) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '2'
---- Begin output of pip install  --upgrade virtualenv ----
STDOUT: Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 232, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 339, in run
    requirement_set.prepare_files(finder)
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 229, in prepare_files
    req_to_install.check_if_exists()
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 931, in check_if_exists
    self.satisfied_by = pkg_resources.get_distribution(self.req)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 461, in get_distribution
    dist = get_provider(dist)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 341, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 870, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 740, in resolve
    env = Environment(self.entries)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 927, in __init__
    self.scan(search_path)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 957, in scan
    self.add(dist)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 973, in add
    if self.can_add(dist) and dist.has_version():
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2658, in has_version
    self.version
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2466, in version
    for line in self._get_metadata(self.PKG_INFO):
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2510, in _get_metadata
    for line in self.get_metadata_lines(name):
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 1927, in get_metadata_lines
    return yield_lines(self.get_metadata(name))
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 1921, in get_metadata
    with open(self.path,'rU') as f:
IOError: [Errno 2] No such file or directory: '/usr/lib/python2.7/dist-packages/setuptools.egg-info'
STDERR:
---- End output of pip install  --upgrade virtualenv ----

you can see the culprit at the end, /usr/lib/python2.7/dist-packages/setuptools.egg-info'
this file is a symink that points to a dead directory.
I have check and it is alive and present before chef run.

it looks like when chef does setuptools upgrade, it removes the realpath directory, but does not cleanup the symlink.

Deleting the symlink manually, allows the chef run to continue.

environment parameter is not working as expected

I'm trying to override ENV['PATH'] for a python_pip command, but it's not working as expected.

      ================================================================================
      Error executing action `install` on resource 'python_pip[whisper]'
      ================================================================================

      Errno::ENOENT
      -------------
      No such file or directory - pip

      Cookbook Trace:
      ---------------
      /var/chef/cache/cookbooks/python/providers/pip.rb:112:in `current_installed_version'
      /var/chef/cache/cookbooks/python/providers/pip.rb:100:in `load_current_resource'

      Resource Declaration:
      ---------------------
      # In /var/chef/cache/cookbooks/myorg-graphite/resources/carbon_cache.rb

       12:   python_pip new_resource.backend_name do
       13:     new_resource.backend_attributes.each { |attr, value| send(attr, value) }
       14:     Chef::Log.info "Installing storage backend: #{package_name}"
       15:     action :install
       16:     environment 'PATH' => "/opt/python-2.7/bin"
       17:   end
       18: end

      Compiled Resource:
      ------------------
      # Declared in /var/chef/cache/cookbooks/myorg-graphite/resources/carbon_cache.rb:12:in `block in class_from_file'

      python_pip("whisper") do
        action [:install]
        retries 0
        retry_delay 2
        default_guard_interpreter :default
        declared_type :python_pip
        cookbook_name "myorg-graphite"
        package_name "whisper"
        environment {"PATH"=>"/opt/python-2.7/bin"}
      end


    ================================================================================
    Error executing action `create` on resource 'myorg_graphite_carbon_cache[default]'
    ================================================================================

    Errno::ENOENT
    -------------
    python_pip[whisper] (/var/chef/cache/cookbooks/myorg-graphite/resources/carbon_cache.rb line 12) had an error: Errno::ENOENT: No such file or directory - pip

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/python/providers/pip.rb:112:in `current_installed_version'
    /var/chef/cache/cookbooks/python/providers/pip.rb:100:in `load_current_resource'

altinstall does NOT install alternate python correctly.

Hi,
I configured the cookbook to install into /usr with version 2.7.8 (centos 6.5):

The contents of the /usr/bin/py* BEFORE the cookbook ran:
-rwxr-xr-x. 1 root root 78 Jan 22 2014 /usr/bin/pydoc
-rwxr-xr-x. 2 root root 4864 Jan 22 2014 /usr/bin/python
lrwxrwxrwx. 1 root root 6 Sep 3 19:01 /usr/bin/python2 -> python
-rwxr-xr-x. 2 root root 4864 Jan 22 2014 /usr/bin/python2.6

The contents of the /usr/bin/py* AFTER the cookbook ran:
-rwxr-xr-x. 1 root root 78 Oct 26 18:42 /usr/bin/pydoc
lrwxrwxrwx. 1 root root 7 Oct 26 18:43 /usr/bin/python -> python2
lrwxrwxrwx. 1 root root 9 Oct 26 18:43 /usr/bin/python2 -> python2.7
-rwxr-xr-x. 1 root root 4864 Jan 22 2014 /usr/bin/python2.6
-rwxr-xr-x. 1 root root 6221527 Oct 26 18:42 /usr/bin/python2.7
-rwxr-xr-x. 1 root root 1668 Oct 26 18:43 /usr/bin/python2.7-config
lrwxrwxrwx. 1 root root 16 Oct 26 18:43 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx. 1 root root 14 Oct 26 18:43 /usr/bin/python-config -> python2-config

As you can see, it creates a symlink for /usr/bin/python which points to python2 for some reason.
python2 is a symlink to python2.7 so essentially i now have only 2.7 and no 2.6.6 (which is needed for yum on centos 6.5)

these are the attributes i configured for the environment.
"python": {
"version": "2.7.8",
"install_dir": "/usr",
"install_method": "source",
"setuptools_version": "1.4.2",
"prefix_dir": "/usr",
"make_options": [
"altinstall"
]
}

Thanks,
-D

python_pip says it supportge purge, but doesn't implement it

The pip resource exposes a :purge action, however the provider implementation doesn't actually implement it. When attempting to use purge, end up with an error:

NoMethodError: No resource or method named `action_purge' for `Chef::Provider::PythonPip ""'

pip fails to install

Just tried to run this on a clean 12.04 vm, and traced the error back to the behavior reported in #77, however in this case the error that's obscured appears different.

$ sudo python /srv/chef/file_store/cookbooks/python/files/default/get-pip.py
Downloading/unpacking pip
  Downloading pip-1.5.2-py2.py3-none-any.whl (1.2MB): 1.2MB downloaded
Downloading/unpacking setuptools
  Downloading setuptools-2.1.2.tar.gz (785kB): 785kB downloaded
Cleaning up...
setuptools must be installed to install from a source distribution
Storing debug log for failure in /home/vagrant/.pip/pip.log
$ echo $?
0

How to install both Python 2 and Python 3?

I'm using this cookbook to install Python 2.7.8 from source. Now I also need to install Python 3.4.2. How can I use this cookbook to install both versions in the same converge?

[COOK-3903] - python_pip resource will always try and update setuptools

The python_pip resource uses the pip freeze command to find the currently installed version of a python package (providers/pip.rb line 111). However, pip freeze does not include the pip and setuptools packages, and as a resource installing either package will always assume the package is not installed and reinstall it, even when the latest version of the package is installed. For instance, the supervisor cookbook will always upgrade setuptools (link).

get_pip script old, doesn't work behind proxy

The get-pip.py script has been updated a bunch since the current bootstrap script. I'm finding it doesn't correctly install behind a proxy when using http_proxy ENV variable. Using the latest get-pip everything works as expected. The current get-pip.py script is confused with the following:

get-pip.py run on Fri Jan 23 14:13:58 2015
Downloading/unpacking pip
  Getting page https://pypi.python.org/simple/pip/
  Could not fetch URL https://pypi.python.org/simple/pip/: connection error: hostname '<proxy server>' doesn't match either of 'www.python.org', 'python.org', 'pypi.python.org', 'docs.python.org', 'testpypi.python.org', 'bugs.python.org', 'wiki.python.org', 'hg.python.org', 'mail.python.org', 'packaging.python.org', 'pythonhosted.org', 'www.pythonhosted.org', 'test.pythonhosted.org', 'us.pycon.org', 'id.python.org'
  Will skip URL https://pypi.python.org/simple/pip/ when looking for download links for pip
  Getting page https://pypi.python.org/simple/
  Could not fetch URL https://pypi.python.org/simple/: connection error: hostname '<proxy server>' doesn't match either of 'www.python.org', 'python.org', 'pypi.python.org', 'docs.python.org', 'testpypi.python.org', 'bugs.python.org', 'wiki.python.org', 'hg.python.org', 'mail.python.org', 'packaging.python.org', 'pythonhosted.org', 'www.pythonhosted.org', 'test.pythonhosted.org', 'us.pycon.org', 'id.python.org'
  Will skip URL https://pypi.python.org/simple/ when looking for download links for pip
  Cannot fetch index base URL https://pypi.python.org/simple/
  URLs to search for versions for pip:
  * https://pypi.python.org/simple/pip/
  Getting page https://pypi.python.org/simple/pip/
  Could not fetch URL https://pypi.python.org/simple/pip/: connection error: hostname '<proxy server>' doesn't match either of 'www.python.org', 'python.org', 'pypi.python.org', 'docs.python.org', 'testpypi.python.org', 'bugs.python.org', 'wiki.python.org', 'hg.python.org', 'mail.python.org', 'packaging.python.org', 'pythonhosted.org', 'www.pythonhosted.org', 'test.pythonhosted.org', 'us.pycon.org', 'id.python.org'
  Will skip URL https://pypi.python.org/simple/pip/ when looking for download links for pip
  Could not find any downloads that satisfy the requirement pip
Cleaning up...
  Removing temporary dir /tmp/pip_build_root...
No distributions at all found for pip
Exception information:
Traceback (most recent call last):
  File "/tmp/unpacker-UNoDRZ-scratchdir/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/tmp/unpacker-UNoDRZ-scratchdir/pip/commands/install.py", line 274, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/tmp/unpacker-UNoDRZ-scratchdir/pip/req.py", line 1166, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "/tmp/unpacker-UNoDRZ-scratchdir/pip/index.py", line 277, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for pip

Gemfile won't resolve

Trying to add chefspec and a few tests, but getting this:

Joes-MacBook-Air:python jstump$ bundle install --without integration
Updating git://github.com/opscode/test-kitchen.git
Updating git://github.com/opscode/kitchen-vagrant.git
Updating git://github.com/opscode/kitchen-ec2.git
Updating https://github.com/portertech/kitchen-lxc.git
Fetching gem metadata from https://rubygems.org/.......
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "test-kitchen":
  In Gemfile:
    kitchen-ec2 (>= 0) ruby depends on
      test-kitchen (~> 1.0.0.beta.3) ruby

    kitchen-lxc (>= 0) ruby depends on
      test-kitchen (1.1.2.dev)

NoMethodError: undefined method `home' for Dir:Class with system Ruby v2.1.4

I'm getting a NoMethodError when trying to use this package to install a virtual machine in Vagrant. This seems closely related to #72, except that my system ruby is 2.1.4 (that PR seems to suggest it would only occur with versions of ruby older than 1.9.3):

$ ruby --version
ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-darwin12.0]
$ which ruby
/usr/local/bin/ruby

Or perhaps we're talking about the version of ruby on the vagrant VM? The exact error reads:

==> default: [2014-11-14T14:00:31+00:00] FATAL: NoMethodError: python_virtualenv[/home/chef/venv/nessus] (...) had an error: NoMethodError: undefined method `home' for Dir:Class

If I comment out the line:

  environment ({ 'HOME' => ::Dir.home(new_resource.owner) }) if new_resource.owner

from providers/virtualenv.rb, I don't run into the error.

bump version to 1.5.0

The cookbook version needs to be bumped to the next minor version (1.4.6 to 1.5.0).

The last commit (f6d0837) breaks the cookbook working on Ubuntu 12.04 (and a number of other distributions I suspect) as it has version of pip less than 1.3 which does not yet have pip list command.
(By breaking I mean the python_pip install resource runs always without respect for whether the package is installed or not which may produce undesired upgrades).

This would be ok if the minor-level version changed but not for the patch-level version:
it turns out I can't fork the cookbook and cherry-pick new fixes in it without creating version clash with you upstream.

Could you please bump the minor version for the cookbook?

QA tools

We use rubocop and foodcritic extensively. When I imported this cookbook into our tree, I received a couple notes about failures and violations.

I was wondering if I should work on ignoring these or if I should issue a PR which fixes the violations and includes these tools on future Travs-CI runs.

Pip install package attempts to use pip from within virtualenv

I have the following declarations

python_virtualenv node[:python][:venv_root] do
  owner user_name
  group user_name
  action :create
end

node[:python][:packages].each do |pip_package|
   python_pip pip_package do
    virtualenv node[:python][:venv_root]
   end
end

That results in the following compiled resource

python_pip("requests") do
  action :install
  retries 0
  retry_delay 2
  cookbook_name :"motesweb"
  recipe_name "default"
  virtualenv "/opt/motesweb/venv"
  package_name "requests"
  timeout 900

That results in the following exception

Errno::ENOENT
-------------
No such file or directory - /opt/motesweb/venv/bin/pip install  requests

I have no such pip binary installed.

This is breaking previously working recipes, so I don't believe I'm doing something incorrect.

Latest version of a pip doesn't work

I have a custom pip hosted on our own pip server.

Using this works fine when node['slice-deployer']['slice_fablib_version'] is a number.

python_pip "slice_fablib" do
  virtualenv node['slice-deployer'][:virtualenv_dir]
  options "-i #{node['slice-deployer']['pip_server_url']}"
  version "#{node['slice-deployer']['slice_fablib_version']}"
end

However, when node['slice-deployer']['slice_fablib_version'] = 'latest' it doesn't update the version on the host when a new version is available on the pip server. I also tried removing the version attribute. Same result. If a newer version is available, nothing happens. If I explicitly set node['slice-deployer']['slice_fablib_version'] to the latest version available on the pip server, then it works.

This is for v1.4.6.

Pip install error which doesn't happen manually (Python3)

Let me put you in context:

  • Ubuntu 14.04
  • Vagrant 1.6.3
  • VirtualBox 4.3.10
  • Chef Development Kit Version: 0.2.0

I am trying to set up a Vagrant machine with Ubuntu 14.04 too, with mysql, python3, django, and some dependencies, among which is django-countries. I have created a VagrantFile which provisions my Ubuntu with a recipe that installs all my packages and then runs the python recipe.

The problem comes when running the following resource on Chef:

python_pip "/vagrant/requirements.txt" do
    user "vagrant"
    virtualenv "/home/vagrant/devenv"
    options "-r"
end

Shows the following output:

==> default: [2014-08-08T12:11:42+00:00] ERROR: Running exception handlers
==> default: [2014-08-08T12:11:42+00:00] ERROR: Exception handlers complete
==> default: [2014-08-08T12:11:42+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2014-08-08T12:11:42+00:00] ERROR: python_pip[/vagrant/requirements.txt] (provision::sql-db line 80) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
==> default: ---- Begin output of /home/vagrant/devenv/bin/pip install -r /vagrant/requirements.txt ----
==> default: STDOUT: Downloading/unpacking django-countries==2.1.2 (from -r /vagrant/requirements.txt (line 20))
==> default:   Running setup.py (path:/home/vagrant/devenv/build/django-countries/setup.py) egg_info for package django-countries
==> default:     Traceback (most recent call last):
==> default:       File "<string>", line 17, in <module>
==> default:       File "/home/vagrant/devenv/build/django-countries/setup.py", line 23, in <module>
==> default:         long_description=long_description(),
==> default:       File "/home/vagrant/devenv/build/django-countries/setup.py", line 14, in long_description
==> default:         return readme.read()
==> default:       File "/home/vagrant/devenv/lib/python3.4/encodings/ascii.py", line 26, in decode
==> default:         return codecs.ascii_decode(input, self.errors)[0]
==> default:     UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1941: ordinal not in range(128)
==> default:     Complete output from command python setup.py egg_info:
==> default:     Traceback (most recent call last):
==> default: 
==> default:   File "<string>", line 17, in <module>
==> default: 
==> default:   File "/home/vagrant/devenv/build/django-countries/setup.py", line 23, in <module>
==> default: 
==> default:     long_description=long_description(),
==> default: 
==> default:   File "/home/vagrant/devenv/build/django-countries/setup.py", line 14, in long_description
==> default: 
==> default:     return readme.read()
==> default: 
==> default:   File "/home/vagrant/devenv/lib/python3.4/encodings/ascii.py", line 26, in decode
==> default: 
==> default:     return codecs.ascii_decode(input, self.errors)[0]
==> default: 
==> default: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1941: ordinal not in range(128)
==> default: 
==> default: ----------------------------------------
==> default: Cleaning up...
==> default: Command python setup.py egg_info failed with error code 1 in /home/vagrant/devenv/build/django-countries
==> default: Storing debug log for failure in /home/vagrant/.pip/pip.log
==> default: STDERR: 
==> default: ---- End output of /home/vagrant/devenv/bin/pip install -r /vagrant/requirements.txt ----
==> default: Ran /home/vagrant/devenv/bin/pip install -r /vagrant/requirements.txt returned 1
==> default: 
==> default: ================================================================================
==> default: Error executing action `install` on resource 'python_pip[/vagrant/requirements.txt]'
==> default: ================================================================================
==> default: 
==> default: 
==> default: Mixlib::ShellOut::ShellCommandFailed
==> default: ------------------------------------
==> default: Expected process to exit with [0], but received '1'
==> default: ---- Begin output of /home/vagrant/devenv/bin/pip install -r /vagrant/requirements.txt ----
==> default: STDOUT: Downloading/unpacking django-countries==2.1.2 (from -r /vagrant/requirements.txt (line 20))
==> default:   Running setup.py (path:/home/vagrant/devenv/build/django-countries/setup.py) egg_info for package django-countries
==> default:     Traceback (most recent call last):
==> default:       File "<string>", line 17, in <module>
==> default:       File "/home/vagrant/devenv/build/django-countries/setup.py", line 23, in <module>
==> default:         long_description=long_description(),
==> default:       File "/home/vagrant/devenv/build/django-countries/setup.py", line 14, in long_description
==> default:         return readme.read()
==> default:       File "/home/vagrant/devenv/lib/python3.4/encodings/ascii.py", line 26, in decode
==> default:         return codecs.ascii_decode(input, self.errors)[0]
==> default:     UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1941: ordinal not in range(128)
==> default:     Complete output from command python setup.py egg_info:
==> default:     Traceback (most recent call last):
==> default: 
==> default:   File "<string>", line 17, in <module>
==> default: 
==> default:   File "/home/vagrant/devenv/build/django-countries/setup.py", line 23, in <module>
==> default: 
==> default:     long_description=long_description(),
==> default: 
==> default:   File "/home/vagrant/devenv/build/django-countries/setup.py", line 14, in long_description
==> default: 
==> default:     return readme.read()
==> default: 
==> default:   File "/home/vagrant/devenv/lib/python3.4/encodings/ascii.py", line 26, in decode
==> default: 
==> default:     return codecs.ascii_decode(input, self.errors)[0]
==> default: 
==> default: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1941: ordinal not in range(128)
==> default: 
==> default: ----------------------------------------
==> default: Cleaning up...
==> default: Command python setup.py egg_info failed with error code 1 in /home/vagrant/devenv/build/django-countries
==> default: Storing debug log for failure in /home/vagrant/.pip/pip.log
==> default: STDERR: 
==> default: ---- End output of /home/vagrant/devenv/bin/pip install -r /vagrant/requirements.txt ----
==> default: Ran /home/vagrant/devenv/bin/pip install -r /vagrant/requirements.txt returned 1

However, if I run it after doing vagrant ssh, and running the same command: /home/vagrant/devenv/bin/pip install -r /vagrant/requirements.txt, the output is correct:

Downloading/unpacking django-countries==2.1.2
  Downloading django-countries-2.1.2.tar.gz (187kB): 187kB downloaded
  Running setup.py (path:/home/vagrant/devenv/build/django-countries/setup.py) egg_info for package django-countries

Installing collected packages: django-countries
  Running setup.py install for django-countries

Successfully installed django-countries

Any idea of why this double behavior may be happening?

Packages specified as URLs break version_check_cmd in python_pip Resource

Per https://github.com/poise/python/blob/master/providers/pip.rb#L111:

version_check_cmd = "#{which_pip(new_resource)} freeze | grep -i '^#{new_resource.package_name}=='"

Given a package_name of git+ssh://[email protected]/ampledata/kiss.git@master#egg=kiss:

url = 'git+ssh://[email protected]/ampledata/kiss.git@master#egg=kiss'
python_pip url do
  action :install
end

...version_check_cmd will always fail to match.

Here's the output from pip install and pip freeze on the command line:

$ pip install git+ssh://[email protected]/ampledata/kiss.git@master#egg=kiss 
$ pip freeze|grep kiss
kiss==1.0.1

I've not implemented a work-around yet, but one idea is groking the package name from the URL and using that to match pip freeze's output.

Tested using python Cookbook 1.4.6 and pip 1.5.2 w/ Python 2.7

Cookbook cannot find get-pip.py when installing on a VM

Hi,
I am a chef newbie so i don't know if i am installing this cookbook the right way but i get a

Error executing action `create` on resource 'cookbook_file[/var/chef/cache/get-pip.py]'

when i try to install this cookbook. I have checked by SSHing into the VM that the file get-pip.py is there.
I am using vagrant with virtualbox to manage my VM and berkshelf to manage my cookbook dependencies.

My Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "trusty64"
  config.vm.box_url = "file://trusty-server-cloudimg-amd64-vagrant-disk1.box"

  config.omnibus.chef_version = :latest

  config.vm.network "forwarded_port", guest: 80, host: 8001
  config.vm.network "private_network", ip: "192.168.33.10"

  config.vm.synced_folder ".", "/home/vagrant/project"

  config.vm.provider "virtualbox" do |vb|
     vb.memory = "1024"
  end

  config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" 

  config.vm.provision :chef_solo do |chef|
        chef.cookbooks_path = "~/.berkshelf/cookbooks"

        chef.add_recipe "apt"
        chef.add_recipe "build-essential"
        chef.add_recipe "git"
        chef.add_recipe "python"
   end
end

My Berksfile

source "https://supermarket.chef.io"

cookbook 'apt', '~> 2.6.1'
cookbook 'build-essential', '~> 2.1.3'
cookbook 'git', '~> 4.1.0'
cookbook 'python', '~> 1.4.6'

The traceback when chef tries to install this cookbook:

==> default: Running provisioner: chef_solo...
==> default: Detected Chef (latest) is already installed
   Generating chef JSON and uploading...
==> default: Running chef-solo...
==> default: [2015-03-05T07:09:46+00:00] INFO: Forking chef instance to converge...
==> default: [2015-03-05T07:09:46+00:00] INFO: *** Chef 12.1.0 ***
==> default: [2015-03-05T07:09:46+00:00] INFO: Chef-client pid: 2518
==> default: [2015-03-05T07:09:52+00:00] INFO: Setting the run_list to ["recipe[apt]", "recipe[build-essential]", "recipe[git]", "recipe[python]"] from CLI options
==> default: [2015-03-05T07:09:52+00:00] INFO: Run List is [recipe[apt], recipe[build-essential], recipe[git], recipe[python]]
==> default: [2015-03-05T07:09:52+00:00] INFO: Run List expands to [apt, build-essential, git, python]
==> default: [2015-03-05T07:09:52+00:00] INFO: Starting Chef Run for vagrant-ubuntu-trusty-64
==> default: [2015-03-05T07:09:52+00:00] INFO: Running start handlers
==> default: [2015-03-05T07:09:52+00:00] INFO: Start handlers complete.
==> default: [2015-03-05T07:10:16+00:00] INFO: execute[apt-get-update-periodic] ran successfully
==> default: [2015-03-05T07:10:16+00:00] INFO: directory[/var/cache/local] created directory /var/cache/local
==> default: [2015-03-05T07:10:16+00:00] INFO: directory[/var/cache/local] owner changed to 0
==> default: [2015-03-05T07:10:16+00:00] INFO: directory[/var/cache/local] group changed to 0
==> default: [2015-03-05T07:10:16+00:00] INFO: directory[/var/cache/local] mode changed to 755
==> default: [2015-03-05T07:10:16+00:00] INFO: directory[/var/cache/local/preseeding] created directory /var/cache/local/preseeding
==> default: [2015-03-05T07:10:16+00:00] INFO: directory[/var/cache/local/preseeding] owner changed to 0
==> default: [2015-03-05T07:10:16+00:00] INFO: directory[/var/cache/local/preseeding] group changed to 0
==> default: [2015-03-05T07:10:16+00:00] INFO: directory[/var/cache/local/preseeding] mode changed to 755
==> default: [2015-03-05T07:10:29+00:00] INFO: apt_package[autoconf] installed autoconf at 2.69-6
==> default: [2015-03-05T07:10:37+00:00] INFO: apt_package[binutils-doc] installed binutils-doc at 2.24-5ubuntu3.1
==> default: [2015-03-05T07:10:44+00:00] INFO: apt_package[bison] installed bison at 2:3.0.2.dfsg-2
==> default: [2015-03-05T07:11:02+00:00] INFO: apt_package[build-essential] installed build-essential at 11.6ubuntu6
==> default: [2015-03-05T07:11:21+00:00] INFO: apt_package[flex] installed flex at 2.5.35-10.1ubuntu2
==> default: [2015-03-05T07:11:39+00:00] INFO: apt_package[gettext] installed gettext at 0.18.3.1-1ubuntu3
==> default: [2015-03-05T07:11:39+00:00] INFO: apt_package[ncurses-dev] is a virtual package, actually acting on package[libncurses5-dev]
==> default: [2015-03-05T07:11:48+00:00] INFO: apt_package[ncurses-dev] installed ncurses-dev at (none)
==> default: [2015-03-05T07:12:00+00:00] INFO: apt_package[git] installed git at 1:1.9.1-1ubuntu0.1
==> default: [2015-03-05T07:12:19+00:00] INFO: apt_package[python-dev] installed python-dev at 2.7.5-5ubuntu3
==> default: 
==> default: ================================================================================
==> default: Error executing action `create` on resource 'cookbook_file[/var/chef/cache/get-pip.py]'
==> default: ================================================================================
==> default: 
==> default: 
==> default: RuntimeError
==> default: ------------
==> default: File files/default/get-pip.py does not exist for cookbook python
==> default: 
==> default: 
==> default: Resource Declaration:
==> default: ---------------------
==> default: # In /tmp/vagrant-chef/ac41a887bfa2c857cfe2917e95756f8c/cookbooks/python-1.4.6/recipes/pip.rb
==> default: 
==> default: 
==> default: 
==> default:  36: cookbook_file "#{Chef::Config[:file_cache_path]}/get-pip.py" do
==> default: 
==> default:  37:   source 'get-pip.py'
==> default: 
==> default:  38:   mode "0644"
==> default: 
==> default:  39:   not_if { ::File.exists?(pip_binary) }
==> default: 
==> default:  40: end
==> default: 
==> default:  41: 
==> default: 
==> default: Compiled Resource:
==> default: ------------------
==> default: # Declared in /tmp/vagrant-chef/ac41a887bfa2c857cfe2917e95756f8c/cookbooks/python-1.4.6/recipes/pip.rb:36:in `from_file'
==> default: 
==> default: cookbook_file("/var/chef/cache/get-pip.py") do
==> default:   provider Chef::Provider::CookbookFile
==> default:   action "create"
==> default:   retries 0
==> default:   retry_delay 2
==> default:   default_guard_interpreter :default
==> default:   path "/var/chef/cache/get-pip.py"
==> default:   backup 5
==> default:   atomic_update true
==> default:   source "get-pip.py"
==> default:   declared_type :cookbook_file
==> default:   cookbook_name :python
==> default:   recipe_name "pip"
==> default:   mode "0644"
==> default:   not_if { #code block }
==> default: end
==> default: 
==> default: [2015-03-05T07:12:19+00:00] INFO: Running queued delayed notifications before re-raising exception
==> default: [2015-03-05T07:12:19+00:00] ERROR: Converge failed with error message cookbook_file[/var/chef/cache/get-pip.py] (python::pip line 36) had an error: RuntimeError: File files/default/get-pip.py does not exist for cookbook python
==> default: [2015-03-05T07:12:19+00:00] ERROR: Running exception handlers
==> default: [2015-03-05T07:12:19+00:00] ERROR: Exception handlers complete
==> default: [2015-03-05T07:12:19+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2015-03-05T07:12:19+00:00] ERROR: Found 1 errors, they are stored in the backtrace
==> default: [2015-03-05T07:12:19+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

Cannot use get-pip.py without an internet connection

I need to configure servers on a network that does not have access to PyPi.

To install packages, I am fine with:
python_pip do
options "--no-index --find-links "
end

It works will and is happy to find dependencies from the cache. However, there is currently no way to pass options to get-pip.py, so I have to run it manually. It works from the command line as:
"python get-pip.py --no-index --find-links "

Can we have a way to pass options to get-pip.py?

get-pip.py masks errors

To reproduce, run:
sudo -u nobody python /var/chef/cache/get-pip.py
echo $?

Expected outcome: an error code is returned.
Actual outcome: success (0) is returned regardless of errors.

The indirect result of this behaviour is that the install-pip action always succeeds. However, if in fact there was an error, subsequent pip resources will fail with something like:

Error executing action install on resource 'python_pip[virtualenv]'
Errno::ENOENT
No such file or directory - pip install virtualenv

Bug: `python_pip` reinstalls packages that contain underscore in their names

The current check for installed packages uses pip freeze | grep -i '^#{new_resource.package_name}==', but pip freeze reports packages with underscore as hyphens: https://github.com/pypa/pip/blob/95035fc5c4cae354e17048c1a7727f4ad766662c/pip/util.py#L186

This issue is very serious to my current work, because I rely on pip_python's updated_by_last_action value to notify supervisor to restart, and my supervisor processes were restarting every time chef runs, even if the package was already installed. My cookbook looks like:

python_pip pkg_name do
  version pkg_version
  action :install
  virtualenv venv_home
  notifies :run, "execute[supervisor:update_and_restart]"
end

I am working on a fix and gonna send a pull request soon.

[COOK-4271] - Add ability to send environment vars to pip install to fix encoding issues

When using the python cookbook to pip install django-pipeline - chef fails with the following error: https://gist.github.com/petecheslock/e3606f1ba6577fc26383
In the setup.py there is the following: https://github.com/cyberdelia/django-pipeline/blob/master/setup.py#L11 I think somewhat related to this - but maybe not: https://tickets.opscode.com/browse/CHEF-3304 Basically I need a way to send "LC_ALL" => "en_US.UTF-8" (in my scenario) as an attribute to the python_pip resource so that it can deal with the encoding correctly.

incorrect error handling for 'pip list'

Hiho,

on redhat 6 I have a python 2.6 installed via rpm including the corresponding pip package python-pip.
I want to install the python package setuptools (3.4.0) and have currently installed setuptools (0.6c11)

root@chef-test1:~# pip show setuptools

Name: setuptools
Version: 0.6c11
Location: /usr/lib/python2.6/site-packages
Requires:
root@chef-test1:~#

the lwrp python_pip seems to successfully install setuptools (3.4.0), but it doesn't.
the method current_installed_version() stumbles over the output which ends with test below and does not realize the pip internal error.
I also worked with shellout and you could improve the code by using this code piece:
cmdStr = "test -f #{new_resource.file}"
Chef::Log.debug "calling: #{cmdStr}"
shell = Mixlib::ShellOut.new(cmdStr)
shell.run_command
shell.error! # raise an exception on error
Chef::Log.debug "stdout: #{shell.stdout.gsub(/\n$/,'')}"
Chef::Log.debug "stderr: #{shell.stderr.gsub(/\n$/,'')}"

output extract from 'pip list':
argparse (1.2.1)
...
setools (1.0)
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/pip/basecommand.py", line 134, in main
status = self.run(options, args)
File "/usr/lib/python2.6/site-packages/pip/commands/list.py", line 80, in run
self.run_listing(options)
File "/usr/lib/python2.6/site-packages/pip/commands/list.py", line 127, in run_listing
self.output_package_listing(installed_packages)
File "/usr/lib/python2.6/site-packages/pip/commands/list.py", line 136, in output_package_listing
if dist_is_editable(dist):
File "/usr/lib/python2.6/site-packages/pip/util.py", line 347, in dist_is_editable
req = FrozenRequirement.from_dist(dist, [])
File "/usr/lib/python2.6/site-packages/pip/init.py", line 194, in from_dist
assert len(specs) == 1 and specs[0][0] == '=='
AssertionError

Storing complete log in /root/.pip/pip.log

Let me know if you need more information.

Best Regards,
Uwe

Allow more python_pip options, like --proxy

I can't make any use of python_pip, and therefore cannot make any use of any cookbook that makes use of python_pip (!!!), because it doesn't support the pip --proxy option. :(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.