summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-11-23 17:39:59 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2015-11-23 17:49:39 -0800
commit894fcd90e7cc9c080e639f846a02b683ff29c17b (patch)
tree10402c4e9bec6fe77a5e9b3e842ad6324d6d3885
parent6d7b26d4e08c2ca29f2fe6ff32e63ebfd377d164 (diff)
downloadspack-894fcd90e7cc9c080e639f846a02b683ff29c17b.tar.gz
spack-894fcd90e7cc9c080e639f846a02b683ff29c17b.tar.bz2
spack-894fcd90e7cc9c080e639f846a02b683ff29c17b.tar.xz
spack-894fcd90e7cc9c080e639f846a02b683ff29c17b.zip
Add a fix/warning so that stale .pyc files don't kill Spack.
- Can't think of a better way to do this. - The externals integration will cause spack to die in weird ways for users who just pull from develop.
-rwxr-xr-xbin/spack15
1 files changed, 15 insertions, 0 deletions
diff --git a/bin/spack b/bin/spack
index f587e206db..e92d7cc273 100755
--- a/bin/spack
+++ b/bin/spack
@@ -41,6 +41,21 @@ 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:
working_dir = os.getcwd()