This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 953e507248 Adds some more checks around Python tooling for YAPF
(#11755)
953e507248 is described below
commit 953e507248d623c5d9f512422dfa45d1e4c940f2
Author: Leif Hedstrom <[email protected]>
AuthorDate: Wed Sep 4 10:14:19 2024 -0700
Adds some more checks around Python tooling for YAPF (#11755)
---
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" ]