From 34e27cd231d2eb2c3617129f805ea1728bfb804b Mon Sep 17 00:00:00 2001 From: "Michael A. Smith" Date: Mon, 15 Apr 2024 21:11:57 -0400 Subject: [PATCH] AVRO-3952: Auto-install tox --- lang/py/build.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lang/py/build.sh b/lang/py/build.sh index 000e048cfd6..369b8aa69f9 100755 --- a/lang/py/build.sh +++ b/lang/py/build.sh @@ -55,7 +55,7 @@ doc() { local doc_dir local version=$(cat ../../share/VERSION.txt) doc_dir="../../build/avro-doc-$version/api/py" - python3 -m tox -e docs + _tox -e docs mkdir -p "$doc_dir" cp -a docs/build/* "$doc_dir" } @@ -72,11 +72,11 @@ interop-data-test() { } lint() { - python3 -m tox -e lint + _tox -e lint } test_() { - TOX_SKIP_ENV=lint python3 -m tox --skip-missing-interpreters + TOX_SKIP_ENV=lint _tox --skip-missing-interpreters } main() { @@ -95,4 +95,16 @@ main() { done } +_tox() { + if command -v tox 2> /dev/null; then + tox "$@" + else + echo 'Your experience will improve if you install tox' + virtualenv="$(mktemp -d)" + python3 -m venv "$virtualenv" + "$virtualenv/bin/python3" -m pip install tox + "$virtualenv/bin/tox" "$@" + fi +} + main "$@"