This page gives you how to install the development environment on a Linux based distro
Check python version by running command: python --version This project uses 2.7.*
Open your Terminal by pressing: ctlr+ alt + t. Follow the steps now:
1. To update the list of packages present on your system.
$ sudo apt-get update
2. The following command installs git(version control), nodejs, npm (node packet manager), python-pip (python packet manager), python-dev.
You only need to know git basics for the installation phase. To learn git, try https://try.github.io/ & or watch this video https://www.youtube.com/watch?v=0fKg7e37bQE
$ sudo apt-get install -y git nodejs nodejs-legacy npm python-pip python-dev
3. Next we need to install Postgres. Postgres is being used to serve as the database. (Similar to MySQL, SQLite).
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
This command downloads the Postgres repository for your distribution version. Try typing lsb_release -cs in your terminal to identify your distribution.
$ sudo apt-get install wget ca-certificates $ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - $ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get install postgresql-9.4 pgadmin3
If you by chance installed postgres 9.3, use this link to updgrade postgres to 9.4: https://medium.com/@tk512/upgrading-postgresql-from-9-3-to-9-4-on-ubuntu-14-04-lts-2b4ddcd26535#.zeuu46oyk
4. Install bower. Bower is a front-end dependency manager on the likes of npm, pip.
$ sudo npm install bower
5. Create a user and database for Postgres
$ sudo -u postgres createuser -d -w <os_username> $ createdb -E UTF-8 crowdsource_dev
6. Fork our repository to your github and clone your fork to your local machine:
7. cd to the directory where you cloned the repositiory and install bower components.
$ cd crowdsource-platform $ bower install
8. Create the database config file. What the following command does is to make a copy of an already exisiting database (default) file. Our copied file will be used by the database.
$ cp local_settings_default.py local_settings.py
9. It is recommended to proceed further using a virtual environment. If you don't wish to create, skip this step. Reason for using it:
Suppose, you created a project `abc` which uses some module `x` whose current version = 2.6. So at that time you installed 'x' module v.2.6 on your system globally.
After some months, 'x' module updated to 2.9.1, and now if you create another project `xyz`, which also contains the 'x' module, sudo pip install 'x' fetches the latest version and installed it on your system.
Now when you try to run `abc`, you start seeing some errors. These errors arise because your 'abc' dependencies use the previous version of 'x' module and 'x' module now corresponds to the latest version. That is why you use a virtual enviroment. In our case we will use virtualenv. virtualenv will create a virtual environment with core python installed. You can then start that virtual environment and install packages there. The packages installed there will go that venv's folder, therefore creating a isolated environment, not harming your global installation of python packages.
$ sudo pip install virtualenv $ pwd
pwd or present working directory is used to tell you where you currently are. Make sure you are inside the crowdsource-platform folder.
$ virtualenv venv $ source venv/bin/activate
source venv/bin/activate activates the virtual environment. To deactivate use type deactivate.
Your bash prompt $: will change to this (venv) $:
10. Install python packages
$ pip install -r requirements.txt
11. Migrate your database:
$ python manage.py makemigrations oauth2_provider $ python manage.py migrate $ python manage.py makemigrations $ python manage.py migrate
12. Finally, run your server and you should be able to reach it under localhost:8000:
$ python manage.py runserver 0.0.0.0:8000