eggs/zc.buildout-1.5.2-py2.6.egg/zc/buildout/upgrading_distribute.txt
changeset 69 c6bca38c1cbf
equal deleted inserted replaced
68:5ff1fc726848 69:c6bca38c1cbf
       
     1 Installing setuptools/distribute
       
     2 --------------------------------
       
     3 
       
     4 Some initial test setup:
       
     5 
       
     6     >>> import sys
       
     7     >>> import zc.buildout
       
     8     >>> dest = tmpdir('sample-install')
       
     9 
       
    10 Setuptools (0.6something) is packaged as an ``.egg``.  So when installing it,
       
    11 the egg is downloaded and used.  Distribute is packaged as a tarball, which
       
    12 makes an easy_install call necessary.  In older versions of buildout, the
       
    13 ``_call_easy_install()`` method would call ``_get_dist()`` to get hold of the
       
    14 setuptools path for calling easy_install.  When an updated "distribute" was
       
    15 found, this would try an install again, leading to an infinite recursion.
       
    16 
       
    17 The solution is to just use the setuptools location found at import time, like
       
    18 happens with the buildout and setuptools location that is inserted in scripts'
       
    19 paths.
       
    20 
       
    21 We test this corner case by patching the ``_get_dist()`` call:
       
    22 
       
    23     >>> def mock_get_dist(requirement, ws, always_unzip):
       
    24     ...     raise RuntimeError("We should not get called")
       
    25 
       
    26 When installing setuptools itself, we expect the "Getting dist" message not to
       
    27 be printed.  We call ``_call_easy_install()`` directly and get an error
       
    28 because of a non-existing tarball, but that's the OK for this corner case
       
    29 test: we only want to test that ``_get_dist()`` isn't getting called:
       
    30 
       
    31     >>> class MockDist(object):
       
    32     ...     def __str__(self):
       
    33     ...         return 'nonexisting.tgz'
       
    34     ...     @property
       
    35     ...     def project_name(self):
       
    36     ...         # Testing corner case: there *is* actually
       
    37     ...         # a newer setuptools package on pypi than we
       
    38     ...         # are running with, so it really installs it
       
    39     ...         # and compares project_name. We're past the
       
    40     ...         # point that we're testing, so we just raise
       
    41     ...         # the normally expected error.
       
    42     ...         raise zc.buildout.UserError(
       
    43     ...             "Couldn't install: nonexisting.tgz")
       
    44     >>> dist = MockDist()
       
    45 
       
    46     >>> installer = zc.buildout.easy_install.Installer(
       
    47     ...     dest=dest,
       
    48     ...     links=[link_server],
       
    49     ...     index=link_server+'index/',
       
    50     ...     executable=sys.executable,
       
    51     ...     always_unzip=True)
       
    52     >>> installer._get_dist = mock_get_dist
       
    53     >>> installer._call_easy_install('setuptools', None, dest, dist)
       
    54     Traceback (most recent call last):
       
    55     ...
       
    56     UserError: Couldn't install: nonexisting.tgz