-
Notifications
You must be signed in to change notification settings - Fork 15
Windows Development Environment Setup
Han Lin edited this page Oct 11, 2015
·
9 revisions
This page provides instructions on how to setup a Microsoft Visual Studio 2015 development environment on Windows 10 64-bit.
- Make sure you have administrator rights on the machine.
- Install Git
- Download: http://git-scm.com/downloads
- Download django-blast to a location of your choice, we will use
D:\as an example in the following steps.- Right click on
D:\, click on Git bash - Run
git clone https://github.com/hotdogee/django-blast.git, this creates a new directoryD:\django-blast\and downloads the application into it.
- Right click on
- Install PostgreSQL server 9.4.x 64-bit
- Download: http://www.enterprisedb.com/products-services-training/pgdownload
- During installation you will needs to set a password for the
postgressuperuser, and a connection port (default: 5432) which will be needed in later steps. - Create a user and a database for django-blast, as an example, we will create a user
django, a databasedjango_blast, and grant all privileges ondjango_blasttodjangousing the command line toolpsql.- Start Menu -> All programs -> PostgreSQL 9.3 -> SQL Shell (psql)
- Log in, accept the default values by pressing
enter, and give it the password forpostgres. - After logging in, you should see the command prompt
postgres=#. Run the following three commands, and change 'myPassword' to something else:
CREATE USER django WITH PASSWORD 'myPassword'; CREATE DATABASE django_blast; GRANT ALL PRIVILEGES ON DATABASE django_blast TO django; \c django_blast CREATE EXTENSION IF NOT EXISTS hstore;
1. Install Python 2.7.x 64-bit (Does not work with Python 3.x)
* Download: https://www.python.org/ftp/python/2.7.10/python-2.7.10.amd64.msi
* The default installation location is `C:\Python27`, if you do not use the default, modify all following steps accordingly.
* Choose to install "pip" and "Add python.exe to Path" during the Python Setup
* Install pip if you didn't install it during Python Setup
* Download get-pip.py: https://bootstrap.pypa.io/get-pip.py
* Run `C:\Python27\python get-pip.py`
* `pip.exe` should now be in `C:\Python27\Scripts`
* Make sure `C:\Python27` and `C:\Python27\Scripts` are in your PATH. If you didn't choose "Add python.exe to Path" during Python Setup, you can run a script included with python that automatically does this: `C:\Python27\Tools\Scripts\win_add2path.py`
* Install `virtualenv`
* `pip install virtualenv`
* Learn more: http://docs.python-guide.org/en/latest/dev/virtualenvs/
* Create a python 2.7 virtual environment under `D:\django-blast\virtualenv`
* Note: if your path to `virtualenv` has spaces in it, you’ll need to `pip install win32api`
D: cd D:\django-blast\virtualenv virtualenv py2.7 --python=C:\Python27\python.exe
* Install django-blast requirements.txt in the virtualenv
* `psycopg2` will fail to compile in Windows, comment or remove it in the `requirements.txt` file. We'll manually install the compiled binary package later.
cd D:\django-blast virtualenv\py2.7\Scripts\activate pip install -r requirements.txt
1. Install psycopg2, the PostgreSQL database adapter for python
* Download the correct version (psycopg2‑2.6.1‑cp27‑none‑win_amd64.whl) from: http://www.lfd.uci.edu/~gohlke/pythonlibs/#psycopg
* Install psycopg2 in the virtualenv
virtualenv\py2.7\Scripts\activate pip install psycopg2‑2.6.1‑cp27‑none‑win_amd64.whl
* Note: `pip install psycopg2` requires a correctly configured C compiler, since psycopg2 is a C extension module. Installing the compiled binary is much simpler.
1. Install Erlang/OTP 64-bit
* This is required for RabbitMQ server
* Download: http://www.erlang.org/download.html
1. Install RabbitMQ server
* Download: http://www.rabbitmq.com/download.html
* Start the RabbitMQ service after installation
* http://technet.microsoft.com/en-us/library/cc736564(v=ws.10).aspx
1. Start a celery worker
* celery workers pulls tasks from RabbitMQ and runs them
* You can start a worker manually using: `celery -A i5k worker --loglevel=info`
* Once you confirm the worker is running, you can schedule it to start automatically when Windows starts using the built in Task Scheduler so you don't have to manually start it every time the server reboots
* http://windows.microsoft.com/en-us/windows/schedule-task
* http://www.calazan.com/windows-tip-run-applications-in-the-background-using-task-scheduler/
1. Configure django-blast
* Assuming you downloaded to `D:\`
* Create a file `D:\django-blast\i5k\secret_key` and put some random characters in it, example: `n(bd1f1c%e8=_xad02x5qtfn%wg2pi492e$8_erx+d)!tpeoim`
* Modify the file `D:\django-blast\i5k\settings.py`
* Change `USE_PROD_SETTINGS = True`
* Modify the file `D:\django-blast\i5k\settings_prod.py`
* Change `ALLOWED_HOSTS` and `DATABASES`: https://docs.djangoproject.com/en/1.7/ref/settings/
* Initialize the database and collect static files:
virtualenv\py2.7\Scripts\activate python manage.py migrate python manage.py collectstatic
* Create a superuser account, we will use this account to log in to the website later
python manage.py createsuperuser
1. Test using django's built in web server
* make sure we got everything working so far
virtualenv\py2.7\Scripts\activate python manage.py runserver
* Check if the page `http://127.0.0.1:8000/blast` loads, CTRL-BREAK to quit.
1. Install Visual Studio Community 2015
* Download: https://www.visualstudio.com/products/visual-studio-community-vs
* Open the Visual Studio Solution file: i5k.sln