#!/bin/sh

set -e

. ./support_functions.sh

DIRECTORY='.venv'

cd "$(dirname "$0")"

REPO="$1"

cd "../../$REPO"

if [ -f lock ]; then
  warn "skipped because 'lock' file exists"
else
  virtualenv -q "$DIRECTORY"
  echo "Updating $REPO..."
  outputfile=$(mktemp -t update-pip.XXXXXX)
  trap "rm -f '$outputfile'" EXIT

  . $DIRECTORY/bin/activate

  if ! pip install --upgrade setuptools >"$outputfile" 2>&1; then
    error "failed to upgrade setuptools with pip output:"
    cat "$outputfile"
    exit 1
  fi

  if pip install -r requirements.txt >"$outputfile" 2>&1; then
    ok "ok"
  else
    error "failed to install dependencies with pip output:"
    cat "$outputfile"
    exit 1
  fi
fi

#!/bin/sh

set -e

. ./support_functions.sh

run_pip_install () {
  $DIRECTORY/bin/pip install -qr requirements.txt
}

DIRECTORY='.venv'

cd "$(dirname "$0")"

REPO="$1"

cd "../../$REPO"

if [ -f lock ]; then
  warn "skipped because 'lock' file exists"
else
  virtualenv -q "$DIRECTORY"
  echo "Updating $REPO..."
  outputfile=$(mktemp -t update-pip.XXXXXX)
  trap "rm -f '$outputfile'" EXIT

  if $(run_pip_install) >"$outputfile" 2>&1; then
    ok "ok"
  else
    error "failed with pip output:"
    cat "$outputfile"
    exit 1
  fi
fi

--- 
+++ 
@@ -3,6 +3,10 @@
 set -e
 
 . ./support_functions.sh
+
+run_pip_install () {
+  $DIRECTORY/bin/pip install -qr requirements.txt
+}
 
 DIRECTORY='.venv'
 
@@ -20,18 +24,10 @@
   outputfile=$(mktemp -t update-pip.XXXXXX)
   trap "rm -f '$outputfile'" EXIT
 
-  . $DIRECTORY/bin/activate
-
-  if ! pip install --upgrade setuptools >"$outputfile" 2>&1; then
-    error "failed to upgrade setuptools with pip output:"
-    cat "$outputfile"
-    exit 1
-  fi
-
-  if pip install -r requirements.txt >"$outputfile" 2>&1; then
+  if $(run_pip_install) >"$outputfile" 2>&1; then
     ok "ok"
   else
-    error "failed to install dependencies with pip output:"
+    error "failed with pip output:"
     cat "$outputfile"
     exit 1
   fi
Upgrade setuptools before trying to install pip dependencies
