From 0e2e67562f3de67c088890ef9f0798551bfc225e Mon Sep 17 00:00:00 2001 From: Peter Dillinger Date: Tue, 27 Oct 2020 11:56:51 -0700 Subject: [PATCH] Give instructions instead of broken 2to3 for clang-format-diff.py (#7603) Summary: My previous change to use lib2to3 to migrate clang-format-diff.py for Python 2 only works if there's nothing to reformat. Instead, give instructions to download to REPO_ROOT. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7603 Test Plan: Try the instructions on a fresh CentOS 8 devserver Reviewed By: riversand963 Differential Revision: D24569608 Pulled By: pdillinger fbshipit-source-id: 1410ba163e016b226e883dec93fae3df9ed0eab2 --- build_tools/format-diff.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/build_tools/format-diff.sh b/build_tools/format-diff.sh index 386885b57..2dba5539e 100755 --- a/build_tools/format-diff.sh +++ b/build_tools/format-diff.sh @@ -75,17 +75,15 @@ else exit 129 fi # Unfortunately, some machines have a Python2 clang-format-diff.py - # installed but only a Python3 interpreter installed. Rather than trying - # different Python versions that might be installed, we can try migrating - # the code to Python3 if it looks like Python2 + # installed but only a Python3 interpreter installed. Unfortunately, + # automatic 2to3 migration is insufficient, so suggest downloading latest. if grep -q "print '" "$CFD_PATH" && \ ${PYTHON:-python3} --version | grep -q 'ython 3'; then - if [ ! -f "$REPO_ROOT/.py3/clang-format-diff.py" ]; then - echo "Migrating $CFD_PATH to Python3 in a hidden file" - mkdir -p "$REPO_ROOT/.py3" - ${PYTHON:-python3} -m lib2to3 -w -n -o "$REPO_ROOT/.py3" "$CFD_PATH" > /dev/null || exit 128 - fi - CFD_PATH="$REPO_ROOT/.py3/clang-format-diff.py" + echo "You have clang-format-diff.py for Python 2 but are using a Python 3" + echo "interpreter (${PYTHON:-python3})." + echo "You can download clang-format-diff.py for Python 3 by running: " + echo " curl --location http://goo.gl/iUW1u2 -o ${REPO_ROOT}/clang-format-diff.py" + exit 130 fi CLANG_FORMAT_DIFF="${PYTHON:-python3} $CFD_PATH" # This had better work after all those checks -- GitLab