summaryrefslogtreecommitdiff
path: root/bin/spack
diff options
context:
space:
mode:
Diffstat (limited to 'bin/spack')
-rwxr-xr-xbin/spack17
1 files changed, 17 insertions, 0 deletions
diff --git a/bin/spack b/bin/spack
index 127a85f6fe..e92d7cc273 100755
--- a/bin/spack
+++ b/bin/spack
@@ -38,6 +38,23 @@ SPACK_PREFIX = os.path.dirname(os.path.dirname(SPACK_FILE))
# Allow spack libs to be imported in our scripts
SPACK_LIB_PATH = os.path.join(SPACK_PREFIX, "lib", "spack")
sys.path.insert(0, SPACK_LIB_PATH)
+SPACK_EXTERNAL_LIBS = os.path.join(SPACK_LIB_PATH, "external")
+sys.path.insert(0, SPACK_EXTERNAL_LIBS)
+
+# Quick and dirty check to clean orphaned .pyc files left over from
+# previous revisions. These files were present in earlier versions of
+# Spack, were removed, but shadow system modules that Spack still
+# imports. If we leave them, Spack will fail in mysterious ways.
+# TODO: more elegant solution for orphaned pyc files.
+orphaned_pyc_files = [os.path.join(SPACK_EXTERNAL_LIBS, n)
+ for n in ('functools.pyc', 'ordereddict.pyc')]
+for pyc_file in orphaned_pyc_files:
+ if not os.path.exists(pyc_file):
+ continue
+ try:
+ os.remove(pyc_file)
+ except OSError as e:
+ print "WARNING: Spack may fail mysteriously. Couldn't remove orphaned .pyc file: %s" % pyc
# If there is no working directory, use the spack prefix.
try: