1. 17 Apr, 2024 3 commits
    • Xavier Thompson's avatar
      [feat] Add more testing normalizers · 86a7d1d8
      Xavier Thompson authored
      86a7d1d8
    • Xavier Thompson's avatar
      [feat] Enable isolation from preexisting packages · a3ff0510
      Xavier Thompson authored
      Add option `isolate-from-buildout-and-setuptools-path` to prevent
      buildout from scanning the directories where zc.buildout's or its
      dependencies's currently running packages are located.
      
      In apparently intended design, `buildout bootstrap` should already
      provide isolation by either installing pinned versions of zc.buildout
      and dependencies in local ./eggs directory, or copying them from the
      currently running egg into ./eggs if the running versions match.
      
      However, when the currently running versions are not eggs - which is
      the case when they are installed by pip in site-packages, e.g. as is
      the case in a virtual environment - then buildout merely creates
      `.egg-link` references to the locations of the running packages, which
      is often site-packages.
      
      The presence of .egg-link referencing site-packages can cause packages
      available in site-packages to interfere when considering which eggs to
      install and what path items to insert in sys.path when creating
      scripts.
      
      This is in some way a workaround for the fact that buildout only knows
      how to handle eggs and not .dist-info packages such as produced by pip.
      
      With `isolate-from-buildout-and-setuptools-path`, buildout bootstrap
      will allways install a fresh version of zc.buildout & co in ./eggs
      a3ff0510
    • Xavier Thompson's avatar
      [fix] Fix bootstrap working set order · 73b0c0d5
      Xavier Thompson authored
      In bootstrap we potentially copy eggs from the working set to ./eggs.
      We then reconstruct the same working set using the moved locations.
      
      This commits ensures we keep a correct working set order throughout
      and that we avoid activating unintended dists.
      73b0c0d5
  2. 11 Apr, 2024 3 commits
    • Xavier Thompson's avatar
      [fix] Use only ws.find in install · 29368600
      Xavier Thompson authored
      Replace `pkg_resources.Environment(ws.entries).best_match(req, ws)`
      with `ws.find(req)`.
      
      The first already starts by calling `ws.find(req)` to attempt to find
      an already activated dist in the working set, but if none is found it
      then proceeds to scan through the entries of the environment - i.e.
      the entries of the working set, `ws.entries` - to activate a dist at
      these locations if one matches.
      
      This is problematic if a dist from site-packages is in the working set
      at this stage: this will consider site-packages over eggs installed in
      .eggs, seemingly randomly depending on what dists are requested and
      whether they are found in site-packages.
      
      Also when calling `install(['zc.buildout'])` to resolve the dists of
      buildout and its dependencies currently running there are no version
      pins yet, so if `zc.buildout` comes from site-packages and specific
      versions of its dependencies come from `.eggs` but other versions
      exist in site-packages, then the dists from site-packages would be
      found instead of the actually running dists from `.eggs`.
      29368600
    • Xavier Thompson's avatar
      [fix] Fix working set sorting · 7ec97f44
      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.
      7ec97f44
    • Xavier Thompson's avatar
      [feat] Add scan_any_python_version option in install · 03d1e80e
      Xavier Thompson authored
      This is passed when calling `install(['zc.buildout'])` to resolve the
      dists of the currently running buildout and its dependencies, as they
      may not actually correspond the version of the running interpreter.
      
      This is needed to support new slapos.rebootstrap: after compiling the
      new Python interpreter, we use it to run buildout bootstrap using the
      same paths to zc.buildout and dependencies as in the initial Python.
      This installs the needed dists for the new Python version and creates
      a new bin/buildout for the new Python interpreter.
      03d1e80e
  3. 02 Apr, 2024 34 commits