poise / python

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

someara opened this issue · comments

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

silviu dicu added a comment - 07/Nov/13 9:16 AM
Hi - this is hardcoded into the pip source code - https://github.com/pypa/pip/blob/develop/pip/util.py#L350
Two solutions
have pip change the logic
have a different strategy into the python_pip provider

I gave improving this a shot, but I'm not sure how to:

  1. support virtualenv
  2. prevent unnecessary upgrades

Commit is here for anyone interested: https://github.com/mal/chef-python/commit/f8651c70c2507e4f082265575d3b982c34d6ace5

Other approaches include using easy_install --version which will report versions for setuptools and/or distribute.

The code already has a special case for pip[1] - a very simple (if not particularly elegant) solution might be to also special case setuptools, using something like:

version_check_cmd = "#{default['python']['binary']} -c \"import setuptools, sys; sys.stdout.write('setuptools==' + str(setuptools.__version__))\""

I found a more generic solution using pip list, should do the job nicely 😀

Bump.