You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by cm...@apache.org on 2024/09/10 18:49:11 UTC
(trafficserver) 01/03: Adds some more checks around Python tooling for YAPF (#11755)
This is an automated email from the ASF dual-hosted git repository.
cmcfarlen pushed a commit to branch 10.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 22239144f98b75c3c742387eb6e6a9a689a84097
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Wed Sep 4 10:14:19 2024 -0700
Adds some more checks around Python tooling for YAPF (#11755)
(cherry picked from commit 953e507248d623c5d9f512422dfa45d1e4c940f2)
---
tools/yapf.sh | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/tools/yapf.sh b/tools/yapf.sh
index cf07f81874..6bcd34578d 100755
--- a/tools/yapf.sh
+++ b/tools/yapf.sh
@@ -41,22 +41,41 @@ _END_
set -e # exit on error
+ if command -v pip3 &> /dev/null; then
+ PIP_CMD="pip3"
+ elif command -v pip &> /dev/null; then
+ PIP_CMD="pip"
+ else
+ echo "pip is not installed."
+ exit 1
+ fi
+
if ! type virtualenv >/dev/null 2>/dev/null
then
- pip install -q virtualenv
+ ${PIP_CMD} install -q virtualenv
fi
+ if python3 -m venv --help &> /dev/null; then
+ VENV_LIB="venv"
+ elif python3 -m virtualenv --help &> /dev/null; then
+ VENV_LIB="virtualenv"
+ else
+ echo "Neither venv nor virtualenv is available."
+ exit 1
+ fi
+
+
REPO_ROOT=$(cd $(dirname $0) && git rev-parse --show-toplevel)
GIT_DIR=$(git rev-parse --absolute-git-dir)
YAPF_VENV=${YAPF_VENV:-${GIT_DIR}/fmt/yapf_${YAPF_VERSION}_venv}
if [ ! -e ${YAPF_VENV} ]
then
- python3 -m virtualenv ${YAPF_VENV}
+ python3 -m ${VENV_LIB} ${YAPF_VENV}
fi
source ${YAPF_VENV}/bin/activate
- pip install -q --upgrade pip
- pip install -q "yapf==${YAPF_VERSION}"
+ ${PIP_CMD} install -q --upgrade pip
+ ${PIP_CMD} install -q "yapf==${YAPF_VERSION}"
ver=$(yapf --version 2>&1)
if [ "$ver" != "$VERSION" ]