- which goimports >/dev/null || go get golang.org/x/tools/cmd/goimports || fatal "Go setup failed"
-
- setup_virtualenv "$VENVDIR" --python python2.7
- . "$VENVDIR/bin/activate"
-
- # Needed for run_test_server.py which is used by certain (non-Python) tests.
- (
- set -e
- "${VENVDIR}/bin/pip" install PyYAML
- "${VENV3DIR}/bin/pip" install PyYAML
- cd "$WORKSPACE/sdk/python"
- python setup.py install
- ) || fatal "installing PyYAML and sdk/python failed"
-
- # Deactivate Python 2 virtualenv
- deactivate
-
- # If Python 3 is available, set up its virtualenv in $VENV3DIR.
- # Otherwise, skip dependent tests.
- PYTHON3=$(which python3)
- if [[ ${?} = 0 ]]; then
- setup_virtualenv "$VENV3DIR" --python python3
- else
- PYTHON3=
- cat >&2 <<EOF
-
-Warning: python3 could not be found. Python 3 tests will be skipped.
-
-EOF
- fi
+ which goimports >/dev/null || go install golang.org/x/tools/cmd/goimports@latest || fatal "Go setup failed"
+
+ setup_virtualenv "$VENV3DIR"
+ . "$VENV3DIR/bin/activate"
+
+ # PyYAML is a test requirement used by run_test_server.py and needed for
+ # other, non-Python tests.
+ # pdoc is needed to build PySDK documentation.
+ # We run `setup.py build` first to generate _version.py.
+ env -C "$WORKSPACE/sdk/python" python3 setup.py build \
+ && python3 -m pip install "$WORKSPACE/sdk/python" \
+ && python3 -m pip install PyYAML pdoc \
+ || fatal "installing Python SDK and related dependencies failed"