Skip to content

Commit 01c7fbf

Browse files
committed
WIP: simplify setup.py to bundle all extension types
Also, convert pathlib.Path instances to str for consistency
1 parent aff8266 commit 01c7fbf

File tree

3 files changed

+24
-31
lines changed

3 files changed

+24
-31
lines changed

Diff for: install.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"packageManager": "python",
3+
"packageName": "pythreejs",
4+
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package pythreejs"
5+
}

Diff for: js/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
},
5555
"jupyterlab": {
5656
"extension": "src/jupyterlab-plugin",
57-
"outputDir": "../share/jupyter/labextensions/jupyter-threejs",
57+
"outputDir": "../pythreejs/labextension",
5858
"sharedPackages": {
5959
"@jupyter-widgets/base": {
6060
"bundled": false,

Diff for: setup.py

+18-30
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
3-
from __future__ import print_function
4-
import os
5-
import sys
2+
from pathlib import Path
63

74
from setupbase import (
85
log,
@@ -12,8 +9,7 @@
129
ensure_targets,
1310
get_version,
1411
)
15-
16-
from setuptools import setup
12+
import setuptools
1713

1814

1915
# due to https://github.com/jupyterlab/jupyterlab/blob/136d2ec216ebfc429a696e6ee75fee5f8ead73e2/jupyterlab/federated_labextensions.py#L347
@@ -24,39 +20,29 @@
2420

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

27-
here = os.path.dirname(os.path.abspath(__file__))
23+
HERE = Path(__file__).parent.resolve()
2824
name = 'pythreejs'
29-
version = get_version(os.path.join(here, name, '_version.py'))
25+
lab_path = (HERE / name / "labextension")
3026

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

3229
cmdclass = create_cmdclass(
3330
'js',
3431
data_files_spec=[
35-
('share/jupyter/nbextensions/jupyter-threejs',
36-
name + '/static',
37-
'*.js'),
38-
('share/jupyter/nbextensions/jupyter-threejs',
39-
name + '/static',
40-
'*.js.map'),
41-
('share/jupyter/lab/extensions',
42-
'js/lab-dist',
43-
'jupyter-threejs-*.tgz'),
44-
('share/jupyter/labextensions/jupyter-threejs/',
45-
'share/jupyter/labextensions/jupyter-threejs/',
46-
'*.*'),
47-
('share/jupyter/labextensions/jupyter-threejs/static',
48-
'share/jupyter/labextensions/jupyter-threejs/static/',
49-
'*.*'),
50-
('etc/jupyter/nbconfig',
51-
'jupyter-config',
52-
'**/*.json'),
32+
# Support JupyterLab 3.x prebuilt extension
33+
("share/jupyter/labextensions/jupyter-threejs", str(lab_path), "**"),
34+
("share/jupyter/labextensions/jupyter-threejs", str(HERE), "install.json"),
35+
# Support JupyterLab 2.x
36+
('share/jupyter/lab/extensions', str(HERE/'js'/'lab-dist'), 'jupyter-threejs-*.tgz'),
37+
# Support Jupyter Notebook
38+
('etc/jupyter/nbconfig', str(HERE/'jupyter-config'), '**/*.json')
5339
],
5440
)
5541
cmdclass['js'] = combine_commands(
5642
install_npm(
57-
path=os.path.join(here, 'js'),
58-
build_dir=os.path.join(here, name, 'static'),
59-
source_dir=os.path.join(here, 'js'),
43+
path=HERE/'js',
44+
build_dir=HERE/'name'/'static',
45+
source_dir=HERE/'js',
6046
build_cmd='build:all'
6147
),
6248
ensure_targets([
@@ -117,4 +103,6 @@
117103
],
118104
}
119105

120-
setup(**setup_args)
106+
107+
if __name__ == "__main__":
108+
setuptools.setup(**setup_args)

0 commit comments

Comments
 (0)