Skip to content

Feature: JupyterLab 3.0 Support Cleanup #350

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

Merged
merged 14 commits into from
Feb 15, 2021
Merged
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
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ recursive-include pythreejs/static *.*

include setupbase.py

include LICENSE
include README.md
include pytest.ini
include screencast.gif

Expand Down
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


```
5 changes: 5 additions & 0 deletions install.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"packageManager": "python",
"packageName": "pythreejs",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package pythreejs"
}
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",
"bluebird": "^3.5.5",
"jupyter-dataserializers": "^2.2.0",
"three": "^0.97.0",
"underscore": "^1.8.3"
},
"devDependencies": {
"@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": "../pythreejs/labextension",
"sharedPackages": {
"@jupyter-widgets/base": {
"bundled": false,
"singleton": true
}
},
"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'
);
});
}
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 = ["jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"
58 changes: 26 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import print_function
import os
import sys
from pathlib import Path

from setupbase import (
log,
Expand All @@ -12,50 +9,45 @@
ensure_targets,
get_version,
)

from setuptools import setup
import setuptools


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 = Path(__file__).parent.resolve()
name = 'pythreejs'
version = get_version(os.path.join(here, name, '_version.py'))
py_path = (HERE / name)
js_path = (HERE / "js")
lab_path = (py_path / "labextension")

version = get_version(HERE / name / '_version.py')

cmdclass = create_cmdclass(
'js',
data_files_spec=[
('share/jupyter/nbextensions/jupyter-threejs',
name + '/static',
'*.js'),
('share/jupyter/nbextensions/jupyter-threejs',
name + '/static',
'*.js.map'),
('share/jupyter/lab/extensions',
'js/lab-dist',
'jupyter-threejs-*.tgz'),
('etc/jupyter/nbconfig',
'jupyter-config',
'**/*.json'),
# Support JupyterLab 3.x prebuilt extension
("share/jupyter/labextensions/jupyter-threejs", str(lab_path), "**"),
("share/jupyter/labextensions/jupyter-threejs", str(HERE), "install.json"),
# Support JupyterLab 2.x
('share/jupyter/lab/extensions', str(js_path/'lab-dist'), 'jupyter-threejs-*.tgz'),
# Support Jupyter Notebook
('etc/jupyter/nbconfig', str(HERE/'jupyter-config'), '**/*.json'),
('share/jupyter/nbextensions/jupyter-threejs', str(py_path/'static'), '**/*.js'),
('share/jupyter/nbextensions/jupyter-threejs', str(py_path/'static'), '**/*.js.map')
],
)
cmdclass['js'] = combine_commands(
install_npm(
path=os.path.join(here, 'js'),
build_dir=os.path.join(here, name, 'static'),
source_dir=os.path.join(here, 'js'),
path=str(js_path),
build_dir=str(py_path/'static'),
source_dir=str(js_path),
build_cmd='build:all'
),
ensure_targets([
name + '/static/extension.js',
name + '/static/index.js',
'js/src/core/BufferAttribute.autogen.js',
name + '/core/BufferAttribute_autogen.py',
str(py_path/'static'/'extension.js'),
str(py_path/'static'/'index.js'),
str(js_path/'src'/'core'/'BufferAttribute.autogen.js'),
str(py_path/'core'/'BufferAttribute_autogen.py'),
]),
)

Expand Down Expand Up @@ -109,4 +101,6 @@
],
}

setup(**setup_args)

if __name__ == "__main__":
setuptools.setup(**setup_args)