Skip to content

Developer Installation

Clayton Burlison edited this page Aug 21, 2019 · 10 revisions

Setting up Sal for Development

Introduction

These instructions were written to document one collaborator's setup prior to development (macOS 10.12.3). Setup on your machine may be different. If things don't work, please ask!

Prerequisites

First, satisfy a couple of requirements:

  1. Install Python 3.7+ (homebrew, python.org, etc)

  2. If you don't have pip install it with:

    sudo easy_install pip3
  3. If you don't already have virtualenv:

    • As of 10.11 or later SIP protects the /Library/Python/2.7/site-packages directory so you must install with the --user flag which will install the package to $HOME/Library/Python/2.7/bin by default. Install with:

       pip3 install --user virtualenv
    • You will also want to add the above to your shell PATH. Changes might be required if you are not using the bourne again shell (bash) shell.

       echo export PATH="\$PATH:\$HOME/Library/Python/2.7/bin" | tee -a $HOME/.bash_profile
       echo export PATH="\$PATH:\$HOME/Library/Python/3.7/bin" | tee -a $HOME/.bash_profile
  4. (Kind of optional) Grab the latest PostgreSQL installer for your platform from http://www.postgresql.org/download. Development can use the sqlite3 default database, but the python packages won't install without postgresql available.

Python Setup

  1. If you are intending on sending pull requests to the project, fork Sal on GitHub.

  2. Clone your fork or the master repo

    git clone <your fork's URL>
  3. Set up a virtual environment for Sal.

    1. cd <sal repository folder>
    2. virtualenv -p python3.7 sal_env
  4. Activate the virtual environment: source sal_env/bin/activate (For Bash shell)

  5. Install python package dependencies.

    1. pip3 install -r requirements.txt
    • If the the cryptography package fails because it was already installed on your system. Editing <projectdir>/setup/requirements.txt to remove the version number supplied with the cryptography package and re-running the pip install command.
    • Even though development will just use the sqlite database, the psycopg2 package needs PostgreSQL installed. After installation it was not the path, so a PATH=$PATH:/Library/PostgreSQL/ added the install directory with pg_config to the path and allowed pip to finish installing the dependencies.

Config Setup

We need to set up the development configuration.

  1. Copy the example_settings.py file to be the active settings.py file: cp sal/example_settings.py sal/settings.py. This configures sqlite as our database.
  2. settings.py imports system_settings.py. Edit settings.py to override the following items as needed (look at their default definitions in system_settings.py -- put your modifications in settings.py):
    1. Set DEBUG = True to enable debug mode.
    2. Set ADMINS to an administrative name and email
    3. Set TIME_ZONE to the appropriate timezone
    4. Set DISPLAY_NAME to what you want the header to be
    5. This is enough to get you going. See Settings for more options in detail.

Database Config

  1. python manage.py makemigrations
  2. python manage.py migrate
  3. python manage.py collectstatic
  4. Create the admin user: python manage.py createsuperuser

Moment of Truth

  1. Start Sal in debug mode with python manage.py runserver
  2. Visit http://127.0.0.1:8000 in your web browser.
Clone this wiki locally