diff --git a/Dockerfile b/Dockerfile index 445eba2..1af8e92 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,8 @@ RUN apt-get install -y -q build-essential make gcc zlib1g-dev git && \ # In order to build from source, need less RUN npm install -g less -RUN apt-get install -y -q fabric python-sphinx python3-sphinx +RUN apt-get install -y -q python-sphinx python3-sphinx +RUN pip install invoke RUN mkdir -p /srv/ WORKDIR /srv/ diff --git a/IPython/html/README.md b/IPython/html/README.md index e354f71..892cb82 100644 --- a/IPython/html/README.md +++ b/IPython/html/README.md @@ -4,10 +4,9 @@ Developers of the IPython Notebook will need to install the following tools: -* fabric +* invoke * node.js * less (`npm install -g less`) -* bower (`npm install -g bower`) ## Components @@ -15,14 +14,13 @@ We are moving to a model where our JavaScript dependencies are managed using [bower](http://bower.io/). These packages are installed in `static/components` and committed into a separate git repo [ipython/ipython-components](ipython/ipython-components). Our dependencies are described in the file -`static/components/bower.json`. To update our bower packages, run `fab update` +`static/components/bower.json`. To update our bower packages, run `bower install` in this directory. ## less If you edit our `.less` files you will need to run the less compiler to build -our minified css files. This can be done by running `fab css` from this directory, -or `python setup.py css` from the root of the repository. +our minified css files. This can be done by running `python setup.py css` from the root of the repository. If you are working frequently with `.less` files please consider installing git hooks that rebuild the css files and corresponding maps in `${RepoRoot}/git-hooks/install-hooks.sh`. diff --git a/IPython/html/fabfile.py b/IPython/html/tasks.py similarity index 79% rename from IPython/html/fabfile.py rename to IPython/html/tasks.py index 9283b8e..a384a6b 100644 --- a/IPython/html/fabfile.py +++ b/IPython/html/tasks.py @@ -1,7 +1,6 @@ -""" fabfile to prepare the notebook """ +"""invoke task file to build CSS""" -from fabric.api import local,lcd -from fabric.utils import abort +from invoke import task, run import os from distutils.version import LooseVersion as V from subprocess import check_output @@ -40,11 +39,9 @@ def _need_css_update(): return False +@task def css(minify=False, verbose=False, force=False): """generate the css from less files""" - minify = _to_bool(minify) - verbose = _to_bool(verbose) - force = _to_bool(force) # minify implies force because it's not the default behavior if not force and not minify and not _need_css_update(): print("css up-to-date") @@ -56,15 +53,10 @@ def css(minify=False, verbose=False, force=False): sourcemap = pjoin('style', "%s.min.css.map" % name) _compile_less(source, target, sourcemap, minify, verbose) -def _to_bool(b): - if not b in ['True', 'False', True, False]: - abort('boolean expected, got: %s' % b) - return (b in ['True', True]) - def _compile_less(source, target, sourcemap, minify=True, verbose=False): """Compile a less file by source and target relative to static_dir""" - min_flag = '-x' if minify is True else '' - ver_flag = '--verbose' if verbose is True else '' + min_flag = '-x' if minify else '' + ver_flag = '--verbose' if verbose else '' # pin less to version number from above try: @@ -80,6 +72,12 @@ def _compile_less(source, target, sourcemap, minify=True, verbose=False): 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)) static_path = pjoin(here, static_dir) - with lcd(static_dir): - local('lessc {min_flag} {ver_flag} --source-map={sourcemap} --source-map-basepath={static_path} --source-map-rootpath="../" {source} {target}'.format(**locals())) + cwd = os.getcwd() + try: + os.chdir(static_dir) + run('lessc {min_flag} {ver_flag} --source-map={sourcemap} --source-map-basepath={static_path} --source-map-rootpath="../" {source} {target}'.format(**locals()), + echo=True, + ) + finally: + os.chdir(cwd) diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index 1389dd5..50876c5 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -259,7 +259,7 @@ sec.requires('zmq', 'tornado', 'requests', 'sqlite3', 'jsonschema') # file in there (MathJax ships a conf.py), so we might as # well play it safe and skip the whole thing. sec.exclude('static') -sec.exclude('fabfile') +sec.exclude('tasks') if not have['jinja2']: sec.exclude('notebookapp') if not have['pygments'] or not have['jinja2']: diff --git a/docs/autogen_api.py b/docs/autogen_api.py index b504f80..870d24e 100755 --- a/docs/autogen_api.py +++ b/docs/autogen_api.py @@ -46,7 +46,7 @@ if __name__ == '__main__': r'\.core\.display', r'\.lib\.display', # This isn't actually a module - r'\.html\.fabfile', + r'\.html\.tasks', ] # These modules import functions and classes from other places to expose diff --git a/git-hooks/post-checkout b/git-hooks/post-checkout index a8b1206..e491e8f 100755 --- a/git-hooks/post-checkout +++ b/git-hooks/post-checkout @@ -9,12 +9,12 @@ else PREVIOUS_HEAD=$1 fi -# if style changed (and less/fabric available), rebuild sourcemaps +# if style changed (and less/invoke available), rebuild sourcemaps if [[ ! -z "$(git diff $PREVIOUS_HEAD IPython/html/static/style/ipython.min.css)" && ! -z "$(git diff $PREVIOUS_HEAD IPython/html/static/style/style.min.css)" && ! -z $(which 2>/dev/null lessc) - && ! -z $(which 2>/dev/null fab) + && ! -z $(which 2>/dev/null invoke) ]]; then echo "rebuilding sourcemaps" cd IPython/html diff --git a/setupbase.py b/setupbase.py index 2516e4f..5e85d4b 100644 --- a/setupbase.py +++ b/setupbase.py @@ -669,7 +669,7 @@ class CompileCSS(Command): Regenerate the compiled CSS from LESS sources. - Requires various dev dependencies, such as fabric and lessc. + Requires various dev dependencies, such as invoke and lessc. """ description = "Recompile Notebook CSS" user_options = [ @@ -686,11 +686,12 @@ class CompileCSS(Command): self.force = bool(self.force) def run(self): - check_call([ - "fab", - "css:minify=%s,force=%s" % (self.minify, self.force), - ], cwd=pjoin(repo_root, "IPython", "html"), - ) + cmd = ['invoke', 'css'] + if self.minify: + cmd.append('--minify') + if self.force: + cmd.append('--force') + check_call(cmd, cwd=pjoin(repo_root, "IPython", "html")) class JavascriptVersion(Command): diff --git a/tox.ini b/tox.ini index dae0b87..3a19738 100644 --- a/tox.ini +++ b/tox.ini @@ -3,10 +3,8 @@ # test suite on all supported python versions. To use it, "pip install tox" # and then run "tox" from this directory. -# Building the source distribution requires both fabric's fab binary -# (http://www.fabfile.org/) and the lessc binary of the css preprocessor -# less (http://lesscss.org/) in the PATH. -# "pip install fabric" will install fabric. Less can be installed by +# Building the source distribution requires `invoke` and `lessc` to be on your PATH. +# "pip install invoke" will install invoke. Less can be installed by # node.js' (http://nodejs.org/) package manager npm: # "npm install -g less".