Skip to content
This repository was archived by the owner on Oct 2, 2018. It is now read-only.
This repository was archived by the owner on Oct 2, 2018. It is now read-only.

cookbook says it updates setuptools, but it doesn't #100

Closed

Description

@joshk0

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

Activity

  1. coderanger commented on May 7, 2014

    @coderanger
    Member

    Hmm, so the relevant code seems correct:

    python_pip 'setuptools' do
      action :upgrade
      version node['python']['setuptools_version']
    end

    Can you run with debug to see what command Processing python_pip[setuptools] action upgrade (python::pip line 50) is running?

  2. joshk0 commented on May 7, 2014

    @joshk0
    Author

    So, I've manually worked around all the affected machines for now. But I am pretty sure it is running pip install --upgrade setuptools. I can tell you for sure when I dig up another machine on which this error occurs.

    I wonder if pip install --upgrade setuptools could fail without exiting nonzero? I could definitely see it bombing on retrieving setuptools from pypi, and exiting silently while leaving setuptools at the old version.

  3. cummingscs commented on May 8, 2014

    @cummingscs

    run the command manually and then check echo $? to see if that's what is happening

  4. joshk0 commented on May 8, 2014

    @joshk0
    Author

    The weird thing is that so far, it's always worked when run manually, so no help there.

  5. coderanger commented on May 8, 2014

    @coderanger
    Member

    I am loathe to blame things on transient failures, but without more info it is certainly tempting :-(

  6. cummingscs commented on May 8, 2014

    @cummingscs

    @joshk0 Have you recorded exit codes for any of your cases?

  7. jonathanq commented on Jun 3, 2014

    @jonathanq

    I am seeing this same issue on a fresh Amazon Linux 2014.03 AMI.

    The cookbook run is reporting that it is upgrading setuptools. And I believe the underlying issue is that on some machines, there will be multiple copies of setuptools installed and it needs to upgrade both.

    [2014-06-03T15:47:03+00:00] INFO: Processing execute[install-pip] action run (python::pip line 42)
    [2014-06-03T15:47:07+00:00] INFO: execute[install-pip] ran successfully
    [2014-06-03T15:47:07+00:00] INFO: Processing python_pip[setuptools] action upgrade (python::pip line 50)
    [2014-06-03T15:47:08+00:00] INFO: Upgrading python_pip[setuptools] version from uninstalled to latest
    [2014-06-03T15:47:12+00:00] INFO: Processing python_pip[virtualenv] action install (python::virtualenv line 23)
    [2014-06-03T15:47:13+00:00] INFO: Installing python_pip[virtualenv] version latest
    [2014-06-03T15:47:14+00:00] INFO: Processing python_pip[supervisor] action upgrade (supervisor::default line 34)
    [2014-06-03T15:47:15+00:00] INFO: Upgrading python_pip[supervisor] version from uninstalled to 3.0
    ...
    <followed by a similar error installing this package due to "error: invalid command 'egg_info'">
    

    I did see this note on SO (http://stackoverflow.com/a/18081193) where others have reported needing to run this command twice to upgrade setuptools.

    That could explain why running this command again on a host "fixes" it. This is not a transient error as it happens on every first run, but a second run will fix the problem as the command is run again.

    Just to prove that - I added a second block to the pip.rb recipe and I was able to get a successful run on the first time:

    python_pip 'setuptools-2' do
      package_name 'setuptools'
      action :upgrade
      version node['python']['setuptools_version']
    end
    

    The resulting log output:

    [2014-06-03T17:04:50+00:00] INFO: Processing execute[install-pip] action run (python::pip line 42)
    [2014-06-03T17:04:57+00:00] INFO: execute[install-pip] ran successfully
    [2014-06-03T17:04:57+00:00] INFO: Processing python_pip[setuptools] action upgrade (python::pip line 50)
    [2014-06-03T17:04:58+00:00] INFO: Upgrading python_pip[setuptools] version from uninstalled to latest
    [2014-06-03T17:05:03+00:00] INFO: Processing python_pip[setuptools-2] action upgrade (python::pip line 55)
    [2014-06-03T17:05:04+00:00] INFO: Upgrading python_pip[setuptools-2] version from uninstalled to latest
    [2014-06-03T17:05:09+00:00] INFO: Processing python_pip[virtualenv] action install (python::virtualenv line 23)
    [2014-06-03T17:05:10+00:00] INFO: Installing python_pip[virtualenv] version latest
    [2014-06-03T17:05:11+00:00] INFO: Processing python_pip[supervisor] action upgrade (supervisor::default line 34)
    [2014-06-03T17:05:12+00:00] INFO: Upgrading python_pip[supervisor] version from uninstalled to 3.0
    

    I don't know the best way to handle this case. It may actually be an issue with the underlying packages provided on the OS.

  8. nikhilshah28 commented on Aug 12, 2014

    @nikhilshah28

    I've got some errors trying to build python by source and specifying a specific version; however, when building by package it works (just older version).

    default_attributes(

    'python' => {

    'version' => '3.4.1',
    
    'install_method' => 'source'
    

    }

    )

    ec2.compute-1.amazonaws.com * remote_file[/var/chef/cache/Python-3.4.1.tgz] action create

    ec2.compute-1.amazonaws.com - create new file /var/chef/cache/Python-3.4.1.tgz

    ec2.compute-1.amazonaws.com - update content in file /var/chef/cache/Python-3.4.1.tgz from none to 8d007e

    ec2.compute-1.amazonaws.com (file sizes exceed 10000000 bytes, diff output suppressed)

    ec2.compute-1.amazonaws.com - change mode from '' to '0644'

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com * link[/usr/local/bin/python] action create

    ec2.compute-1.amazonaws.com - create symlink at /usr/local/bin/python to /usr/local/bin/python3.4

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com Recipe: python::pip

    ec2.compute-1.amazonaws.com * cookbook_file[/var/chef/cache/get-pip.py] action create

    ec2.compute-1.amazonaws.com - create new file /var/chef/cache/get-pip.py

    ec2.compute-1.amazonaws.com - update content in file /var/chef/cache/get-pip.py from none to 415b4d

    ec2.compute-1.amazonaws.com (long diff of over 1000000 characters, diff output suppressed)

    ec2.compute-1.amazonaws.com - change mode from '' to '0644'

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com * execute[install-pip] action run

    ec2.compute-1.amazonaws.com - execute /usr/local/bin/python get-pip.py

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com * python_pip[setuptools] action upgrade

    ec2.compute-1.amazonaws.com ================================================================================

    ec2.compute-1.amazonaws.com Error executing action upgrade on resource 'python_pip[setuptools]'

    ec2.compute-1.amazonaws.com ================================================================================

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com Errno::ENOENT

    ec2.compute-1.amazonaws.com -------------

    ec2.compute-1.amazonaws.com No such file or directory - pip list

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com Cookbook Trace:

    ec2.compute-1.amazonaws.com ---------------

    ec2.compute-1.amazonaws.com /var/chef/cache/cookbooks/python/providers/pip.rb:112:in `current_installed_version'

    ec2.compute-1.amazonaws.com /var/chef/cache/cookbooks/python/providers/pip.rb:100:in `load_current_resource'

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com Resource Declaration:

    ec2.compute-1.amazonaws.com ---------------------

    ec2.compute-1.amazonaws.com # In /var/chef/cache/cookbooks/python/recipes/pip.rb

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com 50: python_pip 'setuptools' do

    ec2.compute-1.amazonaws.com 51: action :upgrade

    ec2.compute-1.amazonaws.com 52: version node['python']['setuptools_version']

    ec2.compute-1.amazonaws.com 53: end

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com Compiled Resource:

    ec2.compute-1.amazonaws.com ------------------

    ec2.compute-1.amazonaws.com # Declared in /var/chef/cache/cookbooks/python/recipes/pip.rb:50:in `from_file'

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com python_pip("setuptools") do

    ec2.compute-1.amazonaws.com action [:upgrade]

    ec2.compute-1.amazonaws.com retries 0

    ec2.compute-1.amazonaws.com retry_delay 2

    ec2.compute-1.amazonaws.com guard_interpreter :default

    ec2.compute-1.amazonaws.com cookbook_name "python"

    ec2.compute-1.amazonaws.com recipe_name "pip"

    ec2.compute-1.amazonaws.com version "3.4.1"

    ec2.compute-1.amazonaws.com package_name "setuptools"

    ec2.compute-1.amazonaws.com end

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com Running handlers:

    ec2.compute-1.amazonaws.com [2014-08-11T19:59:19+00:00] ERROR: Running exception handlers

    ec2.compute-1.amazonaws.com Running handlers complete

    ec2.compute-1.amazonaws.com

    ec2.compute-1.amazonaws.com [2014-08-11T19:59:19+00:00] ERROR: Exception handlers complete

    ec2.compute-1.amazonaws.com [2014-08-11T19:59:19+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out

    ec2.compute-1.amazonaws.com Chef Client failed. 18 resources updated in 393.998412496 seconds

    ec2.compute-1.amazonaws.com [2014-08-11T19:59:19+00:00] ERROR: python_pip[setuptools](python::pip line 50) had an error: Errno::ENOENT: No such file or directory - pip list

    ec2.compute-1.amazonaws.com [2014-08-11T19:59:19+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

  9. michaelmarziani commented on Aug 13, 2014

    @michaelmarziani

    @jonathanq, I can confirm that I have to run the exact same pip update command for setuptools twice in a row and that works. I'm on a new CentOS 6.5 server. I did some digging and copious 'pip list' at every part of my server build and found out what's happening.

    On a new build I have only the basics. I install python-pip using yum and that brings python-setuptools with it. It's a pretty old version and hence it's actually installing distribute (0.6.10). After installing a package manager my first instinct is to update it so it can be as smart as possible, so I run 'pip install -U pip'. That brings my pip up to version 1.5.6.

    Now I ask pip to update my setuptools and this version of pip is smart enough to know it wants to remove the old version of distribute first. It does this, but then instead of installing the latest version of setuptools it installs setuptools (0.6c11). That version is oddly close to the same version of distribute that we just removed, but no time to ponder a possible connection.

    If I now run the exact same command again 'pip install -U setuptools', the old version of setuptools is removed, and version 5.5.1 is installed. I don't know why pip doesn't take us straight to the new setuptools in one shot, but this is what's happening and hopefully it will help others to see this.

  10. martinb3 commented on Aug 21, 2014

    @martinb3

    As mentioned by @michaelmarziani, this is also broken on CentOS 6.5, and the fix in #111 doesn't help those using CentOS 6.5. It's ugly but we may need to run these commands anyway:

    pip install -U pip
    pip install -U setuptools
    pip install -U setuptools
    
  11. joshk0 commented on Nov 18, 2014

    @joshk0
    Author

    I think upgrading pip is the much cleaner way to go. Anything blocking this from going in?

  12. martinb3 commented on Nov 18, 2014

    @martinb3

    @joshk0 As mentioned by the two commenters above you, we both had systems where upgrading pip didn't work either, without still running the setuptools step twice afterwards.

  13. joshk0 commented on Nov 18, 2014

    @joshk0
    Author

    OK, pieced it all together now. So rather than put in a workaround, we're putting all our hopes and dreams in pypa/pip#1992 being fixed? :)

  14. martinb3 commented on Nov 23, 2014

    @martinb3

    @joshk0 No, we're just telling you that the workaround you are proposing doesn't work. This is 3 months old by the way. Most folks have implemented their own workarounds long ago.

  15. joshk0 commented on Nov 23, 2014

    @joshk0
    Author

    OK. Is there some documentation about the workarounds that people have in place and are generally agreed upon, then?

  16. michaelmarziani commented on Nov 24, 2014

    @michaelmarziani

    It may be worth pointing out that this should rapidly become a moot point
    as operating systems are released with less ancient versions of Python and
    pip. For instance, I just put CentOS 7 through its paces and unlike CentOS
    6, only one run of:
    pip install -U pip
    pip install -U setuptools

    was needed to get the latest and greatest. When first installing pip
    through yum (EPEL) as before, it now comes with setuptools version 0.9.8,
    and distribute is nowhere to be seen. One run of the update command and I'm
    at setuptools 7.0.

    On Sunday, November 23, 2014, Joshua Kwan notifications@github.com wrote:

    OK. Is there some documentation about the workarounds that people have in
    place and are generally agreed upon, then?

    —
    Reply to this email directly or view it on GitHub
    #100 (comment).

  17. krallin commented on Dec 3, 2014

    @krallin

    Just wanted to pitch in that I was having the same issue here, and my workaround has been (and continues to be) to install setuptools twice.

  18. tipu commented on Dec 17, 2014

    @tipu

    i was having the same problem of python_pip installing a "bad" setuptools. my solution was to grab the ez_setup.py from the setuptools site and manually run that instead of the action :upgrade command that was ruining things.

  19. coderanger commented on Jul 17, 2015

    @coderanger
    Member

    Closing this out as get-pip.py no longer touches setuptools on the system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ Proxy