Version 13 (modified by solomonr, 10 months ago)

--

Development Environment Setup

Table of Contents

  1. 1. Install a C compiler and native libraries
    1. On Mac
    2. On Ubuntu
  2. 2. Setup database
  3. 3. Get source code
  4. 4. Install Python libraries
  5. 5. Django
  6. 6. Other misc

Assumes you are putting all this code in PROJECT_DIR

1. Install a C compiler and native libraries

On Mac

  • install Xcode (from app store)
  • install HomeBrew (from ruby script via HomeBrew project homepage)
  • then:
      brew install postgresql
      brew install geos
      brew install proj
      brew install postgis
      brew install gdal
      brew install libgeoip
    

that's all based on the instructions at:  https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#macports

On Ubuntu

These instructions are pretty thorough and helpful:

 https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/

On our staging server we followed these instructions since it is running Ubuntu 10.04:

 https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#through-11-04

2. Setup database

  • then ran:
      initdb /usr/local/var/postgres
    
  • had trouble running createdb because Mac OSX Lion now, apparently, comes with it's own Postgres installed, and, while initdb and pg_ctl were running the HomeBrew versions, for some reason createdb was defaulting to the pre-packaged Max OSX version. To fix this I simply modified my path in .bashrc to put /usr/local/bin before all others.
  • Finally, after that, was able to create a spatial database based on the GeoDjango documentation instructions:

 https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#creating-a-spatial-database-template-for-postgis

Note: this file is located in our project repository at: urt/etc/sh/create_template_postgis-1.5.sh

  • created a database for URT:
    createdb -T template_postgis urt
    

3. Get source code

  • cd PROJECT_DIR
  • then did a git clone, which now includes bootstrap.py git instructions

something like: git clone rorys@rorys.webfactional.com:webapps/urt_src/repos/urt.git

4. Install Python libraries

  • cd PROJECT_DIR/urt/trunk/
  • ran python bootstrap.py, which created ./bin/buildout
  • ran ./bin/buildout, which created all the buildout stuff including project dependencies (psycopg2, south, PIL, ) and etc

5. Django

  • cp urt/local_settings.sample.py urt/local_settings.py
  • edit PROJECT_DIR/urt/trunk/urt/local_settings.py - Probably all you need to change is the database username
  • run ./bin/django syncdb and ./bin/django migrate to create the project data model
  • and finally: ./bin/django runserver

6. Other misc