-
Notifications
You must be signed in to change notification settings - Fork 2
/
tasks.py
124 lines (92 loc) · 2.7 KB
/
tasks.py
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
from invoke import task, run
from invoke.tasks import call
import os
import shutil
@task()
def clean(deps=False, pybuild=False):
"""
Clean up all files produced by a build. Optionally removes
jspm dependencies and python build environment.
"""
ui = os.path.join('pelicide', 'ui')
paths = [
os.path.join(ui, fn)
for fn in ['build.js', 'build.js.map', 'build.css', 'build.css.map']
]
if deps:
paths.append(os.path.join(ui, 'jspm_packages'))
if pybuild:
paths.append('build')
for pattern in paths:
if os.path.isfile(pattern):
os.remove(pattern)
elif os.path.isdir(pattern):
shutil.rmtree(pattern)
elif os.path.exists(pattern):
raise RuntimeError('Don\'t know how to clean %s' % pattern)
@task()
def deps():
"""
Install jspm dependencies required for development.
"""
run('jspm install')
@task(deps)
def build_bundle(minify=True, sourcemaps=True):
"""
Create a bundled version of the code and its dependencies, ready for
deployment.
--[no-]minify: Minify the output (defaults to true).
--[no-]sourcemaps: Build source maps (defaults to true).
"""
args = []
if minify:
args.append('--minify')
if not sourcemaps:
args.append('--skip-source-maps')
run('jspm bundle-sfx %s %s' % (os.path.join('src', 'main'), ' '.join(args)))
@task(call(build_bundle, sourcemaps=False))
def build_python():
"""
Build everything needed to install python package.
"""
run('python setup.py build')
@task(build_python)
def build():
"""
Perform a production build of the javascript code, its dependencies and
the python package.
"""
@task(pre=[call(clean, deps=True, pybuild=True), build])
def rebuild():
"""
Perform a full rebuild of the javascript code, its dependencies and
the python package.
"""
@task(rebuild)
def wheel():
"""
Perform a full rebuild and bundle pelicide as a python wheel.
"""
run('python setup.py bdist_wheel')
@task(wheel)
def dist():
"""
Build all distribution variants.
"""
@task(build)
def nuitka():
"""
Build a standalone nuitka distribution. Experimental.
"""
run('nuitka --standalone %s --output-dir=build' % (
os.path.join('build', 'lib', 'pelicide', '__main__.py'),
))
os.makedirs(os.path.join('build', '__main__.dist', 'pelicide'))
shutil.copy(
os.path.join('build', 'lib', 'pelicide', 'pelican-runner.py'),
os.path.join('build', '__main__.dist', 'pelicide')
)
shutil.copytree(
os.path.join('build', 'lib', 'pelicide', 'ui'),
os.path.join('build', '__main__.dist', 'ui')
)