Skip to content

Commit

Permalink
script/bootstrap: modify for use beyond Vagrant
Browse files Browse the repository at this point in the history
This adds a `--vagrant` swtich to be used along with the Vagran box,
and also ensures that the `media/` directory has been created.
  • Loading branch information
sagepe committed Nov 12, 2020
1 parent d8b9c40 commit d3a4ab6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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', '[email protected]', 'password')"
Expand Down
24 changes: 15 additions & 9 deletions script/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d3a4ab6

Please sign in to comment.