Skip to content

Instantly share code, notes, and snippets.

@mrpollo
Created October 7, 2024 17:57
Show Gist options
  • Save mrpollo/db8c5d52e63e82dee25c993d1d06d813 to your computer and use it in GitHub Desktop.
Save mrpollo/db8c5d52e63e82dee25c993d1d06d813 to your computer and use it in GitHub Desktop.
PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}')
REQUIRED_VERSION="3.11"
if [[ "$(printf '%s\n' "$REQUIRED_VERSION" "$PYTHON_VERSION" | sort -V | head -n1)" == "$REQUIRED_VERSION" ]]; then
python3 -m pip install --break-system-packages -r ${DIR}/requirements.txt
else
if [ -n "$VIRTUAL_ENV" ]; then
# virtual environments don't allow --user option
python -m pip install -r ${DIR}/requirements.txt
else
python3 -m pip install --user -r ${DIR}/requirements.txt
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment