-
Notifications
You must be signed in to change notification settings - Fork 60
/
_update.py
191 lines (161 loc) · 7.09 KB
/
_update.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
from __future__ import print_function
from builtins import input
import sys, os, shutil, glob
def system(cmd):
print(cmd)
failure = os.system(cmd)
if failure:
print('could not run\n%s\nin%s' % (cmd, os.getcwd()))
sys.exit(1)
def rmtree(directory):
try:
shutil.rmtree(directory)
except OSError:
pass # OK if the directory does not exist
def zip_dir(dirname):
os.system('rm -rf %s/.git' % dirname) # remove .git, all will be removed...
system('zip -r %s.zip %s' % (dirname, dirname))
def insertdoc():
# To run from the root dir
system('python bin/doconce insertdocstr plain lib/doconce')
def wide_clean():
# remove files that are to be regenerated:
#system('sh clean.sh')
# (must be in the root directory)
thisdir = os.getcwd()
dirs = [os.path.join('lib', 'doconce', 'docstrings'),
os.path.join('doc', 'src', 'tutorial'),
os.path.join('doc', 'src', 'manual'),
os.path.join('doc', 'src', 'latexcode'),
os.path.join('doc', 'src', 'quickref'),
os.path.join('doc', 'src', 'slides'),
os.path.join('doc', 'src', 'blog'),
os.path.join('doc', 'src', 'design'),
os.path.join('doc', 'src', 'pyopt_pysc'),
'test',
#'bundled', # leave cloned repos and delete them manually
]
for d in dirs:
os.chdir(d)
system('sh ./clean.sh')
os.chdir(thisdir)
def pack_local_dirs():
system('zip -r sphinx_themes.zip sphinx_themes')
system('zip -r html_images.zip html_images')
# Pack latex styles and figures in a zip file without any directory.
# minted.sty and anslistings.sty are not copied from some
# repo every time, so get the latest versions from ptex2tex manually.
os.chdir('latex_styles')
system('zip latex_styles.zip *')
system('mv -f latex_styles.zip ..')
os.chdir(os.pardir)
zipfiles2lib()
def zipfiles2lib():
for zfile in glob.glob('*.zip'):
shutil.copy(zfile, os.path.join(os.pardir, 'lib', 'doconce', zfile))
def pack_reveal_deck_csss():
if clone:
print("""
NOTE: cloning repos like reveal.js and deck.js may bring in new
versions of styles that are not compatible with previous tuning.
So, be careful to mix doconce tunings with new versions.
If styles are to be tuned more, a good idea can be to pack out
the zip file instead and tune directly those style files.
If new versions are cloned (i.e., you answer "yes" below), first
take a copy of the reveal.js and deck.js source trees (e.g.,
from doc/pub/slides/demo) and run a directory tree diff on the
new and old trees to get an overview of what type of files that
have changed. Note that if you diff bundled/reveal.js and an old
reveal.js after having run _update.py all, the files in bundled
have copies of local doconce modifications in bundled/doconce_modifications.
You should also diff with a fresh reveal.js clone to see how new
.css files define things and play together with new .js functions.
(Detected time-consuming incompatibilities Jan, 2014, after reveal and
deck had undergone significant developments.)
""")
ans = input('Sure you want to proceed? (y/n) ')
if ans.lower().startswith('n'):
return
system('sh clean.sh')
rmtree('reveal.js')
system('git clone git://github.com/hakimel/reveal.js.git')
os.system('cp doconce_modifications/reveal/css/reveal*.css reveal.js/css/')
os.system('cp doconce_modifications/reveal/css/theme/*.css reveal.js/css/theme/')
os.system('cp doconce_modifications/reveal/css/theme/source/*.scss reveal.js/css/theme/source/')
os.system('cp doconce_modifications/reveal/css/theme/template/*.scss reveal.js/css/theme/template/')
os.system('cp doconce_modifications/reveal/Gruntfile.js reveal.js/')
os.system('mkdir reveal.js/css/images')
os.system('cp doconce_modifications/reveal/css/images/*.png reveal.js/css/images/')
# Building new .css files is only necessary if .scss are modified
#os.system('cp doconce_modifications/reveal/Gruntfile.js reveal.js/')
#os.system('cd reveal.js; npm install; grunt themes; cd ..')
zip_dir('reveal.js')
if clone:
rmtree('csss')
system('git clone git://github.com/LeaVerou/csss.git')
os.system('cp doconce_modifications/csss/*.css csss/')
zip_dir('csss')
if clone:
rmtree('deck.js')
system('git clone git://github.com/imakewebthings/deck.js.git')
rmtree('mnml')
system('git clone git://github.com/duijf/mnml.git')
rmtree('deckjs-theme-mozilla')
system('git clone git://github.com/groovecoder/deckjs-theme-mozilla.git')
rmtree('deck.js-codemirror')
system('git clone git://github.com/iros/deck.js-codemirror.git')
os.mkdir('deck.js/extensions/codemirror')
rmtree('deck.ext.js')
system('git clone git://github.com/barraq/deck.ext.js.git')
rmtree('deck.pointer.js')
system('git clone git://github.com/mikeharris100/deck.pointer.js.git')
os.mkdir('deck.js/extensions/pointer')
rmtree('presenterview')
system('git clone git://github.com/stvnwrgs/presenterview.git')
rmtree('deck.annotate.js')
system('git clone git://github.com/nemec/deck.annotate.js.git')
rmtree('deck.js-notes')
system('git clone [email protected]:freekh/deck.js-notes.git')
system('cp mnml/mnml.css deck.js/themes/style')
system('cp deckjs-theme-mozilla/*.*css deck.js/themes/style')
system('cp -r deck.js-codemirror/* deck.js/extensions/codemirror/')
system('cp -r deck.ext.js/themes/style/*.*css deck.js/themes/style/')
system('cp -r deck.pointer.js/deck.pointer.* deck.js/extensions/pointer/')
system('cp -r presenterview/ deck.js/extensions/')
system('cp -r deck.annotate.js deck.js/extensions/')
system('cp -r deck.js-notes deck.js/extensions/notes')
#system('cp doconce_modifications/deck/core/*.css deck.js/core/')
system('cp doconce_modifications/deck/themes/style/*.css deck.js/themes/style/')
if not os.path.isdir('deck.js/themes/images'):
os.mkdir('deck.js/themes/images')
system('cp doconce_modifications/deck/themes/images/*.png deck.js/themes/images/')
# this find will always generate errors..., use os.system
os.system("find deck.js/extensions -name '.git' -exec rm -rf {} \;")
zip_dir('deck.js')
zipfiles2lib()
def run_all():
# pack zip files distributed as data with doconce
pack_local_dirs()
pack_reveal_deck_csss()
# back to root dir
os.chdir(os.pardir)
insertdoc()
wide_clean()
if __name__ == '__main__':
software_dir = 'bundled'
os.chdir(software_dir)
os.system('rm -f *.zip')
if len(sys.argv) == 1:
print('Usage: python _update.py all | | all-noclone | local')
sys.exit(1)
if sys.argv[1] == 'all':
clone = True
run_all()
elif sys.argv[1] == 'all-noclone':
clone = False
run_all()
else:
#func = sys.argv[1]
#eval(func + '()')
pack_local_dirs()
print('Successful execution of', sys.argv[0])