Commit 35f26d0e authored by Kirill Kuzminykh's avatar Kirill Kuzminykh

Added sorting of working set used by zc.recipe.egg

parent a77a7577
...@@ -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