Skip to content

Commit

Permalink
Check Python version before proceeding (<=3.8)
Browse files Browse the repository at this point in the history
  • Loading branch information
samayer12 committed Dec 28, 2021
1 parent 28d4e21 commit 0a87ceb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ We assume you have unlimited access to the following when using this dataset: ic

# Quick Start

Execute `scripts/setup.sh`.
Execute `scripts/setup.sh` from the project root.
This script creates the virtualenvironment and prints an example invocation of the program for local testing.
Failure to exeucte this script from the project root will **not** detect the current version of Python.

# Data Processing

Expand Down
25 changes: 24 additions & 1 deletion scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
#!/bin/bash
MIN_PYTHON_VER=3.8

source scripts/vercomp.sh

cd app/ 2>/dev/null || true

version=$(python -V 2>&1 | grep -Po '(?<=Python )(.+)')
if [[ -z "$version" ]]
then
echo "No Python detected"
exit 1
fi

echo "Detected python version: $version."

vercomp "$version" $MIN_PYTHON_VER # Return codes: 0 is equal, 1 is greater, 2 is less

COMPARISON_CODE=$?
if [ $COMPARISON_CODE -eq 2 ];
then
echo "Current Python versions is less than required ($MIN_PYTHON_VER)."
echo "Please upgrade your python version."
exit 1
fi

echo "Creating virtual environment in: $(pwd)"
python3 -m pip install --user virtualenv
virtualenv venv --python=python3
source venv/bin/activate
pip install -r requirements.txt
echo "If running locally, try sudo -E venv/bin/python3 src/main.py recipes log.txt"
echo "If running locally, try: sudo -E venv/bin/python3 src/main.py recipes log.txt"

0 comments on commit 0a87ceb

Please sign in to comment.