author | Lennard de Rijk <ljvderijk@gmail.com> |
Sat, 04 Jul 2009 15:59:19 +0200 | |
changeset 2534 | c880489123fc |
parent 2457 | eebf0c4ace3d |
child 2599 | 22e1ec7bd02a |
permissions | -rw-r--r-- |
2457
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
1 |
# -*- coding: utf-8 -*- |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
2 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
3 |
""" |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
4 |
Example Usage |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
5 |
============= |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
6 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
7 |
The following commands can be run from the root directory of the Mercurial |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
8 |
repo. To run ``paver``, however, you'll need to do ``easy_install Paver``. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
9 |
Most of the following commands accept other arguments; see ``command --help`` |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
10 |
for more information, or ``paver help`` for a list of all the valid commands. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
11 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
12 |
``paver build`` |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
13 |
Builds the project. This essentially just runs a bunch of other tasks, |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
14 |
like ``pylint``, ``django_zip`` and ``tinymce_zip``, etc. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
15 |
``paver pylint`` |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
16 |
Runs PyLint on the project. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
17 |
``paver django_zip`` |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
18 |
Builds the Django zip file. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
19 |
``paver tinymce_zip`` |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
20 |
Builds the TinyMCE zip file. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
21 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
22 |
If you specify ``--dry-run`` before a task, then the action of that task will |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
23 |
not actually be carried out, although logging output will be displayed as if |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
24 |
it were. For example, you could run ``paver --dry-run django_zip`` to see what |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
25 |
files would be added to the ``django.zip`` file, etc. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
26 |
""" |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
27 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
28 |
from cStringIO import StringIO |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
29 |
import sys |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
30 |
import zipfile |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
31 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
32 |
import paver |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
33 |
import paver.easy |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
34 |
import paver.tasks |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
35 |
from paver.easy import * |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
36 |
from paver.path import path |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
37 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
38 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
39 |
# Paver comes with Jason Orendorff's 'path' module; this makes path |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
40 |
# manipulation easy and far more readable. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
41 |
PROJECT_DIR = path(__file__).dirname() |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
42 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
43 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
44 |
# Set some default options. Having the options at the top of the file cleans |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
45 |
# the whole thing up and makes the behaviour a lot more configurable. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
46 |
options( |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
47 |
build = Bunch( |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
48 |
project_dir = PROJECT_DIR, |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
49 |
app_build = PROJECT_DIR / 'build', |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
50 |
app_folder = PROJECT_DIR / 'app', |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
51 |
app_files = ['app.yaml', 'cron.yaml', 'index.yaml', 'main.py', |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
52 |
'settings.py', 'shell.py', 'urls.py', 'gae_django.py'], |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
53 |
app_dirs = ['soc', 'ghop', 'gsoc', 'feedparser', 'python25src', |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
54 |
'reflistprop', 'jquery', 'ranklist', 'shell', 'json', |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
55 |
'htmlsanitizer', 'taggable-mixin', 'gviz'], |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
56 |
zip_files = ['tiny_mce.zip'], |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
57 |
skip_pylint = False, |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
58 |
) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
59 |
) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
60 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
61 |
# The second call to options allows us to re-use some of the constants defined |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
62 |
# in the first call. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
63 |
options( |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
64 |
clean_build = options.build, |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
65 |
tinymce_zip = options.build, |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
66 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
67 |
django_zip = Bunch( |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
68 |
prune_dirs = ['.svn', 'gis', 'admin', 'localflavor', 'mysql', |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
69 |
'mysql_old', 'oracle', 'postgresql', |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
70 |
'postgresql_psycopg2', 'sqlite3', 'test'], |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
71 |
**options.build |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
72 |
), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
73 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
74 |
pylint = Bunch( |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
75 |
check_modules = ['soc', 'reflistprop', 'settings.py', 'urls.py', |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
76 |
'main.py'], |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
77 |
quiet = False, |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
78 |
quiet_args = ['--disable-msg=W0511,R0401', '--reports=no', |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
79 |
'--disable-checker=similarities'], |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
80 |
pylint_args = [], |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
81 |
ignore = False, |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
82 |
**options.build |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
83 |
) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
84 |
) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
85 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
86 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
87 |
# Utility functions |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
88 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
89 |
def django_zip_files(django_src_dir): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
90 |
"""Yields each filename which should go into ``django.zip``.""" |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
91 |
for filename in django_src_dir.walkfiles(): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
92 |
# The following seems unnecessarily unreadable, but unfortunately |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
93 |
# it seems it cannot be unobfuscated any more (if someone finds a |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
94 |
# nicer way of writing it, please tell me). |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
95 |
if not (filename.ext in ['.pyc', '.pyo', '.po', '.mo'] or |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
96 |
any(name in filename.splitall() |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
97 |
for name in options.django_zip.prune_dirs)): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
98 |
# The filename is suitable to be added to the archive. In this |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
99 |
# case, we yield the filename and the name it should be given in |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
100 |
# the Zip archive. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
101 |
paver.tasks.environment.info( |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
102 |
'%-4sdjango.zip <- %s', '', filename) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
103 |
arcname = path('django') / django_src_dir.relpathto(filename) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
104 |
yield filename, arcname |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
105 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
106 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
107 |
def tinymce_zip_files(tiny_mce_dir): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
108 |
"""Yields each filename which should go into ``tiny_mce.zip``.""" |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
109 |
for filename in tiny_mce_dir.walkfiles(): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
110 |
if '.svn' not in filename.splitall(): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
111 |
# In this case, `tiny_mce/*` is in the root of the zip file, so |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
112 |
# we do not need to prefix `arcname` with 'tinymce/' (like we did |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
113 |
# with `django.zip`). |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
114 |
paver.tasks.environment.info( |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
115 |
'%-4stiny_mce.zip <- %s', '', filename) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
116 |
arcname = tiny_mce_dir.relpathto(filename) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
117 |
yield filename, arcname |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
118 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
119 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
120 |
def write_zip_file(zip_file_handle, files): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
121 |
if paver.tasks.environment.dry_run: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
122 |
for args in files: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
123 |
pass |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
124 |
return |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
125 |
zip_file = zipfile.ZipFile(zip_file_handle, mode='w') |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
126 |
for args in files: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
127 |
zip_file.write(*args) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
128 |
zip_file.close() |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
129 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
130 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
131 |
def symlink(target, link_name): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
132 |
if hasattr(target, 'symlink'): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
133 |
target.symlink(link_name) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
134 |
else: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
135 |
# If we are on a platform where symlinks are not supported (such as |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
136 |
# Windows), simply copy the files across. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
137 |
target.copy(link_name) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
138 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
139 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
140 |
# Tasks |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
141 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
142 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
143 |
@task |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
144 |
@cmdopts([ |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
145 |
('app-folder=', 'a', 'App folder directory (default /app)'), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
146 |
('pylint-command=', 'c', 'Specify a custom pylint executable'), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
147 |
('quiet', 'q', 'Disables a lot of the pylint output'), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
148 |
('ignore', 'i', 'Ignore PyLint errors') |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
149 |
]) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
150 |
def pylint(options): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
151 |
"""Check the source code using PyLint.""" |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
152 |
from pylint import lint |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
153 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
154 |
# Initial command. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
155 |
arguments = [] |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
156 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
157 |
if options.quiet: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
158 |
arguments.extend(options.quiet_args) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
159 |
if 'pylint_args' in options: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
160 |
arguments.extend(list(options.pylint_args)) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
161 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
162 |
# Add the list of paths containing the modules to check using PyLint. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
163 |
arguments.extend( |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
164 |
str(options.app_folder / module) for module in options.check_modules) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
165 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
166 |
# By placing run_pylint into its own function, it allows us to do dry runs |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
167 |
# without actually running PyLint. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
168 |
def run_pylint(): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
169 |
# Add app folder to path. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
170 |
sys.path.insert(0, options.app_folder.abspath()) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
171 |
# Add google_appengine directory to path. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
172 |
sys.path.insert(0, |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
173 |
options.project_dir.abspath() / |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
174 |
'thirdparty' / 'google_appengine') |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
175 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
176 |
# Specify PyLint RC file. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
177 |
arguments.append('--rcfile=' + |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
178 |
options.project_dir.abspath() / |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
179 |
'scripts' / 'pylint' / 'pylintrc') |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
180 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
181 |
# `lint.Run.__init__` runs the PyLint command. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
182 |
try: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
183 |
lint.Run(arguments) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
184 |
# PyLint will `sys.exit()` when it has finished, so we need to catch |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
185 |
# the exception and process it accordingly. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
186 |
except SystemExit, exc: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
187 |
return_code = exc.args[0] |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
188 |
if return_code != 0 and (not options.pylint.ignore): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
189 |
raise paver.tasks.BuildFailure( |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
190 |
'PyLint finished with a non-zero exit code') |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
191 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
192 |
return dry('pylint ' + ' '.join(arguments), run_pylint) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
193 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
194 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
195 |
@task |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
196 |
@cmdopts([ |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
197 |
('app-build=', 'b', 'App build directory (default /build)'), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
198 |
('app-folder=', 'a', 'App folder directory (default /app)'), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
199 |
('skip-pylint', 's', 'Skip PyLint checker'), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
200 |
('ignore-pylint', 'i', 'Ignore results of PyLint (but run it anyway)'), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
201 |
('quiet-pylint', 'q', 'Make PyLint run quietly'), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
202 |
]) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
203 |
def build(options): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
204 |
"""Build the project.""" |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
205 |
# If `--skip-pylint` is not provided, run PyLint. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
206 |
if not options.skip_pylint: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
207 |
# If `--ignore-pylint` is provided, act as if `paver pylint --ignore` |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
208 |
# was run. Likewise for `--quiet-pylint`. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
209 |
if options.get('ignore_pylint', False): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
210 |
options.pylint.ignore = True |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
211 |
if options.get('quiet_pylint', False): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
212 |
options.pylint.quiet = True |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
213 |
pylint(options) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
214 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
215 |
# Clean old generated zip files from the app folder. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
216 |
clean_zip(options) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
217 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
218 |
# Clean the App build directory by removing and re-creating it. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
219 |
clean_build(options) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
220 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
221 |
# Build the django.zip file. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
222 |
django_zip(options) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
223 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
224 |
# Build the tiny_mce.zip file. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
225 |
tinymce_zip(options) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
226 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
227 |
# Make the necessary symlinks between the app and build directories. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
228 |
build_symlinks(options) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
229 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
230 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
231 |
@task |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
232 |
@cmdopts([ |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
233 |
('app-build=', 'b', 'App build directory (default /build)'), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
234 |
('app-folder=', 'a', 'App folder directory (default /app)'), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
235 |
]) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
236 |
def build_symlinks(options): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
237 |
"""Build symlinks between the app and build folders.""" |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
238 |
# Create the symbolic links from the app folder to the build folder. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
239 |
for filename in options.app_files + options.app_dirs + options.zip_files: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
240 |
# The `symlink()` function handles discrepancies between platforms. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
241 |
target = path(options.app_folder) / filename |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
242 |
link = path(options.app_build) / filename |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
243 |
dry( |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
244 |
'%-4s%-20s <- %s' % ('', target, link), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
245 |
lambda: symlink(target, link)) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
246 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
247 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
248 |
@task |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
249 |
@cmdopts([ |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
250 |
('app-build=', 'b', 'App build directory (default /build)'), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
251 |
]) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
252 |
def clean_build(options): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
253 |
"""Clean the build folder.""" |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
254 |
# Not checking this could cause an error when trying to remove a |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
255 |
# non-existent file. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
256 |
if path(options.app_build).exists(): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
257 |
path(options.app_build).rmtree() |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
258 |
path(options.app_build).makedirs() |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
259 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
260 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
261 |
@task |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
262 |
@cmdopts([ |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
263 |
('app-folder=', 'a', 'App folder directory (default /app)'), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
264 |
]) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
265 |
def clean_zip(options): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
266 |
"""Remove all the generated zip files from the app folder.""" |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
267 |
for zip_file in options.zip_files + ['django.zip']: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
268 |
zip_path = path(options.app_folder) / zip_file |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
269 |
if zip_path.exists(): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
270 |
zip_path.remove() |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
271 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
272 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
273 |
@task |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
274 |
@cmdopts([ |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
275 |
('app-build=', 'b', 'App build directory (default /build)'), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
276 |
('app-folder=', 'a', 'App folder directory (default /app)'), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
277 |
]) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
278 |
def django_zip(options): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
279 |
"""Create the zip file containing Django (minus unwanted stuff).""" |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
280 |
# Write the `django.zip` file. This requires finding all of the necessary |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
281 |
# files and writing them to a `zipfile.ZipFile` instance. Python's |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
282 |
# stdlib `zipfile` module is written in C, so it's fast and doesn't incur |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
283 |
# much overhead. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
284 |
django_src_dir = path(options.app_folder) / 'django' |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
285 |
django_zip_filename = path(options.app_build) / 'django.zip' |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
286 |
if paver.tasks.environment.dry_run: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
287 |
django_zip_fp = StringIO() |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
288 |
else: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
289 |
# Ensure the parent directories exist. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
290 |
django_zip_filename.dirname().makedirs() |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
291 |
django_zip_fp = open(django_zip_filename, mode='w') |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
292 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
293 |
# Write the zip file to disk; this uses the `write_zip_file()` function |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
294 |
# defined above. The try/except/finally makes sure the `django.zip` file |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
295 |
# handle is properly closed no matter what happens. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
296 |
try: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
297 |
write_zip_file(django_zip_fp, django_zip_files(django_src_dir)) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
298 |
except Exception, exc: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
299 |
# Close and delete the (possibly corrupted) `django.zip` file. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
300 |
django_zip_fp.close() |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
301 |
django_zip_filename.remove() |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
302 |
# Raise the error, causing Paver to exit with a non-zero exit code. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
303 |
raise paver.tasks.BuildFailure( |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
304 |
'Error occurred creating django.zip: %r' % (exc,)) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
305 |
finally: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
306 |
# Close the file handle if it isn't already. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
307 |
if not django_zip_fp.closed: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
308 |
django_zip_fp.close() |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
309 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
310 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
311 |
@task |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
312 |
@cmdopts([ |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
313 |
('app-folder=', 'a', 'App folder directory (default /app)'), |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
314 |
]) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
315 |
def tinymce_zip(options): |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
316 |
"""Create the zip file containing TinyMCE.""" |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
317 |
# This is very similar to django_zip; see the comments there for |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
318 |
# explanations. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
319 |
tinymce_dir = path(options.app_folder) / 'tiny_mce' |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
320 |
tinymce_zip_filename = path(options.app_folder) / 'tiny_mce.zip' |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
321 |
if paver.tasks.environment.dry_run: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
322 |
tinymce_zip_fp = StringIO() |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
323 |
else: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
324 |
# Ensure the parent directories exist. |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
325 |
tinymce_zip_filename.dirname().makedirs() |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
326 |
tinymce_zip_fp = open(tinymce_zip_filename, mode='w') |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
327 |
|
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
328 |
try: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
329 |
write_zip_file(tinymce_zip_fp, tinymce_zip_files(tinymce_dir)) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
330 |
except Exception, exc: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
331 |
tinymce_zip_fp.close() |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
332 |
tinymce_zip_filename.remove() |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
333 |
raise paver.tasks.BuildFailure( |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
334 |
'Error occurred creating tinymce.zip: %r' % (exc,)) |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
335 |
finally: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
336 |
if not tinymce_zip_fp.closed: |
eebf0c4ace3d
Add paver script that will replace our current build.sh from scripts folder.
Zachary Voase <disturbyte@googlemail.com>
parents:
diff
changeset
|
337 |
tinymce_zip_fp.close() |