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.
This commit is contained in:
parent
6d7b26d4e0
commit
894fcd90e7
1 changed files with 15 additions and 0 deletions
15
bin/spack
15
bin/spack
|
@ -41,6 +41,21 @@ sys.path.insert(0, SPACK_LIB_PATH)
|
||||||
SPACK_EXTERNAL_LIBS = os.path.join(SPACK_LIB_PATH, "external")
|
SPACK_EXTERNAL_LIBS = os.path.join(SPACK_LIB_PATH, "external")
|
||||||
sys.path.insert(0, SPACK_EXTERNAL_LIBS)
|
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.
|
# If there is no working directory, use the spack prefix.
|
||||||
try:
|
try:
|
||||||
working_dir = os.getcwd()
|
working_dir = os.getcwd()
|
||||||
|
|
Loading…
Reference in a new issue