Commit af496836 authored by Reinout van Rees's avatar Reinout van Rees Committed by GitHub

Merge pull request #432 from Cykooz/master

Added sorting of working set used by zc.recipe.egg
parents a77a7577 1b4dee29
...@@ -4,7 +4,8 @@ Change History ...@@ -4,7 +4,8 @@ Change History
2.0.5 (unreleased) 2.0.5 (unreleased)
================== ==================
- Nothing changed yet. - Fix #429: added sorting of working set by priority of different
type of paths (develop-eggs-directory, eggs-directory, other paths).
2.0.4 (2017-08-17) 2.0.4 (2017-08-17)
......
...@@ -15,8 +15,10 @@ ...@@ -15,8 +15,10 @@
""" """
import copy import copy
import glob
import logging import logging
import os import os
import pkg_resources
import re import re
import sys import sys
import zc.buildout.easy_install import zc.buildout.easy_install
...@@ -90,6 +92,31 @@ class Eggs(object): ...@@ -90,6 +92,31 @@ class Eggs(object):
update = install update = install
def _sort_working_set(self, ws):
develop_paths = set()
pattern = os.path.join(self.options['develop-eggs-directory'], '*.egg-link')
for egg_link in glob.glob(pattern):
with open(egg_link, 'rt') as f:
path = f.readline().strip()
if path:
develop_paths.add(path)
egg_directory = os.path.join(self.options['eggs-directory'], '')
sorted_paths = []
egg_paths = []
other_paths = []
for dist in ws:
path = dist.location
if path in develop_paths:
sorted_paths.append(path)
elif os.path.commonprefix([path, egg_directory]) == egg_directory:
egg_paths.append(path)
else:
other_paths.append(path)
sorted_paths.extend(egg_paths)
sorted_paths.extend(other_paths)
return pkg_resources.WorkingSet(sorted_paths)
def _working_set( def _working_set(
self, self,
distributions, distributions,
...@@ -133,6 +160,7 @@ class Eggs(object): ...@@ -133,6 +160,7 @@ class Eggs(object):
path=[develop_eggs_dir], path=[develop_eggs_dir],
newest=newest, newest=newest,
allow_hosts=allow_hosts) allow_hosts=allow_hosts)
ws = self._sort_working_set(ws)
cache_storage[cache_key] = ws cache_storage[cache_key] = ws
# `pkg_resources.WorkingSet` instances are mutable, so we need to return # `pkg_resources.WorkingSet` instances are mutable, so we need to return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment