Show More
@@ -29,7 +29,8 b' RUN apt-get install -y -q build-essential make gcc zlib1g-dev git && \\' | |||||
29 | # In order to build from source, need less |
|
29 | # In order to build from source, need less | |
30 | RUN npm install -g less |
|
30 | RUN npm install -g less | |
31 |
|
31 | |||
32 |
RUN apt-get install -y -q |
|
32 | RUN apt-get install -y -q python-sphinx python3-sphinx | |
|
33 | RUN pip install invoke | |||
33 |
|
34 | |||
34 | RUN mkdir -p /srv/ |
|
35 | RUN mkdir -p /srv/ | |
35 | WORKDIR /srv/ |
|
36 | WORKDIR /srv/ |
@@ -4,10 +4,9 b'' | |||||
4 |
|
4 | |||
5 | Developers of the IPython Notebook will need to install the following tools: |
|
5 | Developers of the IPython Notebook will need to install the following tools: | |
6 |
|
6 | |||
7 | * fabric |
|
7 | * invoke | |
8 | * node.js |
|
8 | * node.js | |
9 | * less (`npm install -g less`) |
|
9 | * less (`npm install -g less`) | |
10 | * bower (`npm install -g bower`) |
|
|||
11 |
|
10 | |||
12 | ## Components |
|
11 | ## Components | |
13 |
|
12 | |||
@@ -15,14 +14,13 b' We are moving to a model where our JavaScript dependencies are managed using' | |||||
15 | [bower](http://bower.io/). These packages are installed in `static/components` |
|
14 | [bower](http://bower.io/). These packages are installed in `static/components` | |
16 | and committed into a separate git repo [ipython/ipython-components](ipython/ipython-components). |
|
15 | and committed into a separate git repo [ipython/ipython-components](ipython/ipython-components). | |
17 | Our dependencies are described in the file |
|
16 | Our dependencies are described in the file | |
18 |
`static/components/bower.json`. To update our bower packages, run ` |
|
17 | `static/components/bower.json`. To update our bower packages, run `bower install` | |
19 | in this directory. |
|
18 | in this directory. | |
20 |
|
19 | |||
21 | ## less |
|
20 | ## less | |
22 |
|
21 | |||
23 | If you edit our `.less` files you will need to run the less compiler to build |
|
22 | If you edit our `.less` files you will need to run the less compiler to build | |
24 |
our minified css files. This can be done by running ` |
|
23 | our minified css files. This can be done by running `python setup.py css` from the root of the repository. | |
25 | or `python setup.py css` from the root of the repository. |
|
|||
26 | If you are working frequently with `.less` files please consider installing git hooks that |
|
24 | If you are working frequently with `.less` files please consider installing git hooks that | |
27 | rebuild the css files and corresponding maps in `${RepoRoot}/git-hooks/install-hooks.sh`. |
|
25 | rebuild the css files and corresponding maps in `${RepoRoot}/git-hooks/install-hooks.sh`. | |
28 |
|
26 |
@@ -1,7 +1,6 b'' | |||||
1 | """ fabfile to prepare the notebook """ |
|
1 | """invoke task file to build CSS""" | |
2 |
|
2 | |||
3 | from fabric.api import local,lcd |
|
3 | from invoke import task, run | |
4 | from fabric.utils import abort |
|
|||
5 | import os |
|
4 | import os | |
6 | from distutils.version import LooseVersion as V |
|
5 | from distutils.version import LooseVersion as V | |
7 | from subprocess import check_output |
|
6 | from subprocess import check_output | |
@@ -40,11 +39,9 b' def _need_css_update():' | |||||
40 |
|
39 | |||
41 | return False |
|
40 | return False | |
42 |
|
41 | |||
|
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 = _to_bool(minify) |
|
|||
46 | verbose = _to_bool(verbose) |
|
|||
47 | force = _to_bool(force) |
|
|||
48 | # minify implies force because it's not the default behavior |
|
45 | # minify implies force because it's not the default behavior | |
49 | if not force and not minify and not _need_css_update(): |
|
46 | if not force and not minify and not _need_css_update(): | |
50 | print("css up-to-date") |
|
47 | print("css up-to-date") | |
@@ -56,15 +53,10 b' def css(minify=False, verbose=False, force=False):' | |||||
56 | sourcemap = pjoin('style', "%s.min.css.map" % name) |
|
53 | sourcemap = pjoin('style', "%s.min.css.map" % name) | |
57 | _compile_less(source, target, sourcemap, minify, verbose) |
|
54 | _compile_less(source, target, sourcemap, minify, verbose) | |
58 |
|
55 | |||
59 | def _to_bool(b): |
|
|||
60 | if not b in ['True', 'False', True, False]: |
|
|||
61 | abort('boolean expected, got: %s' % b) |
|
|||
62 | return (b in ['True', True]) |
|
|||
63 |
|
||||
64 | def _compile_less(source, target, sourcemap, minify=True, verbose=False): |
|
56 | def _compile_less(source, target, sourcemap, minify=True, verbose=False): | |
65 | """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""" | |
66 |
min_flag = '-x' if minify |
|
58 | min_flag = '-x' if minify else '' | |
67 |
ver_flag = '--verbose' if verbose |
|
59 | ver_flag = '--verbose' if verbose else '' | |
68 |
|
60 | |||
69 | # pin less to version number from above |
|
61 | # pin less to version number from above | |
70 | try: |
|
62 | try: | |
@@ -80,6 +72,12 b' def _compile_less(source, target, sourcemap, minify=True, verbose=False):' | |||||
80 | 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 lesscss@X.Y.Z` to install a specific version of less" % (less_version, max_less_version)) | |
81 |
|
73 | |||
82 | static_path = pjoin(here, static_dir) |
|
74 | static_path = pjoin(here, static_dir) | |
83 | with lcd(static_dir): |
|
75 | cwd = os.getcwd() | |
84 | local('lessc {min_flag} {ver_flag} --source-map={sourcemap} --source-map-basepath={static_path} --source-map-rootpath="../" {source} {target}'.format(**locals())) |
|
76 | try: | |
|
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()), | |||
|
79 | echo=True, | |||
|
80 | ) | |||
|
81 | finally: | |||
|
82 | os.chdir(cwd) | |||
85 |
|
83 |
@@ -259,7 +259,7 b" sec.requires('zmq', 'tornado', 'requests', 'sqlite3', 'jsonschema')" | |||||
259 | # file in there (MathJax ships a conf.py), so we might as |
|
259 | # file in there (MathJax ships a conf.py), so we might as | |
260 | # well play it safe and skip the whole thing. |
|
260 | # well play it safe and skip the whole thing. | |
261 | sec.exclude('static') |
|
261 | sec.exclude('static') | |
262 |
sec.exclude(' |
|
262 | sec.exclude('tasks') | |
263 | if not have['jinja2']: |
|
263 | if not have['jinja2']: | |
264 | sec.exclude('notebookapp') |
|
264 | sec.exclude('notebookapp') | |
265 | if not have['pygments'] or not have['jinja2']: |
|
265 | if not have['pygments'] or not have['jinja2']: |
@@ -46,7 +46,7 b" if __name__ == '__main__':" | |||||
46 | r'\.core\.display', |
|
46 | r'\.core\.display', | |
47 | r'\.lib\.display', |
|
47 | r'\.lib\.display', | |
48 | # This isn't actually a module |
|
48 | # This isn't actually a module | |
49 |
r'\.html\. |
|
49 | r'\.html\.tasks', | |
50 | ] |
|
50 | ] | |
51 |
|
51 | |||
52 | # These modules import functions and classes from other places to expose |
|
52 | # These modules import functions and classes from other places to expose |
@@ -9,12 +9,12 b' else' | |||||
9 | PREVIOUS_HEAD=$1 |
|
9 | PREVIOUS_HEAD=$1 | |
10 | fi |
|
10 | fi | |
11 |
|
11 | |||
12 |
# if style changed (and less/ |
|
12 | # if style changed (and less/invoke available), rebuild sourcemaps | |
13 | if [[ |
|
13 | if [[ | |
14 | ! -z "$(git diff $PREVIOUS_HEAD IPython/html/static/style/ipython.min.css)" |
|
14 | ! -z "$(git diff $PREVIOUS_HEAD IPython/html/static/style/ipython.min.css)" | |
15 | && ! -z "$(git diff $PREVIOUS_HEAD IPython/html/static/style/style.min.css)" |
|
15 | && ! -z "$(git diff $PREVIOUS_HEAD IPython/html/static/style/style.min.css)" | |
16 | && ! -z $(which 2>/dev/null lessc) |
|
16 | && ! -z $(which 2>/dev/null lessc) | |
17 |
&& ! -z $(which 2>/dev/null |
|
17 | && ! -z $(which 2>/dev/null invoke) | |
18 | ]]; then |
|
18 | ]]; then | |
19 | echo "rebuilding sourcemaps" |
|
19 | echo "rebuilding sourcemaps" | |
20 | cd IPython/html |
|
20 | cd IPython/html |
@@ -669,7 +669,7 b' class CompileCSS(Command):' | |||||
669 |
|
669 | |||
670 | Regenerate the compiled CSS from LESS sources. |
|
670 | Regenerate the compiled CSS from LESS sources. | |
671 |
|
671 | |||
672 |
Requires various dev dependencies, such as |
|
672 | Requires various dev dependencies, such as invoke and lessc. | |
673 | """ |
|
673 | """ | |
674 | description = "Recompile Notebook CSS" |
|
674 | description = "Recompile Notebook CSS" | |
675 | user_options = [ |
|
675 | user_options = [ | |
@@ -686,11 +686,12 b' class CompileCSS(Command):' | |||||
686 | self.force = bool(self.force) |
|
686 | self.force = bool(self.force) | |
687 |
|
687 | |||
688 | def run(self): |
|
688 | def run(self): | |
689 | check_call([ |
|
689 | cmd = ['invoke', 'css'] | |
690 | "fab", |
|
690 | if self.minify: | |
691 | "css:minify=%s,force=%s" % (self.minify, self.force), |
|
691 | cmd.append('--minify') | |
692 | ], cwd=pjoin(repo_root, "IPython", "html"), |
|
692 | if self.force: | |
693 | ) |
|
693 | cmd.append('--force') | |
|
694 | check_call(cmd, cwd=pjoin(repo_root, "IPython", "html")) | |||
694 |
|
695 | |||
695 |
|
696 | |||
696 | class JavascriptVersion(Command): |
|
697 | class JavascriptVersion(Command): |
@@ -3,10 +3,8 b'' | |||||
3 | # test suite on all supported python versions. To use it, "pip install tox" |
|
3 | # test suite on all supported python versions. To use it, "pip install tox" | |
4 | # and then run "tox" from this directory. |
|
4 | # and then run "tox" from this directory. | |
5 |
|
5 | |||
6 |
# Building the source distribution requires |
|
6 | # Building the source distribution requires `invoke` and `lessc` to be on your PATH. | |
7 | # (http://www.fabfile.org/) and the lessc binary of the css preprocessor |
|
7 | # "pip install invoke" will install invoke. Less can be installed by | |
8 | # less (http://lesscss.org/) in the PATH. |
|
|||
9 | # "pip install fabric" will install fabric. Less can be installed by |
|
|||
10 | # node.js' (http://nodejs.org/) package manager npm: |
|
8 | # node.js' (http://nodejs.org/) package manager npm: | |
11 | # "npm install -g less". |
|
9 | # "npm install -g less". | |
12 |
|
10 |
General Comments 0
You need to be logged in to leave comments.
Login now