##// END OF EJS Templates
Merge pull request #7070 from rgbkrk/pin_less_docker...
Matthias Bussonnier -
r19118:9b0db4ee merge
parent child Browse files
Show More
@@ -1,66 +1,66 b''
1 # Installs IPython from the current branch
1 # Installs IPython from the current branch
2 # Another Docker container should build from this one to get services like the notebook
2 # Another Docker container should build from this one to get services like the notebook
3
3
4 FROM ubuntu:14.04
4 FROM ubuntu:14.04
5
5
6 MAINTAINER IPython Project <ipython-dev@scipy.org>
6 MAINTAINER IPython Project <ipython-dev@scipy.org>
7
7
8 ENV DEBIAN_FRONTEND noninteractive
8 ENV DEBIAN_FRONTEND noninteractive
9
9
10 # Not essential, but wise to set the lang
10 # Not essential, but wise to set the lang
11 # Note: Users with other languages should set this in their derivative image
11 # Note: Users with other languages should set this in their derivative image
12 RUN apt-get update && apt-get install -y language-pack-en
12 RUN apt-get update && apt-get install -y language-pack-en
13 ENV LANGUAGE en_US.UTF-8
13 ENV LANGUAGE en_US.UTF-8
14 ENV LANG en_US.UTF-8
14 ENV LANG en_US.UTF-8
15 ENV LC_ALL en_US.UTF-8
15 ENV LC_ALL en_US.UTF-8
16
16
17 RUN locale-gen en_US.UTF-8
17 RUN locale-gen en_US.UTF-8
18 RUN dpkg-reconfigure locales
18 RUN dpkg-reconfigure locales
19
19
20 # Python binary dependencies, developer tools
20 # Python binary dependencies, developer tools
21 RUN apt-get update && apt-get install -y -q \
21 RUN apt-get update && apt-get install -y -q \
22 build-essential \
22 build-essential \
23 make \
23 make \
24 gcc \
24 gcc \
25 zlib1g-dev \
25 zlib1g-dev \
26 git \
26 git \
27 python \
27 python \
28 python-dev \
28 python-dev \
29 python-pip \
29 python-pip \
30 python3-dev \
30 python3-dev \
31 python3-pip \
31 python3-pip \
32 python-sphinx \
32 python-sphinx \
33 python3-sphinx \
33 python3-sphinx \
34 libzmq3-dev \
34 libzmq3-dev \
35 sqlite3 \
35 sqlite3 \
36 libsqlite3-dev \
36 libsqlite3-dev \
37 pandoc \
37 pandoc \
38 libcurl4-openssl-dev \
38 libcurl4-openssl-dev \
39 nodejs \
39 nodejs \
40 nodejs-legacy \
40 nodejs-legacy \
41 npm
41 npm
42
42
43 # In order to build from source, need less
43 # In order to build from source, need less
44 RUN npm install -g less
44 RUN npm install -g less@1.7.5
45
45
46 RUN pip install invoke
46 RUN pip install invoke
47
47
48 RUN mkdir -p /srv/
48 RUN mkdir -p /srv/
49 WORKDIR /srv/
49 WORKDIR /srv/
50 ADD . /srv/ipython
50 ADD . /srv/ipython
51 WORKDIR /srv/ipython/
51 WORKDIR /srv/ipython/
52 RUN chmod -R +rX /srv/ipython
52 RUN chmod -R +rX /srv/ipython
53
53
54 # .[all] only works with -e, so use file://path#egg
54 # .[all] only works with -e, so use file://path#egg
55 # Can't use -e because ipython2 and ipython3 will clobber each other
55 # Can't use -e because ipython2 and ipython3 will clobber each other
56 RUN pip2 install file:///srv/ipython#egg=ipython[all]
56 RUN pip2 install file:///srv/ipython#egg=ipython[all]
57 RUN pip3 install file:///srv/ipython#egg=ipython[all]
57 RUN pip3 install file:///srv/ipython#egg=ipython[all]
58
58
59 # install kernels
59 # install kernels
60 RUN python2 -m IPython kernelspec install-self --system
60 RUN python2 -m IPython kernelspec install-self --system
61 RUN python3 -m IPython kernelspec install-self --system
61 RUN python3 -m IPython kernelspec install-self --system
62
62
63 WORKDIR /tmp/
63 WORKDIR /tmp/
64
64
65 RUN iptest2
65 RUN iptest2
66 RUN iptest3
66 RUN iptest3
@@ -1,83 +1,83 b''
1 """invoke task file to build CSS"""
1 """invoke task file to build CSS"""
2
2
3 from invoke import task, run
3 from invoke import task, run
4 import os
4 import os
5 from distutils.version import LooseVersion as V
5 from distutils.version import LooseVersion as V
6 from subprocess import check_output
6 from subprocess import check_output
7
7
8 pjoin = os.path.join
8 pjoin = os.path.join
9 static_dir = 'static'
9 static_dir = 'static'
10 components_dir = pjoin(static_dir, 'components')
10 components_dir = pjoin(static_dir, 'components')
11 here = os.path.dirname(__file__)
11 here = os.path.dirname(__file__)
12
12
13 min_less_version = '1.7.5'
13 min_less_version = '1.7.5'
14 max_less_version = '1.8.0' # exclusive
14 max_less_version = '1.8.0' # exclusive
15
15
16 def _need_css_update():
16 def _need_css_update():
17 """Does less need to run?"""
17 """Does less need to run?"""
18
18
19 static_path = pjoin(here, static_dir)
19 static_path = pjoin(here, static_dir)
20 css_targets = [
20 css_targets = [
21 pjoin(static_path, 'style', '%s.min.css' % name)
21 pjoin(static_path, 'style', '%s.min.css' % name)
22 for name in ('style', 'ipython')
22 for name in ('style', 'ipython')
23 ]
23 ]
24 css_maps = [t + '.map' for t in css_targets]
24 css_maps = [t + '.map' for t in css_targets]
25 targets = css_targets + css_maps
25 targets = css_targets + css_maps
26 if not all(os.path.exists(t) for t in targets):
26 if not all(os.path.exists(t) for t in targets):
27 # some generated files don't exist
27 # some generated files don't exist
28 return True
28 return True
29 earliest_target = sorted(os.stat(t).st_mtime for t in targets)[0]
29 earliest_target = sorted(os.stat(t).st_mtime for t in targets)[0]
30
30
31 # check if any .less files are newer than the generated targets
31 # check if any .less files are newer than the generated targets
32 for (dirpath, dirnames, filenames) in os.walk(static_path):
32 for (dirpath, dirnames, filenames) in os.walk(static_path):
33 for f in filenames:
33 for f in filenames:
34 if f.endswith('.less'):
34 if f.endswith('.less'):
35 path = pjoin(static_path, dirpath, f)
35 path = pjoin(static_path, dirpath, f)
36 timestamp = os.stat(path).st_mtime
36 timestamp = os.stat(path).st_mtime
37 if timestamp > earliest_target:
37 if timestamp > earliest_target:
38 return True
38 return True
39
39
40 return False
40 return False
41
41
42 @task
42 @task
43 def css(minify=False, verbose=False, force=False):
43 def css(minify=False, verbose=False, force=False):
44 """generate the css from less files"""
44 """generate the css from less files"""
45 # minify implies force because it's not the default behavior
45 # minify implies force because it's not the default behavior
46 if not force and not minify and not _need_css_update():
46 if not force and not minify and not _need_css_update():
47 print("css up-to-date")
47 print("css up-to-date")
48 return
48 return
49
49
50 for name in ('style', 'ipython'):
50 for name in ('style', 'ipython'):
51 source = pjoin('style', "%s.less" % name)
51 source = pjoin('style', "%s.less" % name)
52 target = pjoin('style', "%s.min.css" % name)
52 target = pjoin('style', "%s.min.css" % name)
53 sourcemap = pjoin('style', "%s.min.css.map" % name)
53 sourcemap = pjoin('style', "%s.min.css.map" % name)
54 _compile_less(source, target, sourcemap, minify, verbose)
54 _compile_less(source, target, sourcemap, minify, verbose)
55
55
56 def _compile_less(source, target, sourcemap, minify=True, verbose=False):
56 def _compile_less(source, target, sourcemap, minify=True, verbose=False):
57 """Compile a less file by source and target relative to static_dir"""
57 """Compile a less file by source and target relative to static_dir"""
58 min_flag = '-x' if minify else ''
58 min_flag = '-x' if minify else ''
59 ver_flag = '--verbose' if verbose else ''
59 ver_flag = '--verbose' if verbose else ''
60
60
61 # pin less to version number from above
61 # pin less to version number from above
62 try:
62 try:
63 out = check_output(['lessc', '--version'])
63 out = check_output(['lessc', '--version'])
64 except OSError as err:
64 except OSError as err:
65 raise ValueError("Unable to find lessc. Please install lessc >= %s and < %s " \
65 raise ValueError("Unable to find lessc. Please install lessc >= %s and < %s " \
66 % (min_less_version, max_less_version))
66 % (min_less_version, max_less_version))
67 out = out.decode('utf8', 'replace')
67 out = out.decode('utf8', 'replace')
68 less_version = out.split()[1]
68 less_version = out.split()[1]
69 if V(less_version) < V(min_less_version):
69 if V(less_version) < V(min_less_version):
70 raise ValueError("lessc too old: %s < %s. Use `$ npm install lesscss@X.Y.Z` to install a specific version of less" % (less_version, min_less_version))
70 raise ValueError("lessc too old: %s < %s. Use `$ npm install less@X.Y.Z` to install a specific version of less" % (less_version, min_less_version))
71 if V(less_version) >= V(max_less_version):
71 if V(less_version) >= V(max_less_version):
72 raise ValueError("lessc too new: %s >= %s. Use `$ npm install lesscss@X.Y.Z` to install a specific version of less" % (less_version, max_less_version))
72 raise ValueError("lessc too new: %s >= %s. Use `$ npm install less@X.Y.Z` to install a specific version of less" % (less_version, max_less_version))
73
73
74 static_path = pjoin(here, static_dir)
74 static_path = pjoin(here, static_dir)
75 cwd = os.getcwd()
75 cwd = os.getcwd()
76 try:
76 try:
77 os.chdir(static_dir)
77 os.chdir(static_dir)
78 run('lessc {min_flag} {ver_flag} --source-map={sourcemap} --source-map-basepath={static_path} --source-map-rootpath="../" {source} {target}'.format(**locals()),
78 run('lessc {min_flag} {ver_flag} --source-map={sourcemap} --source-map-basepath={static_path} --source-map-rootpath="../" {source} {target}'.format(**locals()),
79 echo=True,
79 echo=True,
80 )
80 )
81 finally:
81 finally:
82 os.chdir(cwd)
82 os.chdir(cwd)
83
83
General Comments 0
You need to be logged in to leave comments. Login now