aboutsummaryrefslogtreecommitdiff
path: root/docs/development.md
blob: a4eb32133d9368e067ac487cf6333c0cb23ec47f (plain)
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
# Developing patchwork

## Using virtualenv

It's a good idea to use virtualenv to develop Python software. Virtual
environments are "instances" of your system Python, without any of the
additional Python packages installed. They are useful to develop and deploy
patchwork against a "well known" set of dependencies, but they can also be
used to test patchwork against several versions of Django.

1. Install pip, virtualenv (python-pip, python-virtualenv packages)

   Because we're going to recompile our dependencies, we'll also need
   development headers. For the MySQL/MariaDB setups these are
   `mariadb-devel` (Fedora), `libmysqlclient-dev` (Debian)

2. Create a new virtual environement.

   Inside a virtual env, we'll just install the dependencies needed for
   patchwork and run it from there.

       $ virtualenv django-1.8

   This will create a virtual env called 'django-1.8' in eponymous directory.

3. Activate a virtual environment

       $ source django-1.8/bin/activate
       (django-1.8)$

   The shell prompt is preprended with the virtual env name.

4. Install the required dependencies

   To ease this task, it's customary to maintain a list of dependencies in a
   text file and install them in one go. One can maintain such a list of
   dependencies per interesting configuration.

       (django-1.8)$ pip install -r docs/requirements-dev.txt

   You will also need to install a version of Django - we don't install this
   by default to allow development against multiple versions of Django. This
   can be installed like so (assuming Django 1.8):

       (django-1.8)$ pip install 'django<1.9,>=1.8'

   Of course, this is a one-time step: once installed in the virtual
   environment there is no need to to install requirements again.

5. Run the development server

       (django-1.8)$ ./manage.py --version
       1.8
       (django-1.8)$ ./manage.py runserver

Once finished, you can kill the server (`Ctrl` + `C`) and exit the the virtual
environment:

    (django-1.8)$ deactivate
    $

Should you wish to re-enter this environment, simply source the `activate`
script again.

## Running Tests

patchwork includes a [tox] script to automate testing. Before running this, you
should probably install tox:

    $ pip install tox

You can show available
targets like so:

    $ tox --list

You'll see that this includes a number of targets to run unit tests against the
different versions of Django supported, along with some other targets related
to code coverage and code quality. To run these, use the `-e` parameter:

    $ tox -e py27-django18

In the case of the unit tests targets, you can also run specific tests by
passing the fully qualified test name as an additional argument to this
command:

    $ tox -e py27-django18 patchwork.tests.SubjectCleanUpTest

Because patchwork support multiple versions of Django, it's very important
that you test against all supported versions. When run without argument, tox
will do this:

    $ tox

[tox]: https://tox.readthedocs.org/en/latest/