Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Enable support for python repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Gladhill authored and whoojemaflip committed Apr 5, 2017
1 parent e83729c commit b78ebcc
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
6 changes: 6 additions & 0 deletions development-vm/README.md
Expand Up @@ -67,6 +67,11 @@ to install them:
dev$ cd /var/govuk/development
dev$ ./update-bundler.sh

There are a handful of Python apps which use [PIP][pip].
You will probably need to install these dependencies too, so run:

dev$ ./update-pip.sh

For many apps, they won't be usable until you create a user by hand in their
database, or grab a copy of production data (see below).

Expand All @@ -77,6 +82,7 @@ be able to ignore some errors.
dev$ PROC_COUNT=1 ./update-bundler.sh

[bundler]: http://bundler.io/rationale.html
[pip]: https://pip.pypa.io/en/stable/

## 4. Running the apps

Expand Down
1 change: 1 addition & 0 deletions development-vm/update-all.sh
Expand Up @@ -5,3 +5,4 @@ cd $( dirname "${BASH_SOURCE[0]}" )
./update-git.sh
govuk_puppet
./update-bundler.sh
./update-pip.sh
69 changes: 69 additions & 0 deletions development-vm/update-pip.sh
@@ -0,0 +1,69 @@
#!/bin/sh

set -e
cd "$(dirname "$0")"

ANSI_GREEN="\033[32m"
ANSI_RED="\033[31m"
ANSI_YELLOW="\033[33m"
ANSI_RESET="\033[0m"
ANSI_BOLD="\033[1m"

ok () {
start "$REPO"
echo "${ANSI_GREEN}${@}${ANSI_RESET}" >&2
}

error () {
start "$REPO"
echo "${ANSI_RED}${@}${ANSI_RESET}" >&2
}

start () {
local repo="$1"
repo=$(truncate 25 "$repo")
printf "${ANSI_BOLD}%-25s${ANSI_RESET} " "$repo" >&2
}

truncate () {
local len="$1"
local str="$2"
if [ "${#str}" -gt "$len" ]; then
printf "$str" | awk "{ s=substr(\$0, 1, $len-3); print s \"...\"; }"
else
printf "$str"
fi
}

DIRECTORY='.venv'

find_pip_repos () {
ls -d ../*/requirements.txt | cut -d/ -f2
}

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

for REPO in $(find_pip_repos)
do
cd "../$REPO"

virtualenv -q "$DIRECTORY"

if [ -f lock ]; then
warn "skipped because 'lock' file exists"
else
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
done

0 comments on commit b78ebcc

Please sign in to comment.