Skip to content

Latest commit

 

History

History
89 lines (59 loc) · 2.87 KB

set-up-project-mac.md

File metadata and controls

89 lines (59 loc) · 2.87 KB

Run BikeMaps.org locally on a Mac

This doc summarizes setting up BikeMaps locally for project development on a mac.

Clone (copy) the BikeMaps repo

Learn more about cloning here or enter the desired directory in your terminal and run:

git clone https://github.com/SPARLab/BikeMaps.git

Install Python 3

Instructions for a system install of Python 3 here

I prefer using pyenv to manage python versions and am using 3.6.1 for this project. Using homebrew to install:

brew update
brew install pyenv
pyenv install 3.6.1

More docs on pyenv here.

To see which python versions are downloaded and available to pyenv: pyenv versions

To switch versions: pyenv global 3.6.1

To see current python path: which python

Set up virtual environment

It is advisable to run a python virtual environment for the BikeMaps.org project. This guarantees an isolated context for your python version and dependencies, which avoids issues with conflicts between this project and your other projects or your system.

venv is the newer version of virtualenv that ships with python3, so it doesn't need to be installed.

Virtual environments can be stored in their own directory separate from the projects they are associated with. To create one if it doesn't already exist:

mkdir /Users/your-username/virtualenvs && cd $_

Create and activate a new venv for the bikemaps project:

python -m venv bikemaps_venv
. bikemaps_venv/bin/activate

Verify the environment has the correct python version: python -V

To exit the venv: deactivate

Set up database

I've found the easiest way to run a PostgreSQL server is with Postgres.app.

Once the server is running using PostgreSQL 13, create the bikemaps database with 'postgres' as the user:

createdb -U postgres bikeDB

Verify you can connect to the database: psql -U postgres -d bikeDB

View tables: \dt+

Exit: \q

Postgres.app includes the postgis extension out of the box, but if necessary install with: psql -U postgres -d bikeDB -c "CREATE EXTENSION postgis;"

Run Django project

From the BikeMaps project directory with the virtual environment activated, install the requirements with the most recent version of pip.

pip install --upgrade pip
pip install -r requirements.txt

Generate and run migrations to add all database tables:

./manage.py makemigrations
./manage.py migrate

Start the development server at 127.0.0.1:8000 and visit in a web browser.

./manage.py runserver

Exit with ctrl-c.

To access the admin page, create a superuser account to log in with.

./manage.py createsuperuser