From abea2c71721456abfb99f43e7727845ac8f86408 Mon Sep 17 00:00:00 2001 From: Dave Page Date: Mon, 3 Apr 2023 15:18:46 +0100 Subject: [PATCH] Add a script and Makefile targets for setting up Python environments. This is primarily intended for simplifying Jenkins jobs. --- Makefile | 8 +++++++- tools/setup-python-env.sh | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 tools/setup-python-env.sh diff --git a/Makefile b/Makefile index 01da1cab1..61dfd7807 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,13 @@ appbundle: ./pkg/mac/build.sh install-node: - cd web && yarn install && npm rebuild + cd web && yarn install + +install-python: + ./tools/setup-python-env.sh + +install-python-testing: + ./tools/setup-python-env.sh --test bundle: cd web && yarn run bundle diff --git a/tools/setup-python-env.sh b/tools/setup-python-env.sh new file mode 100755 index 000000000..772fe424d --- /dev/null +++ b/tools/setup-python-env.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +TEST=0 +if [ "$1" = "--test" ]; +then + TEST=1 +fi + +echo Creating a blank environment... +python3 -m venv venv || { echo 'ERROR: Failed to create the blank virtual env.' ; exit 1; } + +echo Activating the virtual environment... +. venv/bin/activate || { echo 'ERROR: Failed to activate the virtual env.' ; exit 1; } + +echo Installing requirements... +pip install --upgrade pip + +if [ ${TEST} -eq 1 ]; +then + echo Installing requirements for running Python tests... + pip install --no-cache-dir wheel sphinx sphinxcontrib-youtube -r web/regression/requirements.txt || { echo 'ERROR: Failed to install Python requirements.' ; exit 1; } +else + echo Installing requirements for executing and building only... + pip install --no-cache-dir wheel sphinx sphinxcontrib-youtube -r requirements.txt || { echo 'ERROR: Failed to install Python requirements.' ; exit 1; } +fi