Euler source The code that runs the solver shell and this site, version 4.34.2 Repository on GitHub

Upgrade pip and the named packages in the active virtualenv.

22 lines of Bash Raw file Open on GitHub

#!/usr/bin/env bash
# Upgrade pip and the named packages in the active virtualenv.

set -e  # Exit on error

upgrade() {
    cd "$(git rev-parse --show-toplevel)"
    [[ -z "${VIRTUAL_ENV}" ]] && {
        echo "Error: Not in a Python virtual environment. Please activate your venv first."
        exit 1
    }
    python3 -c "import sys; raise SystemExit(0 if sys.prefix != sys.base_prefix else 1)" || {
        echo "Error: Not in a Python virtual environment. Please activate your venv first."
        exit 1
    }
    python3 -m pip install --upgrade pip
    python3 -m pip install --upgrade "$@"
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
    upgrade "$@"
fi