Skip to content

feat: jupyter lab 3.0 federated bundle support #342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,8 @@ jupyter nbextension install --py --symlink --sys-prefix pythreejs
# To clean out generated files, run:
npm run clean

# To symlink the jupyter lab extension
jupyter labextension develop .. --overwrite


```
12 changes: 10 additions & 2 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,22 @@
"build:all": "npm run build:labextension",
"build:bundles": "webpack -d && node ./scripts/post-build.js --debug",
"build:bundles-prod": "webpack -p && node ./scripts/post-build.js",
"build:labextension": "rimraf lab-dist && mkdirp lab-dist && cd lab-dist && npm pack ..",
"build:labextension": "rimraf lab-dist && mkdirp lab-dist && cd lab-dist && npm pack .. && cd .. && jupyter labextension build .",
"clean": "rimraf dist && rimraf ../pythreejs/static && rimraf lab-dist && node ./scripts/clean-generated-files.js",
"prepack": "npm run build:bundles-prod",
"prepare": "npm run autogen",
"update:deps": "update-dependency --minimal --regex \"^(?!@jupyter-widgets|three)\"",
"watch": "webpack -d -w"
},
"dependencies": {
"@jupyter-widgets/base": "^1.2.5 || ^2.0.0 || ^3.0.0",
"@jupyter-widgets/base": "^1.2.5 || ^2.0.0 || ^3.0.0 || ^4.0.0-alpha.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"@jupyter-widgets/base": "^1.2.5 || ^2.0.0 || ^3.0.0 || ^4.0.0-alpha.2",
"@jupyter-widgets/base": "^1.2.5 || ^2.0.0 || ^3.0.0 || ^4",

"bluebird": "^3.5.5",
"jupyter-dataserializers": "^2.2.0",
"three": "^0.97.0",
"underscore": "^1.8.3"
},
"devDependencies": {
"@jupyterlab/builder": "^3.0.0-rc.13",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"@jupyterlab/builder": "^3.0.0-rc.13",
"@jupyterlab/builder": "^3.0.0",

"@jupyterlab/buildutils": "^2.0.2",
"eslint": "^6.8.0",
"fs-extra": "^8.1.0",
Expand All @@ -53,6 +54,13 @@
},
"jupyterlab": {
"extension": "src/jupyterlab-plugin",
"outputDir": "../share/jupyter/labextensions/jupyter-threejs",
"sharedPackages": {
"@jupyter-widgets/base": {
"bundled": false,
"singleton": true
}
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nice to hoist threejs as a shared package (non-singleton, ha!)

"discovery": {
"kernel": [
{
Expand Down
19 changes: 19 additions & 0 deletions js/scripts/templates/py_top_level_init.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ from __future__ import absolute_import
from {{ module.pyRelativePath }} import *
{{/each}}


def _prefix():
import sys
from pathlib import Path
prefix = sys.prefix
here = Path(__file__).parent
# for when in dev mode
if (here.parent / 'setup.py').exists():
prefix = here.parent
return prefix


def _jupyter_labextension_paths():
return [{
'src': f'{_prefix()}/share/jupyter/labextensions/{npm_pkg_name}/',
'dest': f'{npm_pkg_name}',
}]


def _jupyter_nbextension_paths():
return [{
'section': 'notebook',
Expand Down
2 changes: 1 addition & 1 deletion js/src/jupyterlab-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
console.error(err);
reject(err);
},
'jupyter-threejs'
'jupyter-threejs-chunk'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is surprising to me. Why do you need -chunk?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the chunk name was not allowed to be the same name as package/module/forgotwhatitwasname, as long as it was not jupyter-threejs it was fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can confirm, have encountered this elsewhere

);
});
}
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["jupyter_packaging~=0.7.0", "jupyterlab>=3.0.0rc4,==3.*", "setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"
17 changes: 9 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,20 @@
import os
import sys

from setupbase import (
log,
from jupyter_packaging import (
create_cmdclass,
install_npm,
combine_commands,
ensure_targets,
combine_commands,
get_version,
)

from setuptools import setup


log.set_verbosity(log.DEBUG)
log.info('setup.py entered')
log.info('$PATH=%s' % os.environ['PATH'])

LONG_DESCRIPTION = 'A Python/ThreeJS bridge utilizing the Jupyter widget infrastructure.'

here = os.path.abspath(os.path.dirname(sys.argv[0]))
here = os.path.dirname(os.path.abspath(__file__))
name = 'pythreejs'
version = get_version(os.path.join(here, name, '_version.py'))

Expand All @@ -39,6 +34,12 @@
('share/jupyter/lab/extensions',
'js/lab-dist',
'jupyter-threejs-*.tgz'),
('share/jupyter/labextensions/jupyter-threejs/',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'share/jupyter/labextensions/jupyter-threejs/',
'*.*'),
('share/jupyter/labextensions/jupyter-threejs/static',
'share/jupyter/labextensions/jupyter-threejs/static/',
'*.*'),
('etc/jupyter/nbconfig',
'jupyter-config',
'**/*.json'),
Expand Down
Loading