diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/spack/external/pyqver2.py | 12 | ||||
-rw-r--r-- | lib/spack/spack/build_environment.py | 8 | ||||
-rw-r--r-- | lib/spack/spack/cmd/find.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/test/python_version.py | 17 | ||||
-rw-r--r-- | lib/spack/spack/util/executable.py | 27 |
5 files changed, 45 insertions, 21 deletions
diff --git a/lib/spack/external/pyqver2.py b/lib/spack/external/pyqver2.py index cd45bf948f..4a16e2811e 100755 --- a/lib/spack/external/pyqver2.py +++ b/lib/spack/external/pyqver2.py @@ -165,12 +165,24 @@ class NodeChecker(object): def rollup(n): if isinstance(n, compiler.ast.Name): return n.name + elif isinstance(n, compiler.ast.Const): + return type(n.value).__name__ elif isinstance(n, compiler.ast.Getattr): r = rollup(n.expr) if r: return r + "." + n.attrname name = rollup(node.node) if name: + # Special handling for empty format strings, which aren't + # allowed in Python 2.6 + if name in ('unicode.format', 'str.format'): + n = node.node + if isinstance(n, compiler.ast.Getattr): + n = n.expr + if isinstance(n, compiler.ast.Const): + if '{}' in n.value: + self.add(node, (2,7), name + ' with {} format string') + v = Functions.get(name) if v is not None: self.add(node, v, name) diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index 81fbedc689..a133faa629 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -88,10 +88,10 @@ def set_compiler_environment_variables(pkg): compiler = pkg.compiler # Set compiler variables used by CMake and autotools - os.environ['CC'] = 'cc' - os.environ['CXX'] = 'c++' - os.environ['F77'] = 'f77' - os.environ['FC'] = 'f90' + os.environ['CC'] = join_path(spack.build_env_path, 'cc') + os.environ['CXX'] = join_path(spack.build_env_path, 'c++') + os.environ['F77'] = join_path(spack.build_env_path, 'f77') + os.environ['FC'] = join_path(spack.build_env_path, 'f90') # Set SPACK compiler variables so that our wrapper knows what to call if compiler.cc: diff --git a/lib/spack/spack/cmd/find.py b/lib/spack/spack/cmd/find.py index a0232d2f12..3c993990b1 100644 --- a/lib/spack/spack/cmd/find.py +++ b/lib/spack/spack/cmd/find.py @@ -92,7 +92,7 @@ def display_specs(specs, **kwargs): # Print one spec per line along with prefix path width = max(len(s) for s in abbreviated) width += 2 - format = " %-{}s%s".format(width) + format = " %%-%ds%%s" % width for abbrv, spec in zip(abbreviated, specs): if hashes: diff --git a/lib/spack/spack/test/python_version.py b/lib/spack/spack/test/python_version.py index 5b803b4cf3..5779d31ed2 100644 --- a/lib/spack/spack/test/python_version.py +++ b/lib/spack/spack/test/python_version.py @@ -41,13 +41,10 @@ spack_max_version = (2,6) class PythonVersionTest(unittest.TestCase): - def spack_python_files(self): + def pyfiles(self, *search_paths): # first file is the spack script. yield spack.spack_file - # Next files are all the source files and package files. - search_paths = [spack.lib_path, spack.var_path] - # Iterate through the whole spack source tree. for path in search_paths: for root, dirnames, filenames in os.walk(path): @@ -56,16 +53,20 @@ class PythonVersionTest(unittest.TestCase): yield os.path.join(root, filename) - def all_package_py_files(self): + def package_py_files(self): for name in spack.db.all_package_names(): yield spack.db.filename_for_package_name(name) - def check_python_versions(self, files): + def check_python_versions(self, *files): # dict version -> filename -> reasons all_issues = {} for fn in files: + if fn != '/Users/gamblin2/src/spack/var/spack/packages/vim/package.py': + continue + print fn + with open(fn) as pyfile: versions = pyqver2.get_versions(pyfile.read()) for ver, reasons in versions.items(): @@ -101,8 +102,8 @@ class PythonVersionTest(unittest.TestCase): def test_core_module_compatibility(self): - self.check_python_versions(self.spack_python_files()) + self.check_python_versions(*self.pyfiles(spack.lib_path)) def test_package_module_compatibility(self): - self.check_python_versions(self.all_package_py_files()) + self.check_python_versions(*self.pyfiles(spack.packages_path)) diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py index 67e8cddd98..d1dfb62ffb 100644 --- a/lib/spack/spack/util/executable.py +++ b/lib/spack/spack/util/executable.py @@ -34,6 +34,7 @@ import llnl.util.tty as tty import spack import spack.error + class Executable(object): """Class representing a program that can be run on the command line.""" def __init__(self, name): @@ -58,7 +59,20 @@ class Executable(object): return_output = kwargs.get("return_output", False) fail_on_error = kwargs.get("fail_on_error", True) ignore_errors = kwargs.get("ignore_errors", ()) + + output = kwargs.get("output", sys.stdout) error = kwargs.get("error", sys.stderr) + input = kwargs.get("input", None) + + def streamify(arg, mode): + if isinstance(arg, basestring): + return open(arg, mode), True + elif arg is None and mode != 'r': + return open(os.devnull, mode), True + return arg, False + output, ostream = streamify(output, 'w') + error, estream = streamify(error, 'w') + input, istream = streamify(input, 'r') # if they just want to ignore one error code, make it a tuple. if isinstance(ignore_errors, int): @@ -77,16 +91,12 @@ class Executable(object): cmd_line = ' '.join(cmd) tty.debug(cmd_line) - close_error = False try: - if error is None: - error = open(os.devnull, 'w') - close_error = True - proc = subprocess.Popen( cmd, + stdin=input, stderr=error, - stdout=subprocess.PIPE if return_output else sys.stdout) + stdout=subprocess.PIPE if return_output else output) out, err = proc.communicate() self.returncode = proc.returncode @@ -110,8 +120,9 @@ class Executable(object): % (proc.returncode, cmd_line)) finally: - if close_error: - error.close() + if ostream: output.close() + if estream: error.close() + if istream: input.close() def __eq__(self, other): |