From 979b53cab605d250dfe23edaacc6b0d2ff88d978 Mon Sep 17 00:00:00 2001 From: alalazo Date: Tue, 10 May 2016 18:33:07 +0200 Subject: qa : modifying 2 packages and a framework file just for the sake of it --- lib/spack/spack/architecture.py | 1 + var/spack/repos/builtin/packages/ImageMagick/package.py | 4 +++- var/spack/repos/builtin/packages/Mitos/package.py | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py index 2701fab90c..eec7636d00 100644 --- a/lib/spack/spack/architecture.py +++ b/lib/spack/spack/architecture.py @@ -44,6 +44,7 @@ class NoSysTypeError(serr.SpackError): "Could not determine sys_type for this machine.") + def get_sys_type_from_spack_globals(): """Return the SYS_TYPE from spack globals, or None if it isn't set.""" if not hasattr(spack, "sys_type"): diff --git a/var/spack/repos/builtin/packages/ImageMagick/package.py b/var/spack/repos/builtin/packages/ImageMagick/package.py index 753ea80ca6..d0a820b5fc 100644 --- a/var/spack/repos/builtin/packages/ImageMagick/package.py +++ b/var/spack/repos/builtin/packages/ImageMagick/package.py @@ -23,8 +23,10 @@ class Imagemagick(Package): version('6.8.9-10', 'aa050bf9785e571c956c111377bbf57c', url="http://sourceforge.net/projects/imagemagick/files/old-sources/6.x/6.8/ImageMagick-6.8.9-10.tar.gz/download") - depends_on('libtool') + + depends_on('jpeg') + depends_on('libtool') depends_on('libpng') depends_on('freetype') depends_on('fontconfig') diff --git a/var/spack/repos/builtin/packages/Mitos/package.py b/var/spack/repos/builtin/packages/Mitos/package.py index ea131872dd..073c473b93 100644 --- a/var/spack/repos/builtin/packages/Mitos/package.py +++ b/var/spack/repos/builtin/packages/Mitos/package.py @@ -19,6 +19,8 @@ class Mitos(Package): depends_on('hwloc') depends_on('mpi') + + def install(self, spec, prefix): with working_dir('spack-build', create=True): cmake('..', *std_cmake_args) -- cgit v1.2.3-60-g2f50 From 190c437980ecb7e1710643b05278cfd4f4b77b1b Mon Sep 17 00:00:00 2001 From: alalazo Date: Tue, 10 May 2016 18:38:30 +0200 Subject: qa : copied flake8 configuration, updated travis.yml --- .travis.yml | 2 +- flake8-framework.ini | 3 +++ flake8-packages.ini | 3 +++ flake8.ini | 3 --- 4 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 flake8-framework.ini create mode 100644 flake8-packages.ini delete mode 100644 flake8.ini diff --git a/.travis.yml b/.travis.yml index 4ff4d5f483..96138813e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ script: - coverage run bin/spack test # Checks if the file that have been changed are flake8 conformant - CHANGED_PYTHON_FILES=`git diff develop... --name-only | perl -ne 'print if /\.py$/'` - - if [[ ${CHANGED_PYTHON_FILES} ]] ; then flake8 --format pylint --config flake8.ini ${CHANGED_PYTHON_FILES} ; fi + - if [[ ${CHANGED_PYTHON_FILES} ]] ; then flake8 --format pylint --config flake8-framework.ini ${CHANGED_PYTHON_FILES} ; fi after_success: diff --git a/flake8-framework.ini b/flake8-framework.ini new file mode 100644 index 0000000000..32ced73dd7 --- /dev/null +++ b/flake8-framework.ini @@ -0,0 +1,3 @@ +[flake8] +ignore = W391,F403,E221,F821 +max-line-length = 79 diff --git a/flake8-packages.ini b/flake8-packages.ini new file mode 100644 index 0000000000..32ced73dd7 --- /dev/null +++ b/flake8-packages.ini @@ -0,0 +1,3 @@ +[flake8] +ignore = W391,F403,E221,F821 +max-line-length = 79 diff --git a/flake8.ini b/flake8.ini deleted file mode 100644 index 32ced73dd7..0000000000 --- a/flake8.ini +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -ignore = W391,F403,E221,F821 -max-line-length = 79 -- cgit v1.2.3-60-g2f50 From 3f20014f335f50e6bac8f8ced7a36fae00537c61 Mon Sep 17 00:00:00 2001 From: alalazo Date: Tue, 10 May 2016 18:45:11 +0200 Subject: qa : differentiate framework from packages --- .travis.yml | 7 +++++-- flake8-framework.ini | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 96138813e2..c41692c08e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,9 +25,12 @@ script: - spack install -v libdwarf # Run unit tests with code coverage - coverage run bin/spack test - # Checks if the file that have been changed are flake8 conformant - - CHANGED_PYTHON_FILES=`git diff develop... --name-only | perl -ne 'print if /\.py$/'` + # Checks if the file that have been changed are flake8 conformant [framework] + - CHANGED_PYTHON_FILES=`git diff develop... --name-only | perl -ne 'print if /\.py$/' | perl -ne 'print if not /var/' ` - if [[ ${CHANGED_PYTHON_FILES} ]] ; then flake8 --format pylint --config flake8-framework.ini ${CHANGED_PYTHON_FILES} ; fi + # Checks if the file that have been changed are flake8 conformant [packages] + - CHANGED_PACKAGES=`git diff develop... --name-only | perl -ne 'print if /\.py$/' | perl -ne 'print if /var/' ` + - if [[ ${CHANGED_PACKAGES} ]] ; then flake8 --format pylint --config flake8-packages.ini ${CHANGED_PACKAGES} ; fi after_success: diff --git a/flake8-framework.ini b/flake8-framework.ini index 32ced73dd7..f8bff04355 100644 --- a/flake8-framework.ini +++ b/flake8-framework.ini @@ -1,3 +1,3 @@ [flake8] -ignore = W391,F403,E221,F821 +ignore = W391,F403,E221 max-line-length = 79 -- cgit v1.2.3-60-g2f50 From 7d74e209f365ba135acd9dfe738737bcf37d4b79 Mon Sep 17 00:00:00 2001 From: alalazo Date: Tue, 10 May 2016 19:20:26 +0200 Subject: qa : this should still fail due to F821 --- lib/spack/spack/architecture.py | 15 +++++++-------- var/spack/repos/builtin/packages/ImageMagick/package.py | 14 +++++++------- var/spack/repos/builtin/packages/Mitos/package.py | 9 +++------ 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py index eec7636d00..62c25c8003 100644 --- a/lib/spack/spack/architecture.py +++ b/lib/spack/spack/architecture.py @@ -34,15 +34,14 @@ import spack.error as serr class InvalidSysTypeError(serr.SpackError): def __init__(self, sys_type): - super(InvalidSysTypeError, self).__init__( - "Invalid sys_type value for Spack: " + sys_type) + super(InvalidSysTypeError, + self).__init__("Invalid sys_type value for Spack: " + sys_type) class NoSysTypeError(serr.SpackError): def __init__(self): - super(NoSysTypeError, self).__init__( - "Could not determine sys_type for this machine.") - + super(NoSysTypeError, + self).__init__("Could not determine sys_type for this machine.") def get_sys_type_from_spack_globals(): @@ -70,15 +69,15 @@ def get_sys_type_from_platform(): @memoized def sys_type(): """Returns a SysType for the current machine.""" - methods = [get_sys_type_from_spack_globals, - get_sys_type_from_environment, + methods = [get_sys_type_from_spack_globals, get_sys_type_from_environment, get_sys_type_from_platform] # search for a method that doesn't return None sys_type = None for method in methods: sys_type = method() - if sys_type: break + if sys_type: + break # Couldn't determine the sys_type for this machine. if sys_type is None: diff --git a/var/spack/repos/builtin/packages/ImageMagick/package.py b/var/spack/repos/builtin/packages/ImageMagick/package.py index d0a820b5fc..7a3d12e364 100644 --- a/var/spack/repos/builtin/packages/ImageMagick/package.py +++ b/var/spack/repos/builtin/packages/ImageMagick/package.py @@ -1,10 +1,11 @@ from spack import * + class Imagemagick(Package): """ImageMagick is a image processing library""" homepage = "http://www.imagemagic.org" - #------------------------------------------------------------------------- + # ------------------------------------------------------------------------- # ImageMagick does not keep around anything but *-10 versions, so # this URL may change. If you want the bleeding edge, you can # uncomment it and see if it works but you may need to try to @@ -17,13 +18,13 @@ class Imagemagick(Package): # version('6.9.0-6', 'c1bce7396c22995b8bdb56b7797b4a1b', # url="http://www.imagemagick.org/download/ImageMagick-6.9.0-6.tar.bz2") - #------------------------------------------------------------------------- + # ------------------------------------------------------------------------- # *-10 versions are archived, so these versions should fetch reliably. # ------------------------------------------------------------------------- - version('6.8.9-10', 'aa050bf9785e571c956c111377bbf57c', - url="http://sourceforge.net/projects/imagemagick/files/old-sources/6.x/6.8/ImageMagick-6.8.9-10.tar.gz/download") - - + version( + '6.8.9-10', + 'aa050bf9785e571c956c111377bbf57c', + url="http://sourceforge.net/projects/imagemagick/files/old-sources/6.x/6.8/ImageMagick-6.8.9-10.tar.gz/download") # NOQA: ignore=E501 depends_on('jpeg') depends_on('libtool') @@ -34,6 +35,5 @@ class Imagemagick(Package): def install(self, spec, prefix): configure("--prefix=%s" % prefix) - make() make("install") diff --git a/var/spack/repos/builtin/packages/Mitos/package.py b/var/spack/repos/builtin/packages/Mitos/package.py index 073c473b93..ec1d56a5c7 100644 --- a/var/spack/repos/builtin/packages/Mitos/package.py +++ b/var/spack/repos/builtin/packages/Mitos/package.py @@ -1,26 +1,23 @@ from spack import * + class Mitos(Package): """Mitos is a library and a tool for collecting sampled memory performance data to view with MemAxes""" homepage = "https://github.com/llnl/Mitos" - url = "https://github.com/llnl/Mitos" + url = "https://github.com/llnl/Mitos" version('0.9.2', git='https://github.com/llnl/Mitos.git', commit='8cb143a2e8c00353ff531a781a9ca0992b0aaa3d') - version('0.9.1', - git='https://github.com/llnl/Mitos.git', - tag='v0.9.1') + version('0.9.1', git='https://github.com/llnl/Mitos.git', tag='v0.9.1') depends_on('dyninst@8.2.1:') depends_on('hwloc') depends_on('mpi') - - def install(self, spec, prefix): with working_dir('spack-build', create=True): cmake('..', *std_cmake_args) -- cgit v1.2.3-60-g2f50 From 2aa4387ebac307285c1b2c90bc6527b82fe83839 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Tue, 10 May 2016 23:45:41 -0700 Subject: Update code style checking. - Exempt overlong URL lines from checks. - Omit some of the more painful PEP items. --- .style.yapf | 3 --- .travis.yml | 24 ++++++++++++++++++------ flake8-framework.ini | 3 --- flake8-packages.ini | 3 --- share/spack/qa/flake8-framework | 10 ++++++++++ share/spack/qa/flake8-packages | 11 +++++++++++ 6 files changed, 39 insertions(+), 15 deletions(-) delete mode 100644 .style.yapf delete mode 100644 flake8-framework.ini delete mode 100644 flake8-packages.ini create mode 100644 share/spack/qa/flake8-framework create mode 100644 share/spack/qa/flake8-packages diff --git a/.style.yapf b/.style.yapf deleted file mode 100644 index a4b3f65252..0000000000 --- a/.style.yapf +++ /dev/null @@ -1,3 +0,0 @@ -[style] -based_on_style = pep8 -column_limit = 79 diff --git a/.travis.yml b/.travis.yml index c41692c08e..9acba991c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,23 +15,35 @@ before_install: # Need this for the git tests to succeed. - git config --global user.email "spack@example.com" - git config --global user.name "Test User" + # Need this to be able to compute the list of changed files - git fetch origin develop:develop script: + # Regular spack setup and tests - . share/spack/setup-env.sh - spack compilers - spack config get compilers - spack install -v libdwarf + # Run unit tests with code coverage - coverage run bin/spack test - # Checks if the file that have been changed are flake8 conformant [framework] - - CHANGED_PYTHON_FILES=`git diff develop... --name-only | perl -ne 'print if /\.py$/' | perl -ne 'print if not /var/' ` - - if [[ ${CHANGED_PYTHON_FILES} ]] ; then flake8 --format pylint --config flake8-framework.ini ${CHANGED_PYTHON_FILES} ; fi - # Checks if the file that have been changed are flake8 conformant [packages] - - CHANGED_PACKAGES=`git diff develop... --name-only | perl -ne 'print if /\.py$/' | perl -ne 'print if /var/' ` - - if [[ ${CHANGED_PACKAGES} ]] ; then flake8 --format pylint --config flake8-packages.ini ${CHANGED_PACKAGES} ; fi + # Check if changed files are flake8 conformant [framework] + - changed=$(git diff --name-only develop... | grep '.py$' | grep -v ^var/) + - [[ $changed ]] && \ + flake8 --format pylint --config share/spack/qa/flake8-framework $changed + + # Check if changed files are flake8 conformant [packages] + - changed=$(git diff --name-only develop... | grep '.py$' | grep ^var/) + + # Exempt url lines in changed packages from overlong errors. + - for file in $changed; do \ + [[ file = *package.py ]] && \ + perl -i~ -pe 's/^(\s*url\s*=.*)$/\1 # NOQA/' $file; \ + done + - [[ $changed ]] && \ + flake8 --format pylint --config share/spack/qa/flake8-packages $changed after_success: - coveralls diff --git a/flake8-framework.ini b/flake8-framework.ini deleted file mode 100644 index f8bff04355..0000000000 --- a/flake8-framework.ini +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -ignore = W391,F403,E221 -max-line-length = 79 diff --git a/flake8-packages.ini b/flake8-packages.ini deleted file mode 100644 index 32ced73dd7..0000000000 --- a/flake8-packages.ini +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -ignore = W391,F403,E221,F821 -max-line-length = 79 diff --git a/share/spack/qa/flake8-framework b/share/spack/qa/flake8-framework new file mode 100644 index 0000000000..b1ad00b80f --- /dev/null +++ b/share/spack/qa/flake8-framework @@ -0,0 +1,10 @@ +# -*- conf -*- +[flake8] +# Descriptions of ignored checks: +# +# E221: multiple spaces before operator +# E241: multiple spaces after ‘,’ +# F403: disable wildcard import +# +ignore = E221,E241,F403 +max-line-length = 79 diff --git a/share/spack/qa/flake8-packages b/share/spack/qa/flake8-packages new file mode 100644 index 0000000000..0e5be249fb --- /dev/null +++ b/share/spack/qa/flake8-packages @@ -0,0 +1,11 @@ +# -*- conf -*- +[flake8] +# Descriptions of ignored checks: +# +# E221: multiple spaces before operator +# E241: multiple spaces after ‘,’ +# F403: disable wildcard import +# F821: undefined name (needed for build commands) +# +ignore = E221,E241,F403,F821 +max-line-length = 79 -- cgit v1.2.3-60-g2f50 From d7847ff7685a52670a9d01cf39bd44eff1a57684 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Wed, 11 May 2016 01:16:41 -0700 Subject: Use just one flake8 file; mark package.py files to avoid E501 w/url. --- .flake8 | 12 ++++++++++++ share/spack/qa/flake8-framework | 10 ---------- share/spack/qa/flake8-packages | 11 ----------- var/spack/repos/builtin/packages/ImageMagick/package.py | 2 +- 4 files changed, 13 insertions(+), 22 deletions(-) create mode 100644 .flake8 delete mode 100644 share/spack/qa/flake8-framework delete mode 100644 share/spack/qa/flake8-packages diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000000..ab1e14b66e --- /dev/null +++ b/.flake8 @@ -0,0 +1,12 @@ +# -*- conf -*- +[flake8] +# Descriptions of ignored checks: +# +# E221: multiple spaces before operator +# E241: multiple spaces after ‘,’ +# F403: disable wildcard import +# F821: undefined name (needed for build commands) +# F999: Undefined undefined name (needed for build commands) +# +ignore = E221,E241,F403,F821,F999 +max-line-length = 79 diff --git a/share/spack/qa/flake8-framework b/share/spack/qa/flake8-framework deleted file mode 100644 index b1ad00b80f..0000000000 --- a/share/spack/qa/flake8-framework +++ /dev/null @@ -1,10 +0,0 @@ -# -*- conf -*- -[flake8] -# Descriptions of ignored checks: -# -# E221: multiple spaces before operator -# E241: multiple spaces after ‘,’ -# F403: disable wildcard import -# -ignore = E221,E241,F403 -max-line-length = 79 diff --git a/share/spack/qa/flake8-packages b/share/spack/qa/flake8-packages deleted file mode 100644 index 0e5be249fb..0000000000 --- a/share/spack/qa/flake8-packages +++ /dev/null @@ -1,11 +0,0 @@ -# -*- conf -*- -[flake8] -# Descriptions of ignored checks: -# -# E221: multiple spaces before operator -# E241: multiple spaces after ‘,’ -# F403: disable wildcard import -# F821: undefined name (needed for build commands) -# -ignore = E221,E241,F403,F821 -max-line-length = 79 diff --git a/var/spack/repos/builtin/packages/ImageMagick/package.py b/var/spack/repos/builtin/packages/ImageMagick/package.py index 7a3d12e364..3a86d9fb7c 100644 --- a/var/spack/repos/builtin/packages/ImageMagick/package.py +++ b/var/spack/repos/builtin/packages/ImageMagick/package.py @@ -24,7 +24,7 @@ class Imagemagick(Package): version( '6.8.9-10', 'aa050bf9785e571c956c111377bbf57c', - url="http://sourceforge.net/projects/imagemagick/files/old-sources/6.x/6.8/ImageMagick-6.8.9-10.tar.gz/download") # NOQA: ignore=E501 + url="http://sourceforge.net/projects/imagemagick/files/old-sources/6.x/6.8/ImageMagick-6.8.9-10.tar.gz/download") depends_on('jpeg') depends_on('libtool') -- cgit v1.2.3-60-g2f50 From f15837505420e878e7b5ec2139686985deb54401 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Wed, 11 May 2016 01:17:52 -0700 Subject: .travis.yml uses a script now. - user can run the same script. --- .travis.yml | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9acba991c7..904143a00f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,21 +29,8 @@ script: # Run unit tests with code coverage - coverage run bin/spack test - # Check if changed files are flake8 conformant [framework] - - changed=$(git diff --name-only develop... | grep '.py$' | grep -v ^var/) - - [[ $changed ]] && \ - flake8 --format pylint --config share/spack/qa/flake8-framework $changed - - # Check if changed files are flake8 conformant [packages] - - changed=$(git diff --name-only develop... | grep '.py$' | grep ^var/) - - # Exempt url lines in changed packages from overlong errors. - - for file in $changed; do \ - [[ file = *package.py ]] && \ - perl -i~ -pe 's/^(\s*url\s*=.*)$/\1 # NOQA/' $file; \ - done - - [[ $changed ]] && \ - flake8 --format pylint --config share/spack/qa/flake8-packages $changed + # Run flake8 code style checks. + - share/spack/qa/run-flake8 after_success: - coveralls -- cgit v1.2.3-60-g2f50 From c512b37a4e26bb639893d06c9f2df30fb6dd6892 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Wed, 11 May 2016 01:25:40 -0700 Subject: format .flake8 more nicely. --- .flake8 | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.flake8 b/.flake8 index ab1e14b66e..a1e2fcc1f8 100644 --- a/.flake8 +++ b/.flake8 @@ -1,12 +1,20 @@ # -*- conf -*- -[flake8] -# Descriptions of ignored checks: +# flake8 settings for Spack. +# +# Below we describe which flake8 checks Spack ignores and what the +# rationale is. +# +# Let people line things up nicely: +# - E221: multiple spaces before operator +# - E241: multiple spaces after ‘,’ # -# E221: multiple spaces before operator -# E241: multiple spaces after ‘,’ -# F403: disable wildcard import -# F821: undefined name (needed for build commands) -# F999: Undefined undefined name (needed for build commands) +# Spack allows wildcard imports: +# - F403: disable wildcard import # +# These are required to get the package.py files to test clean. +# - F821: undefined name (needed for cmake, configure, etc.) +# - F999: name name be undefined or undefined from star imports. +# +[flake8] ignore = E221,E241,F403,F821,F999 max-line-length = 79 -- cgit v1.2.3-60-g2f50 From 78d25ad337e2faaa8cfd589607801acb78aec4d9 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Wed, 11 May 2016 02:01:24 -0700 Subject: Add run-flake8 script. - was missing the obvious. --- share/spack/qa/run-flake8 | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 share/spack/qa/run-flake8 diff --git a/share/spack/qa/run-flake8 b/share/spack/qa/run-flake8 new file mode 100755 index 0000000000..722c7fcba6 --- /dev/null +++ b/share/spack/qa/run-flake8 @@ -0,0 +1,55 @@ +#!/bin/bash +# +# This script runs source code style checks on Spack. +# +# It should be executed from the top-level directory of the repo, +# e.g.: +# +# share/spack/qa/run-flake8 +# +# To run it, you'll need to have the Python flake8 installed locally. +# +PYTHONPATH=./lib/spack:$PYTHONPATH + +flake8="$(which flake8)" +if [[ ! $flake8 ]]; then + echo "ERROR: flake8 is required to run this script." + exit 1 +fi + +# Check if changed files are flake8 conformant [framework] +changed=$(git diff --name-only develop... | grep '.py$') + +# Exempt url lines in changed packages from overlong line errors. +for file in $changed; do + if [[ $file = *package.py ]]; then + perl -i~ -pe 's/^(\s*url\s*=.*)$/\1 # NOQA: ignore=E501/' $file; + fi +done + +return_code=0 +if [[ $changed ]]; then + echo ======================================================= + echo flake8: running flake8 code checks on spack. + echo + echo Modified files: + echo $changed | perl -pe 's/^/ /;s/ +/\n /g' + echo ======================================================= + if flake8 --format pylint $changed; then + echo "Flake8 checks were clean." + else + echo "Flake8 found errors." + return_code=1 + fi +else + echo No core framework files modified. +fi + +# Restore original package files after modifying them. +for file in $changed; do + if [[ $file = *package.py ]]; then + mv "${file}~" "${file}" + fi +done + +exit $return_code -- cgit v1.2.3-60-g2f50