mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 22:13:00 +00:00
remove bower
use npm to fetch dependencies and a simple postinstall script to copy into components
This commit is contained in:
13
MANIFEST.in
13
MANIFEST.in
@@ -1,7 +1,7 @@
|
||||
include README.md
|
||||
include COPYING.md
|
||||
include setupegg.py
|
||||
include bower.json
|
||||
include bower-lite
|
||||
include package.json
|
||||
include *requirements.txt
|
||||
include Dockerfile
|
||||
@@ -18,12 +18,13 @@ graft docs
|
||||
prune docs/node_modules
|
||||
|
||||
# prune some large unused files from components
|
||||
prune share/jupyter/hub/static/components/bootstrap/css
|
||||
exclude share/jupyter/hub/static/components/components/fonts/*.svg
|
||||
exclude share/jupyter/hub/static/components/bootstrap/less/*.js
|
||||
exclude share/jupyter/hub/static/components/font-awesome/css
|
||||
prune share/jupyter/hub/static/components/bootstrap/dist/css
|
||||
exclude share/jupyter/hub/static/components/bootstrap/dist/fonts/*.svg
|
||||
prune share/jupyter/hub/static/components/font-awesome/css
|
||||
prune share/jupyter/hub/static/components/font-awesome/scss
|
||||
exclude share/jupyter/hub/static/components/font-awesome/fonts/*.svg
|
||||
exclude share/jupyter/hub/static/components/jquery/*migrate*.js
|
||||
prune share/jupyter/hub/static/components/jquery/external
|
||||
prune share/jupyter/hub/static/components/jquery/src
|
||||
prune share/jupyter/hub/static/components/moment/lang
|
||||
prune share/jupyter/hub/static/components/moment/min
|
||||
|
||||
|
36
bower-lite
Executable file
36
bower-lite
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
"""
|
||||
bower-lite
|
||||
|
||||
Since Bower's on its way out,
|
||||
stage frontend dependencies from node_modules into components
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
from os.path import join
|
||||
import shutil
|
||||
|
||||
HERE = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
|
||||
components = join(HERE, "share", "jupyter", "hub", "static", "components")
|
||||
node_modules = join(HERE, "node_modules")
|
||||
|
||||
if os.path.exists(components):
|
||||
shutil.rmtree(components)
|
||||
os.mkdir(components)
|
||||
|
||||
with open(join(HERE, 'package.json')) as f:
|
||||
package_json = json.load(f)
|
||||
|
||||
dependencies = package_json['dependencies']
|
||||
for dep in dependencies:
|
||||
src = join(node_modules, dep)
|
||||
dest = join(components, dep)
|
||||
print("%s -> %s" % (src, dest))
|
||||
shutil.copytree(src, dest)
|
11
bower.json
11
bower.json
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"name": "jupyterhub-deps",
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"bootstrap": "components/bootstrap#~3.3",
|
||||
"font-awesome": "components/font-awesome#~4.7",
|
||||
"jquery": "components/jquery#~3.2",
|
||||
"moment": "~2.18",
|
||||
"requirejs": "~2.3"
|
||||
}
|
||||
}
|
11
package.json
11
package.json
@@ -8,10 +8,19 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/jupyter/jupyterhub.git"
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "./bower-lite"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bower": "*",
|
||||
"less": "^2.7.1",
|
||||
"less-plugin-clean-css": "^1.5.1",
|
||||
"clean-css": "^3.4.13"
|
||||
},
|
||||
"dependencies": {
|
||||
"bootstrap": "^3.3.7",
|
||||
"font-awesome": "^4.7.0",
|
||||
"jquery": "^3.2.1",
|
||||
"moment": "^2.18.1",
|
||||
"requirejs": "^2.3.4"
|
||||
}
|
||||
}
|
||||
|
29
setup.py
29
setup.py
@@ -149,45 +149,34 @@ class BaseCommand(Command):
|
||||
return []
|
||||
|
||||
|
||||
class Bower(BaseCommand):
|
||||
class NPM(BaseCommand):
|
||||
description = "fetch static client-side components with bower"
|
||||
|
||||
user_options = []
|
||||
bower_dir = pjoin(static, 'components')
|
||||
node_modules = pjoin(here, 'node_modules')
|
||||
bower_dir = pjoin(static, 'components')
|
||||
|
||||
def should_run(self):
|
||||
if not os.path.exists(self.bower_dir):
|
||||
return True
|
||||
return mtime(self.bower_dir) < mtime(pjoin(here, 'bower.json'))
|
||||
|
||||
def should_run_npm(self):
|
||||
if not shutil.which('npm'):
|
||||
print("npm unavailable", file=sys.stderr)
|
||||
return False
|
||||
if not os.path.exists(self.bower_dir):
|
||||
return True
|
||||
if not os.path.exists(self.node_modules):
|
||||
return True
|
||||
if mtime(self.bower_dir) < mtime(self.node_modules):
|
||||
return True
|
||||
return mtime(self.node_modules) < mtime(pjoin(here, 'package.json'))
|
||||
|
||||
def run(self):
|
||||
if not self.should_run():
|
||||
print("bower dependencies up to date")
|
||||
print("npm dependencies up to date")
|
||||
return
|
||||
|
||||
if self.should_run_npm():
|
||||
print("installing build dependencies with npm")
|
||||
print("installing js dependencies with npm")
|
||||
check_call(['npm', 'install', '--progress=false'], cwd=here, shell=shell)
|
||||
os.utime(self.node_modules)
|
||||
|
||||
env = os.environ.copy()
|
||||
env['PATH'] = npm_path
|
||||
args = ['bower', 'install', '--allow-root', '--config.interactive=false']
|
||||
try:
|
||||
check_call(args, cwd=here, env=env, shell=shell)
|
||||
except OSError as e:
|
||||
print("Failed to run bower: %s" % e, file=sys.stderr)
|
||||
print("You can install js dependencies with `npm install`", file=sys.stderr)
|
||||
raise
|
||||
os.utime(self.bower_dir)
|
||||
# update data-files in case this created new files
|
||||
self.distribution.data_files = get_data_files()
|
||||
@@ -275,7 +264,7 @@ class bdist_egg_disabled(bdist_egg):
|
||||
|
||||
|
||||
setup_args['cmdclass'] = {
|
||||
'js': Bower,
|
||||
'js': NPM,
|
||||
'css': CSS,
|
||||
'build_py': js_css_first(build_py, strict=is_repo),
|
||||
'sdist': js_css_first(sdist, strict=True),
|
||||
|
@@ -35,8 +35,8 @@
|
||||
<link rel="stylesheet" href="{{ static_url("css/style.min.css") }}" type="text/css"/>
|
||||
{% endblock %}
|
||||
<script src="{{static_url("components/requirejs/require.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("components/jquery/jquery.min.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("components/bootstrap/js/bootstrap.min.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("components/jquery/dist/jquery.min.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("components/bootstrap/dist/js/bootstrap.min.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script>
|
||||
require.config({
|
||||
{% if version_hash %}
|
||||
@@ -45,8 +45,8 @@
|
||||
baseUrl: '{{static_url("js", include_version=False)}}',
|
||||
paths: {
|
||||
components: '../components',
|
||||
jquery: '../components/jquery/jquery.min',
|
||||
bootstrap: '../components/bootstrap/js/bootstrap.min',
|
||||
jquery: '../components/jquery/dist/jquery.min',
|
||||
bootstrap: '../components/bootstrap/dist/js/bootstrap.min',
|
||||
moment: "../components/moment/moment",
|
||||
},
|
||||
shim: {
|
||||
|
Reference in New Issue
Block a user