summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorAdam J. Stewart <ajstewart426@gmail.com>2016-10-05 12:00:31 -0500
committerTodd Gamblin <tgamblin@llnl.gov>2016-10-05 10:00:31 -0700
commitd5e5e4ed1aef6ade3ddef34c4ad7a57988fd8d74 (patch)
tree5d4faa19ffcb0fd9d7eb01e54554c9dd1ecb0207 /share
parentac3e21f8d4be5786761b5009690e09f6ec564c79 (diff)
downloadspack-d5e5e4ed1aef6ade3ddef34c4ad7a57988fd8d74.tar.gz
spack-d5e5e4ed1aef6ade3ddef34c4ad7a57988fd8d74.tar.bz2
spack-d5e5e4ed1aef6ade3ddef34c4ad7a57988fd8d74.tar.xz
spack-d5e5e4ed1aef6ade3ddef34c4ad7a57988fd8d74.zip
Add missing dependencies for Flake8 (#1883)
* Warn user if flake8 can't find setuptools * Add missing dependencies of flake8 * Updates to py-autopep8, make packages activateable * Check for presence of setuptools for Sphinx too * Fix bug in order of commands
Diffstat (limited to 'share')
-rwxr-xr-xshare/spack/qa/check_dependencies26
-rwxr-xr-xshare/spack/qa/run-flake8-tests8
2 files changed, 30 insertions, 4 deletions
diff --git a/share/spack/qa/check_dependencies b/share/spack/qa/check_dependencies
index cf3d204f48..e999463b03 100755
--- a/share/spack/qa/check_dependencies
+++ b/share/spack/qa/check_dependencies
@@ -65,6 +65,32 @@ for dep in "$@"; do
exit 1
fi
+
+ # Flake8 and Sphinx require setuptools in order to run.
+ # Otherwise, they print out this error message:
+ #
+ # Traceback (most recent call last):
+ # File: "/usr/bin/flake8", line 5, in <module>
+ # from pkg_resources import load_entry_point
+ # ImportError: No module named pkg_resources
+ #
+ # Print a more useful error message if setuptools not found.
+ if [[ $dep == flake8 || $dep == sphinx* ]]; then
+ # Find which Python is being run
+ # Spack-installed packages have a hard-coded shebang
+ python_cmd=$(head -n 1 $(which $dep) | cut -c 3-)
+ # May not have a shebang
+ if [[ $python_cmd != *python* ]]; then
+ python_cmd=python
+ fi
+ # Check if setuptools is in the PYTHONPATH
+ if ! $python_cmd -c "import setuptools" 2> /dev/null; then
+ echo "ERROR: setuptools is required to run $dep."
+ echo "Please add it to your PYTHONPATH."
+
+ exit 1
+ fi
+ fi
done
echo "Dependencies found."
diff --git a/share/spack/qa/run-flake8-tests b/share/spack/qa/run-flake8-tests
index 350ef3161f..6fe97160e3 100755
--- a/share/spack/qa/run-flake8-tests
+++ b/share/spack/qa/run-flake8-tests
@@ -23,10 +23,6 @@ deps=(
# Check for dependencies
"$QA_DIR/check_dependencies" "${deps[@]}" || exit 1
-# Move to root directory of Spack
-# Allows script to be run from anywhere
-cd "$SPACK_ROOT"
-
# Gather array of changed files
changed=($("$QA_DIR/changed_files" "*.py"))
@@ -36,6 +32,10 @@ if [[ ! "${changed[@]}" ]]; then
exit 0
fi
+# Move to root directory of Spack
+# Allows script to be run from anywhere
+cd "$SPACK_ROOT"
+
function cleanup {
# Restore original package files after modifying them.
for file in "${changed[@]}"; do