summaryrefslogtreecommitdiff
path: root/pkg_resources.py
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2006-06-07 18:31:05 +0000
committerPJ Eby <distutils-sig@python.org>2006-06-07 18:31:05 +0000
commit9561b7000eaa52d798cd82742839219a07744535 (patch)
tree7df2407f74320267c16539d115cb79ad1f3399d1 /pkg_resources.py
parent1c90af0417ad5e8cd41ea7313607cb373967ff2e (diff)
downloadpython-setuptools-git-9561b7000eaa52d798cd82742839219a07744535.tar.gz
Fixed a duplicate path insertion problem on case-insensitive
filesystems. (Merge from 0.7 trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4046712
Diffstat (limited to 'pkg_resources.py')
-rw-r--r--pkg_resources.py63
1 files changed, 52 insertions, 11 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index 2acd43bb..5cb4e2ce 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -2112,22 +2112,63 @@ class Distribution(object):
"""Return the EntryPoint object for `group`+`name`, or ``None``"""
return self.get_entry_map(group).get(name)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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
+ if not loc:
+ return
+
if path is sys.path:
self.check_version_conflict()
- best, pos = 0, -1
- for p,item in enumerate(path):
- item = _normalize_cached(item)
- if loc.startswith(item) and len(item)>best and loc<>item:
- best, pos = len(item), p
- if pos==-1:
- if loc not in path: path.append(loc)
- elif loc not in path[:pos+1]:
- while loc in path: path.remove(loc)
- path.insert(pos,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
+ while 1:
+ try:
+ np = npath.index(nloc, p+1)
+ except ValueError:
+ break
+ else:
+ del npath[np], path[np]
+ p = np # ha!
+
+ return
+
+
def check_version_conflict(self):