From d3a4ab6474cf23a042f713446d83113f0b362fee Mon Sep 17 00:00:00 2001 From: Sam Pearson Date: Tue, 10 Nov 2020 10:30:25 +0000 Subject: [PATCH] script/bootstrap: modify for use beyond Vagrant This adds a `--vagrant` swtich to be used along with the Vagran box, and also ensures that the `media/` directory has been created. --- Vagrantfile | 3 ++- script/bootstrap | 24 +++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 667380cd7..641ec8bf8 100755 --- a/Vagrantfile +++ b/Vagrantfile @@ -83,7 +83,8 @@ Vagrant.configure(2) do |config| # Run bootstrap script to install the python packages we need # Then migrate the db, generate the sass, etc - script/bootstrap + script/bootstrap --vagrant + script/migrate # Create a superuser script/console -c "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', 'admin@example.com', 'password')" diff --git a/script/bootstrap b/script/bootstrap index 16b406637..b4e125e64 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -6,16 +6,22 @@ set -e # check that we are in the expected directory cd `dirname $0`/.. -# Upgrade pip to a secure version -curl -L -s https://bootstrap.pypa.io/get-pip.py | python3 +# create plans and media dirs +mkdir -p data/plans +mkdir -p media -pip3 install --requirement requirements.txt +if [ "$1" == "--vagrant" ]; then -# make sure that there is no old code (the .py files may have been git deleted) -find . -name '*.pyc' -delete + # We're running inside a Vagrant box, so provision accordingly. -# create plans dir -mkdir -p data/plans + export PYTHONDONTWRITEBYTECODE=1 + + # Upgrade pip to a secure version + curl -L -s https://bootstrap.pypa.io/get-pip.py | python3 + + pip3 install --requirement requirements.txt -# get the database up to speed -python3 manage.py migrate + # Belt-and-braces - there may be old code, since deleted, for which bytecode was generated + # before we set PYTHONDONTWRITEBYTECODE above. + find . -name '*.pyc' -delete +fi