From 47ef8b9cac4cbf80fe516f262f733a36bebf3b42 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 19 Jul 2021 15:13:30 -0400 Subject: [PATCH] Upgrade script now looks for Python path as env var --- docs/installation/3-netbox.md | 6 ++++++ docs/installation/upgrading.md | 7 +++++++ upgrade.sh | 7 ++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/installation/3-netbox.md b/docs/installation/3-netbox.md index 589fb8c29..f34ab3f0d 100644 --- a/docs/installation/3-netbox.md +++ b/docs/installation/3-netbox.md @@ -223,6 +223,12 @@ Once NetBox has been configured, we're ready to proceed with the actual installa sudo /opt/netbox/upgrade.sh ``` +Note that Python 3.7 or later is required for NetBox v3.0 and later releases. If the default Python installation on your server does not meet this requirement, you'll need to install Python 3.7 or later separately, and pass the path to the support installation as an environment variable named `PYTHON`. (Note that the environment variable must be passed _after_ the `sudo` command.) + +```no-highlight +sudo PYTHON=/usr/bin/python3.7 /opt/netbox/upgrade.sh +``` + !!! note Upon completion, the upgrade script may warn that no existing virtual environment was detected. As this is a new installation, this warning can be safely ignored. diff --git a/docs/installation/upgrading.md b/docs/installation/upgrading.md index ba72225d4..9854afeb4 100644 --- a/docs/installation/upgrading.md +++ b/docs/installation/upgrading.md @@ -75,6 +75,13 @@ Once the new code is in place, verify that any optional Python packages required sudo ./upgrade.sh ``` +!!! warning + If the default version of Python is not at least 3.7, you'll need to pass the path to a supported Python version as an environment variable when calling the upgrade script. For example: + + ```no-highlight + sudo PYTHON=/usr/bin/python3.7 ./upgrade.sh + ``` + This script performs the following actions: * Destroys and rebuilds the Python virtual environment diff --git a/upgrade.sh b/upgrade.sh index c4d948e20..6ac8d6122 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -2,8 +2,13 @@ # This script will prepare NetBox to run after the code has been upgraded to # its most recent release. +# This script will invoke Python with the value of the PYTHON environment +# variable (if set), or fall back to "python3". Note that NetBox v3.0+ requires +# Python 3.7 or later. + cd "$(dirname "$0")" VIRTUALENV="$(pwd -P)/venv" +PYTHON="${PYTHON:-python3}" # Remove the existing virtual environment (if any) if [ -d "$VIRTUALENV" ]; then @@ -15,7 +20,7 @@ else fi # Create a new virtual environment -COMMAND="python3 -m venv ${VIRTUALENV}" +COMMAND="${PYTHON} -m venv ${VIRTUALENV}" echo "Creating a new virtual environment at ${VIRTUALENV}..." eval $COMMAND || { echo "--------------------------------------------------------------------"