Skip to content

Commit

Permalink
Merge pull request #221 from minrk/swallow-gulp
Browse files Browse the repository at this point in the history
remove gulp
  • Loading branch information
takluyver committed Jul 22, 2015
2 parents ecdb109 + c41df91 commit 454a581
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 142 deletions.
114 changes: 0 additions & 114 deletions gulpfile.js

This file was deleted.

16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@
"version": "4.0.0",
"description": "Jupyter Notebook nodejs dependencies",
"author": "Jupyter Developers",
"license": "BSD",
"license": "BSD-3-Clause",
"repository": {
"type": "git",
"url": "https://github.com/jupyter/notebook.git"
},
"scripts": {
"bower": "bower install",
"build": "python setup.py js css"
},
"devDependencies": {
"bower": "*",
"gulp": "^3.8.11",
"gulp-less": "^3.0.2",
"gulp-livereload": "^3.8.0",
"gulp-newer": "^0.5.0",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^1.5.1",
"less": "~2",
"requirejs": "^2.1.17",
"source-map": "^0.4.2",
"through": "^2.3.7"
"requirejs": "^2.1.17"
}
}
89 changes: 71 additions & 18 deletions setupbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
import os
import sys

import pipes
from distutils import log
from distutils.cmd import Command
from fnmatch import fnmatch
from glob import glob
from multiprocessing.pool import ThreadPool
from subprocess import check_call


#-------------------------------------------------------------------------------
# Useful globals and utility functions
#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -287,6 +290,11 @@ def mtime(path):
return os.stat(path).st_mtime


def run(cmd, *args, **kwargs):
"""Echo a command before running it"""
log.info(" ".join(cmd))
return check_call(cmd, *args, **kwargs)


class Bower(Command):
description = "fetch static client-side components with bower"
Expand Down Expand Up @@ -326,14 +334,14 @@ def run(self):

if self.should_run_npm():
print("installing build dependencies with npm")
check_call(['npm', 'install'], cwd=repo_root)
run(['npm', 'install'], cwd=repo_root)
os.utime(self.node_modules, None)

env = os.environ.copy()
env['PATH'] = npm_path

try:
check_call(
run(
['bower', 'install', '--allow-root', '--config.interactive=false'],
cwd=repo_root,
env=env
Expand All @@ -352,7 +360,7 @@ class CompileCSS(Command):
Regenerate the compiled CSS from LESS sources.
Requires various dev dependencies, such as gulp and lessc.
Requires various dev dependencies, such as require and lessc.
"""
description = "Recompile Notebook CSS"
user_options = []
Expand All @@ -367,40 +375,85 @@ def run(self):
self.run_command('jsdeps')
env = os.environ.copy()
env['PATH'] = npm_path
try:
check_call(['gulp','css'], cwd=repo_root, env=env)
except OSError as e:
print("Failed to run gulp css: %s" % e, file=sys.stderr)
print("You can install js dependencies with `npm install`", file=sys.stderr)
raise

for name in ('ipython', 'style'):

src = pjoin(static, 'style', '%s.less' % name)
dst = pjoin(static, 'style', '%s.min.css' % name)
try:
run(['lessc',
'--source-map',
'--include-path=%s' % pipes.quote(static),
src,
dst,
], cwd=repo_root, env=env)
except OSError as e:
print("Failed to build css: %s" % e, file=sys.stderr)
print("You can install js dependencies with `npm install`", file=sys.stderr)
raise
# update package data in case this created new files
update_package_data(self.distribution)


class CompileJS(Command):
"""Rebuild minified Notebook Javascript
"""Rebuild Notebook Javascript main.min.js files
Calls `gulp js`
Calls require via build-main.js
"""
description = "Rebuild Notebook Javascript"
description = "Rebuild Notebook Javascript main.min.js files"
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def sources(self, name):
"""Generator yielding .js sources that an application depends on"""
yield pjoin(static, name, 'js', 'main.js')

for sec in [name, 'base', 'auth']:
for f in glob(pjoin(static, sec, 'js', '*.js')):
yield f
yield pjoin(static, 'services', 'config.js')
if name == 'notebook':
for f in glob(pjoin(static, 'services', '*', '*.js')):
yield f
for parent, dirs, files in os.walk(pjoin(static, 'components')):
if os.path.basename(parent) == 'MathJax':
# don't look in MathJax, since it takes forever to walk it
dirs[:] = []
continue
for f in files:
yield pjoin(parent, f)

def should_run(self, name, target):
if not os.path.exists(target):
return True
target_mtime = mtime(target)
for source in self.sources(name):
if mtime(source) > target_mtime:
print(source, target)
return True
return False

def build_main(self, name):
"""Build main.min.js"""
target = pjoin(static, name, 'js', 'main.min.js')

if not self.should_run(name, target):
log.info("%s up to date" % target)
return
log.info("Rebuilding %s" % target)
run(['node', 'tools/build-main.js', name])

def run(self):
self.run_command('jsdeps')
env = os.environ.copy()
env['PATH'] = npm_path
try:
check_call(['gulp','js'], cwd=repo_root, env=env)
except OSError as e:
print("Failed to run gulp js: %s" % e, file=sys.stderr)
print("You can install js dependencies with `npm install`", file=sys.stderr)
raise
pool = ThreadPool()
pool.map(self.build_main, ['notebook', 'tree', 'edit', 'terminal', 'auth'])
# update package data in case this created new files
update_package_data(self.distribution)

Expand Down
File renamed without changes.

0 comments on commit 454a581

Please sign in to comment.