-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
99 lines (58 loc) · 2.7 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
Setup
=====
1. Install virtualenv/pip
Sample install on Mac OS X:
$ curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
$ chmod +x virtualenv.py
$ sudo mv virtualenv.py /usr/local/bin
For more about virtualenv and pip (the Python package manager/installer):
http://www.pip-installer.org/en/latest/installing.html
2. Set up the environment
After cloning the repository, use virtualenv to create an isolated Python environment for the project (this is similar in concept to using rvm to create isolated configurations for Rails apps).
Make sure you are INSIDE the project directory when you run this command:
$ virtualenv.py venv --distribute
The .gitignore file is configured to ignore the venv directory in the project, as it is specific to your local environment.
3. Activate the environment
Every time you wish to do development/testing, run this in the Terminal:
$ source venv/bin/activate
This will modify your environment so it will use the project-specific isolated configuration in venv.
4. Install the dependencies
Now install the specified dependencies using pip:
$ pip install -r requirements.txt
Migrations
==========
To apply any database migrations, after activating the environment, run:
$ yoyo-migrate apply ./migrations/ postgres://superuser@localhost/data25c_development
Replace the database url if necessary. For deployments:
$ heroku run yoyo-migrate --verbosity=3 -b apply ./migrations \$DATABASE_URL --app data25c-stage
Replace app as necessary
Testing
=======
In the root of the project folder, execute the following command (don't forget to activate the environment variables as described above in step 3):
PYTHON_ENV=test python -m unittest discover
This will set the PYTHON_ENV variable for just the execution of the tests. The "discover" command will crawl through the current folder looking for tests, importing all the packages it finds along the way.
Ubuntu 12.10 setup
==================
#### REQUIREMENTS ####
$ sudo apt-get install build-essential
$ sudo apt-get install libxml2-dev
$ sudo apt-get install libxslt1-dev
$ sudo apt-get install python2.7-dev
$ sudo apt-get install python-setuptools
$ sudo apt-get install python-pkg-resources
$ sudo apt-get install python-pip
$ sudo pip install virtualenv
$ cd data25c/
$ virtualenv venv --distribute
$ source venv/bin/activate
$ pip install -r requirements.txt
create datatabases!
### DATABASE CONFIGURATION ###
In postgresql.conf:
listen_addresses = '*'
max_prepared_transactions = 10
In pg_hba.conf:
# IPv4 section
host all all 0.0.0.0/0 md5
### RUN MIGRATIONS ###
$ yoyo-migrate apply ./migrations/ postgres://<user>:<password>@localhost:5432/data25c_development