• Xavier Thompson's avatar
    [fix] Fix working set sorting · f8a65f4f
    Xavier Thompson authored
    If a dist in the computed working set is at a location shared with
    other dists - such as site-packages - then when generating scripts
    these other packages may overshadow the next items on the sys.path
    and result in importing a different version than the one installed
    and intended by buildout.
    
    To avert this, a sort of the working set was introduced at various
    points just before generating a script.
    
    However, that sort put the paths referenced from an `.egg-link` in
    ./develop-eggs first. This is truly problematic because dists from
    site-packages which are not eggs - e.g. dists installed with pip -
    can become referenced as `.egg-link` during buildout bootstrap and
    the sort then causes site-packages to be one of the first items in
    sys.path.
    
    In particular when running buildout bootstrap from a venv in which
    zc.buildout was installed by pip, if any one of zc.buildout or its
    dependencies from the venv meets the version requirements, then it
    can cause the generated bin/buildout to import the dists only from
    the venv's site-packages, even when some do not meet requirements.
    
    To fix this, the sort now puts the dists from `./eggs` first as we
    know their locations contain only a single dist, and then puts the
    dists from ./develop-eggs which have locations inside the buildout
    directory before the others.
    
    The previous sort was also activating all the dists from the paths
    of the already activated dists.
    
    Note that this also means that any working set must be manipulated
    with care in general to avoid activating unintended dists from the
    locations of the already activated dists.
    f8a65f4f
easy_install.py 72.6 KB