Skip to content

Commit

Permalink
Merge pull request #319 from maartenbreddels/feat_support_lab2_and_next
Browse files Browse the repository at this point in the history
Support jupyter lab >2 (kinda) and auto enable jupyter lab
  • Loading branch information
maartenbreddels committed Apr 22, 2020
2 parents 13a158d + 9026b84 commit a4f3faf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"webpack-cli": "^3.2.3"
},
"dependencies": {
"@jupyter-widgets/base": "^1.0.0 || ^2.0.0",
"@jupyter-widgets/base": "^1 || ^2 || ^3 || ^4",
"@jupyter-widgets/controls": "^1.4.2",
"css-loader": "^0.28.4",
"d3": "^5.7.0",
Expand Down
3 changes: 2 additions & 1 deletion js/src/labplugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as base from "@jupyter-widgets/base";
import * as jupyter_volume from "./index";

export
const plugin = {
id: "ipyvolume",
requires: [base.IJupyterWidgetRegistry],
Expand All @@ -14,3 +13,5 @@ const plugin = {
},
autoStart: true,
};

export default plugin;
39 changes: 24 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from setuptools.command.build_py import build_py
from setuptools.command.egg_info import egg_info
from subprocess import check_call
import json
import os
import sys
import platform
Expand All @@ -27,6 +28,23 @@ def read(fname):

LONG_DESCRIPTION = read("README.rst")

def get_data_files():
with open(os.path.join('js', 'package.json')) as f:
package_json = json.load(f)
tgz = '%s-%s.tgz' % (package_json['name'], package_json['version'])
return [
(
'share/jupyter/nbextensions/ipyvolume',
[
'ipyvolume/static/extension.js',
'ipyvolume/static/index.js',
'ipyvolume/static/three.js',
'ipyvolume/static/index.js.map',
],
),
('etc/jupyter/nbconfig/notebook.d', ['ipyvolume.json']),
('share/jupyter/lab/extensions', ['js/' + tgz])
]

def js_prerelease(command, strict=False):
"""Decorator for building minified js/css prior to another command."""
Expand All @@ -51,14 +69,15 @@ def run(self):
log.warn('rebuilding js and css failed (not a problem)')
log.warn(str(e))
command.run(self)
update_package_data(self.distribution)
update_data_files(self.distribution)

return DecoratedCommand


def update_package_data(distribution):
def update_data_files(distribution):
"""Update package_data to catch changes during setup."""
build_py = distribution.get_command_obj('build_py')
distribution.data_files = get_data_files()
# distribution.package_data = find_package_data()
# re-init build_py options which load package_data
build_py.finalize_options()
Expand Down Expand Up @@ -114,6 +133,7 @@ def run(self):
log.info("Installing build dependencies with npm. This may take a while...")
npmName = self.get_npm_name()
check_call([npmName, 'install'], cwd=node_root, stdout=sys.stdout, stderr=sys.stderr)
check_call([npmName, 'pack'], cwd=node_root, stdout=sys.stdout, stderr=sys.stderr)
os.utime(self.node_modules, None)

for t in self.targets:
Expand All @@ -124,7 +144,7 @@ def run(self):
raise ValueError(msg)

# update package data in case this created new files
update_package_data(self.distribution)
update_data_files(self.distribution)


version_ns = {}
Expand All @@ -137,18 +157,7 @@ def run(self):
'description': 'IPython widget for rendering 3d volumes',
'long_description': LONG_DESCRIPTION,
'include_package_data': True,
'data_files': [
(
'share/jupyter/nbextensions/ipyvolume',
[
'ipyvolume/static/extension.js',
'ipyvolume/static/index.js',
'ipyvolume/static/three.js',
'ipyvolume/static/index.js.map',
],
),
('etc/jupyter/nbconfig/notebook.d', ['ipyvolume.json']),
],
'data_files': get_data_files(),
'install_requires': [
'ipywidgets>=7.0.0',
'bqplot',
Expand Down

0 comments on commit a4f3faf

Please sign in to comment.