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
This commit is contained in:
		
				
					committed by
					
						
						Todd Gamblin
					
				
			
			
				
	
			
			
			
						parent
						
							ac3e21f8d4
						
					
				
				
					commit
					d5e5e4ed1a
				
			@@ -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."
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user