Skip to content

Commit

Permalink
Problem: site-packages in sys.path before eggs
Browse files Browse the repository at this point in the history
Solution: sort packages to push site-packages at the end
  • Loading branch information
gotcha committed May 17, 2020
1 parent 188827f commit 16ea8e6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Change History
3.0.0 (unreleased)
==================

- Scripts: ensure eggs are inserted before ``site-packages`` in ``sys.path``.

- Fix forever loop when changing ``zc.buildout`` version via ``buildout``.

- Add support for ``Requires-Python`` metadata.
Expand Down
7 changes: 6 additions & 1 deletion src/zc/buildout/easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,12 @@ def scripts(reqs, working_set, executable, dest=None,
):
assert executable == sys.executable, (executable, sys.executable)

path = [dist.location for dist in working_set]
# ensure eggs are inserted before ``site-packages`` in ``sys.path``.
# TODO ensure develop-eggs are also inserted before ``site-packages``.
dists = [dist for dist in working_set]
dists.sort(key=lambda dist: (-dist.precedence, dist.project_name))

path = [dist.location for dist in dists]
path.extend(extra_paths)
# order preserving unique
unique_path = []
Expand Down
4 changes: 2 additions & 2 deletions src/zc/buildout/easy_install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,8 @@ to pass a common base directory of the scripts and eggs:
<BLANKLINE>
import sys
sys.path[0:0] = [
join(base, 'eggs/demoneeded-1.1-pyN.N.egg'),
join(base, 'eggs/demo-0.3-pyN.N.egg'),
join(base, 'eggs/demoneeded-1.1-pyN.N.egg'),
'/ba',
join(base, 'bar'),
base,
Expand Down Expand Up @@ -954,8 +954,8 @@ We specified an interpreter and its paths are adjusted too:
import sys
<BLANKLINE>
sys.path[0:0] = [
join(base, 'eggs/demoneeded-1.1-pyN.N.egg'),
join(base, 'eggs/demo-0.3-pyN.N.egg'),
join(base, 'eggs/demoneeded-1.1-pyN.N.egg'),
'/ba',
join(base, 'bar'),
base,
Expand Down

0 comments on commit 16ea8e6

Please sign in to comment.