From 6d7b26d4e08c2ca29f2fe6ff32e63ebfd377d164 Mon Sep 17 00:00:00 2001 From: Peter Scheibel Date: Wed, 11 Nov 2015 18:04:22 -0800 Subject: Insert lib/spack/external into sys.path. This avoids cases where the system python install and lib/spack/external have the same library installed. This requires modifying the names of some modules in lib/spack/external in cases where both the system python and backported features of future python versions (i.e. after 2.6) are used (previously distinguished by "from external import X" and "import X"). --- bin/spack | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bin') diff --git a/bin/spack b/bin/spack index 127a85f6fe..f587e206db 100755 --- a/bin/spack +++ b/bin/spack @@ -38,6 +38,8 @@ 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) # If there is no working directory, use the spack prefix. try: -- cgit v1.2.3-70-g09d2 From 894fcd90e7cc9c080e639f846a02b683ff29c17b Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Mon, 23 Nov 2015 17:39:59 -0800 Subject: 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. --- bin/spack | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'bin') 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() -- cgit v1.2.3-70-g09d2