From 8eefab08c468e5ef4814df11512a441b5de6edcc Mon Sep 17 00:00:00 2001 From: Joris Roovers Date: Sun, 15 Apr 2018 12:23:34 +0200 Subject: Python 2.6 deprecation warning Added a Python 2.6 deprecation warning in setup.py Also modified the build test in run_tests.sh to check for the warning. --- run_tests.sh | 21 ++++++++++++++++++--- setup.py | 10 +++++++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index 67d21d6..9e3d546 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -166,13 +166,28 @@ run_build_test(){ # Attempt to build the package echo "Building package ..." pushd "$temp_dir" - python setup.py sdist bdist_wheel + # Copy stdout file descriptor so we can both print output to stdout as well as capture it in a variable + # https://stackoverflow.com/questions/12451278/bash-capture-stdout-to-a-variable-but-still-display-it-in-the-console + exec 5>&1 + output=$(python setup.py sdist bdist_wheel | tee /dev/fd/5) local exit_code=$? popd # Cleanup :-) rm -rf "$temp_dir" - # Print success/mno success + # Check for deprecation message in python 2.6 + if [[ $(python --version 2>&1) == 'Python 2.6'* ]]; then + echo -n "[Python 2.6] Checking for deprecation warning..." + echo "$output" | grep "A future version of gitlint will drop support for Python 2.6" > /dev/null + exit_code=$((exit_code + $?)) + if [ $exit_code -gt 0 ]; then + echo -e "${RED}FAIL${NO_COLOR}" + else + echo -e "${GREEN}SUCCESS${NO_COLOR}" + fi + fi + + # Print success/no success if [ $exit_code -gt 0 ]; then echo -e "Building package...${RED}FAIL${NO_COLOR}" else @@ -266,7 +281,7 @@ install_virtualenv(){ deactivate 2> /dev/null # deactivate any active environment virtualenv -p "$python_binary" "$venv_name" source "${venv_name}/bin/activate" - easy_install -U pip + # easy_install -U pip # Commenting out for now, since this gives issues with python 2.6 pip install --ignore-requires-python -r requirements.txt pip install --ignore-requires-python -r test-requirements.txt deactivate 2> /dev/null diff --git a/setup.py b/setup.py index a24a2b0..f2d1eed 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,9 @@ #!/usr/bin/env python +from __future__ import print_function from setuptools import setup, find_packages import re import os +import sys # There is an issue with building python packages in a shared vagrant directory because of how setuptools works # in python < 2.7.9. We solve this by deleting the filesystem hardlinking capability during build. @@ -9,7 +11,7 @@ import os try: del os.link except: - pass # Not all OSes (e.g. windows) support os.link + pass # Not all OSes (e.g. windows) support os.link description = "Git commit message linter written in python, checks your commit messages for style." long_description = """ @@ -89,3 +91,9 @@ setup( ], }, ) + +# Print a red deprecation warning for python 2.6 users +if sys.version_info[0] == 2 and sys.version_info[1] <= 6: + msg = "\033[31mDEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. " + \ + "A future version of gitlint will drop support for Python 2.6\033[0m" + print(msg) -- cgit v1.2.3