mirror of
https://github.com/jupyter/notebook.git
synced 2024-11-27 03:20:27 +08:00
use invoke instead of fabric
it's the descendant of the part of fabric we actually use, it doesn't have complex compiled dependencies like fabric, and it works on Python 3.
This commit is contained in:
parent
c0108e1089
commit
41cfd4f5cf
@ -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/
|
||||
|
@ -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`.
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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']:
|
||||
|
@ -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
|
||||
|
13
setupbase.py
13
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):
|
||||
|
Loading…
Reference in New Issue
Block a user