@@ -25,7 +25,7 @@ declare SRC_DIRS="src examples test logging tools diagnostics python"
25
25
# - The particular version of the `clang-format` program being used.
26
26
#
27
27
# For this reason, this script specifies the exact version of clang-format to be used.
28
- # Similarly for python/yapf, we shall use Python 2 and yapf 0.24
28
+ # Similarly for python/yapf, we shall use Python 3 and yapf 0.26.0
29
29
30
30
declare _intelnervana_clang_format_lib_SCRIPT_NAME=" ${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}"
31
31
declare _maint_SCRIPT_DIR=" $( cd $( dirname " ${_intelnervana_clang_format_lib_SCRIPT_NAME} " ) && pwd ) "
37
37
SED_FLAGS=' -rn'
38
38
fi
39
39
40
- # Find out python version. Use yapf only when in Python 2
40
+ # Find out python version. Use yapf only when in Python 3
41
41
if PYTHON_VERSION=$( python -c ' import sys; print(sys.version_info[:][0])' )
42
42
then
43
- if [[ " 2 " != " ${PYTHON_VERSION} " ]]; then
44
- echo " Python reports version number '${PYTHON_VERSION} ' so will skip yapf formatting. Please use Python2 "
43
+ if [[ " 3 " != " ${PYTHON_VERSION} " ]]; then
44
+ echo " Python reports version number '${PYTHON_VERSION} ' so will skip yapf formatting. Please use Python3 "
45
45
fi
46
46
else
47
47
bash_lib_print_error " Failed invocation of Python."
50
50
51
51
declare CLANG_FORMAT_BASENAME=" clang-format-3.9"
52
52
declare REQUIRED_CLANG_FORMAT_VERSION=3.9
53
- if [[ " 2 " == " ${PYTHON_VERSION} " ]]; then
53
+ if [[ " 3 " == " ${PYTHON_VERSION} " ]]; then
54
54
declare YAPF_FORMAT_BASENAME=" yapf"
55
- declare REQUIRED_YAPF_FORMAT_VERSION=0.24
55
+ declare REQUIRED_YAPF_FORMAT_VERSION=0.26
56
56
fi
57
57
58
58
declare THIS_SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
@@ -65,7 +65,7 @@ if ! CLANG_FORMAT_PROG="$(which "${CLANG_FORMAT_BASENAME}")"; then
65
65
bash_lib_die " Unable to find program ${CLANG_FORMAT_BASENAME} " >&2
66
66
fi
67
67
68
- if [[ " 2 " == " ${PYTHON_VERSION} " ]]; then
68
+ if [[ " 3 " == " ${PYTHON_VERSION} " ]]; then
69
69
declare YAPF_FORMAT_PROG
70
70
if ! YAPF_FORMAT_PROG=" $( which " ${YAPF_FORMAT_BASENAME} " ) " ; then
71
71
bash_lib_die " Unable to find program ${YAPF_FORMAT_BASENAME} " >&2
@@ -76,7 +76,7 @@ format_lib_verify_version "${CLANG_FORMAT_PROG}" "${REQUIRED_CLANG_FORMAT_VERSIO
76
76
bash_lib_status " Verified that '${CLANG_FORMAT_PROG} ' has version '${REQUIRED_CLANG_FORMAT_VERSION} '"
77
77
declare -a FAILED_FILES_CLANG=()
78
78
declare NUM_FILES_CHECKED_CLANG=0
79
- if [[ " 2 " == " ${PYTHON_VERSION} " ]]; then
79
+ if [[ " 3 " == " ${PYTHON_VERSION} " ]]; then
80
80
format_lib_verify_version " ${YAPF_FORMAT_PROG} " " ${REQUIRED_YAPF_FORMAT_VERSION} " " YAPF"
81
81
bash_lib_status " Verified that '${YAPF_FORMAT_PROG} ' has version '${REQUIRED_YAPF_FORMAT_VERSION} '"
82
82
declare -a FAILED_FILES_YAPF=()
@@ -109,7 +109,7 @@ for ROOT_SUBDIR in ${SRC_DIRS}; do
109
109
NUM_FILES_CHECKED_CLANG=$(( NUM_FILES_CHECKED_CLANG+ 1 ))
110
110
done
111
111
112
- if [[ " 2 " == " ${PYTHON_VERSION} " ]]; then
112
+ if [[ " 3 " == " ${PYTHON_VERSION} " ]]; then
113
113
bash_lib_status " About to check formatting of Python code in directory tree '$( pwd) /${ROOT_SUBDIR} ' ..."
114
114
declare SRC_FILE
115
115
# ignore the .in.py file (python/setup.in.py) which has format that crashes yapf
139
139
exit 1
140
140
fi
141
141
142
- if [[ " 2 " == " ${PYTHON_VERSION} " ]]; then
142
+ if [[ " 3 " == " ${PYTHON_VERSION} " ]]; then
143
143
if [[ ${# FAILED_FILES_YAPF[@]} -eq 0 ]]; then
144
144
bash_lib_status " All ${NUM_FILES_CHECKED_YAPF} Python files pass the code-format check."
145
145
else
0 commit comments