details:
http://www.bx.psu.edu/hg/galaxy/rev/2fa5488a9b3e
changeset: 3537:2fa5488a9b3e
user: Nate Coraor <nate(a)bx.psu.edu>
date: Tue Mar 16 14:07:42 2010 -0400
description:
Monkeypatch pkg_resources to put eggs at the beginning of the path instead of the end
diffstat:
lib/galaxy/__init__.py | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diffs (38 lines):
diff -r d776beca95f8 -r 2fa5488a9b3e lib/galaxy/__init__.py
--- a/lib/galaxy/__init__.py Tue Mar 16 12:00:10 2010 -0400
+++ b/lib/galaxy/__init__.py Tue Mar 16 14:07:42 2010 -0400
@@ -61,3 +61,34 @@
except:
pkg_resources._compatible_platforms = pkg_resources.compatible_platforms
pkg_resources.compatible_platforms = _compatible_platforms
+
+# patch to insert eggs at the beginning of sys.path instead of at the end
+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
+
+ nloc = pkg_resources._normalize_cached(loc)
+ npath= [(p and pkg_resources._normalize_cached(p) or p) for p in path]
+
+ if path is sys.path:
+ self.check_version_conflict()
+ path.insert(0, loc)
+
+ # remove dups
+ while 1:
+ try:
+ np = npath.index(nloc, 1)
+ except ValueError:
+ break
+ else:
+ del npath[np], path[np]
+
+ return
+try:
+ assert pkg_resources.Distribution._insert_on
+except:
+ pkg_resources.Distribution._insert_on = pkg_resources.Distribution.insert_on
+ pkg_resources.Distribution.insert_on = _insert_on