Setting up a CSC development environment

These are Rob and Ken’s suggestions for how to set up your development environment to work on ConceptNet, Divisi, and related projects. Everyone has different preferences, so your mileage may vary.

Step 0: Prerequisites

Follow the Common Installation Instructions before these instructions.

Step 1: Get a virtual environment

virtualenv is a system that sets up an isolated Python environment for you to develop in. This is nice. It means when something breaks, you don’t have to try to pick the pieces out of your systemwide Python configuration; you can just make a fresh virtual environment. It also means less sudo.

You’ll need Setuptools for Python (otherwise known as easy_install) and the virtualenv package. If you’re using Ubuntu:

sudo aptitude install python-setuptools python-virtualenv

Otherwise, see the ConceptNet install instructions to get easy_install, then run:

easy_install virtualenv

Now set up a virtual environment. This command will create one called “csc” under your home directory:

virtualenv ~/csc

To activate the environment, you run this:

source ~/csc/bin/activate

You may want to add this to your .bashrc so that it runs by default when you start a shell. You can get back to your normal Python by typing deactivate.

Step 2: Set up Bazaar and Launchpad

Directions for installing and setting up Bazaar and Launchpad are in the Common Sense Computing and Bazaar section.

Make sure you register a public key with Launchpad, and then let the command line client know about your Launchpad username:

bzr launchpad-login myusername

Step 3: Get the packages

If you were merely using the packages, you’d easy_install them, but since you might want to change the code, branch them from Bazaar instead. Run this inside your ~/csc directory:

bzr co lp:csc-utils
bzr branch lp:conceptnet
bzr branch lp:divisi
bzr co lp:~commonsense/cscweb/documentation/

(I suggest branching ConceptNet and Divisi because you’ll more often make changes that break things there, but checkouts of csc-utils and this documentation should be fine.)

There are some other codebases you won’t be messing with, and which you will really want to be installed:

easy_install django
easy_install psycopg2
easy_install PyStemmer

Step 4: Install

For each package in (csc-utils, conceptnet, and divisi):

cd ~/csc/$package
python setup.py develop

Step 5: Test

Start up your ipython. Try importing csc.conceptnet4 and csc.divisi. Run some of the code in the “Examples” section. If it works, you’re all set.