summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-07-24 14:22:28 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2015-07-24 14:22:28 -0700
commit27ca697b43458c76fd7e079c2a6395fbb5b6126e (patch)
tree1b5ced0211fe27194a698e97504b3194aee6c82a
parent1e2f421faa62455033ea6c3db941221723da3599 (diff)
downloadspack-27ca697b43458c76fd7e079c2a6395fbb5b6126e.tar.gz
spack-27ca697b43458c76fd7e079c2a6395fbb5b6126e.tar.bz2
spack-27ca697b43458c76fd7e079c2a6395fbb5b6126e.tar.xz
spack-27ca697b43458c76fd7e079c2a6395fbb5b6126e.zip
Add Python version test to detect {} in version strings.
- {} is not compatible with Python 2.6
-rwxr-xr-xlib/spack/external/pyqver2.py12
-rw-r--r--lib/spack/spack/test/python_version.py17
2 files changed, 21 insertions, 8 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/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))