From 792b03325562e5577d018b188577915ea4dd5e7d Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Tue, 22 Dec 2015 07:54:25 -0800 Subject: Slightly more robust tmp directory search. - remove getcwd() check (seems arbitrary -- if users set their TMPDIR to this why stop them?) - try a number of common locations and try per-user directories in them first. --- lib/spack/spack/__init__.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py index ccd7dc25c8..92cb417a85 100644 --- a/lib/spack/spack/__init__.py +++ b/lib/spack/spack/__init__.py @@ -24,6 +24,7 @@ ############################################################################## import os import tempfile +import getpass from llnl.util.filesystem import * # This lives in $prefix/lib/spack/spack/__file__ @@ -111,10 +112,17 @@ use_tmp_stage = True # that it can create. tmp_dirs = [] _default_tmp = tempfile.gettempdir() -if _default_tmp != os.getcwd(): - tmp_dirs = [ join_path(_default_tmp, '%u', 'spack-stage'), - join_path(_default_tmp, 'spack-stage') ] -tmp_dirs.append('/nfs/tmp2/%u/spack-stage') # TODO: remove +_tmp_user = getpass.getuser() + +_tmp_candidates = (_default_tmp, '/nfs/tmp2', '/tmp', '/var/tmp') +for path in _tmp_candidates: + # don't add a second username if it's already unique by user. + if not _tmp_user in path: + tmp_dirs.append(join_path(path, '%u', 'spack-stage')) + +for path in _tmp_candidates: + if not path in tmp_dirs: + tmp_dirs.append(join_path(path, 'spack-stage')) # Whether spack should allow installation of unsafe versions of # software. "Unsafe" versions are ones it doesn't have a checksum -- cgit v1.2.3-70-g09d2