##// END OF EJS Templates
Merge pull request #5027 from minrk/pin-less...
Brian E. Granger -
r15060:7b8c0663 merge
parent child Browse files
Show More
@@ -1,32 +1,46 b''
1 1 """ fabfile to prepare the notebook """
2 2
3 3 from fabric.api import local,lcd
4 4 from fabric.utils import abort
5 5 import os
6 from distutils.version import LooseVersion as V
7 from subprocess import check_output
6 8
7 9 pjoin = os.path.join
8 10 static_dir = 'static'
9 11 components_dir = os.path.join(static_dir, 'components')
10 12
13 min_less_version = '1.4.0'
14 max_less_version = '1.5.0' # exclusive
11 15
12 16 def css(minify=True, verbose=False):
13 17 """generate the css from less files"""
14 18 for name in ('style', 'ipython'):
15 19 source = pjoin('style', "%s.less" % name)
16 20 target = pjoin('style', "%s.min.css" % name)
17 21 _compile_less(source, target, minify, verbose)
18 22
19 23 def _to_bool(b):
20 24 if not b in ['True', 'False', True, False]:
21 25 abort('boolean expected, got: %s' % b)
22 26 return (b in ['True', True])
23 27
24 28 def _compile_less(source, target, minify=True, verbose=False):
25 29 """Compile a less file by source and target relative to static_dir"""
26 30 minify = _to_bool(minify)
27 31 verbose = _to_bool(verbose)
28 32 min_flag = '-x' if minify is True else ''
29 33 ver_flag = '--verbose' if verbose is True else ''
34
35 # pin less to 1.4
36 out = check_output(['lessc', '--version'])
37 out = out.decode('utf8', 'replace')
38 less_version = out.split()[1]
39 if V(less_version) < V(min_less_version):
40 raise ValueError("lessc too old: %s < %s" % (less_version, min_less_version))
41 if V(less_version) > V(max_less_version):
42 raise ValueError("lessc too new: %s > %s" % (less_version, max_less_version))
43
30 44 with lcd(static_dir):
31 45 local('lessc {min_flag} {ver_flag} {source} {target}'.format(**locals()))
32 46
General Comments 0
You need to be logged in to leave comments. Login now