Toshio Kuratomi wrote: > > This code creates an unordered list because you might have already had > to place something after one of the duplicate locations that this code > is removing. We need to do a sort of the entire list after each add + > duplicate removal run.
Here's a quick and dirty patch. It's correct but it's inefficient. A better sort algorithm would help some. Refactoring code so we call a sort method after we finish adding entries to the path would be even better. I'll test how this affects packaging tonight. -Toshio
diff -up setuptools-0.6c6/pkg_resources.py.bak setuptools-0.6c6/pkg_resources.py --- setuptools-0.6c6/pkg_resources.py.bak 2007-09-01 14:48:48.000000000 -0700 +++ setuptools-0.6c6/pkg_resources.py 2007-09-01 14:44:53.000000000 -0700 @@ -2214,31 +2214,20 @@ class Distribution(object): def insert_on(self, path, loc = None): """Insert self.location in path before its nearest parent directory""" - loc = loc or self.location if not loc: return + #print 'DEBUG:',loc if path is sys.path: self.check_version_conflict() + path.insert(0, loc) nloc = _normalize_cached(loc) - bdir = os.path.dirname(nloc) npath= map(_normalize_cached, path) - bp = None - for p, item in enumerate(npath): - if item==nloc: - break - elif item==bdir: - path.insert(p, loc) - npath.insert(p, nloc) - break - else: - path.append(loc) - return - # p is the spot where we found or inserted loc; now remove duplicates + p = 0 while 1: try: np = npath.index(nloc, p+1) @@ -2247,7 +2236,21 @@ class Distribution(object): else: del npath[np], path[np] p = np # ha! - + + # Sort the paths + newPath = [] + newNPath = [] + for basePathNum, basePath in enumerate(npath): + bdir = os.path.dirname(basePath) + for p, item in enumerate(newNPath): + if item==bdir: + newPath.insert(p, path[basePathNum]) + newNPath.insert(p, basePath) + break + else: + newNPath.append(basePath) + newPath.append(path[basePathNum]) + path = newPath return
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig