|
1 | 1 | # -*- coding: utf-8 -*- |
2 | | - |
3 | | -from __future__ import print_function |
4 | | -import os |
5 | | -import sys |
| 2 | +from pathlib import Path |
6 | 3 |
|
7 | 4 | from setupbase import ( |
8 | 5 | log, |
|
12 | 9 | ensure_targets, |
13 | 10 | get_version, |
14 | 11 | ) |
15 | | - |
16 | | -from setuptools import setup |
| 12 | +import setuptools |
17 | 13 |
|
18 | 14 |
|
19 | 15 | # due to https://github.com/jupyterlab/jupyterlab/blob/136d2ec216ebfc429a696e6ee75fee5f8ead73e2/jupyterlab/federated_labextensions.py#L347 |
|
24 | 20 |
|
25 | 21 | LONG_DESCRIPTION = 'A Python/ThreeJS bridge utilizing the Jupyter widget infrastructure.' |
26 | 22 |
|
27 | | -here = os.path.dirname(os.path.abspath(__file__)) |
| 23 | +HERE = Path(__file__).parent.resolve() |
28 | 24 | name = 'pythreejs' |
29 | | -version = get_version(os.path.join(here, name, '_version.py')) |
| 25 | +lab_path = (HERE / name / "labextension") |
30 | 26 |
|
| 27 | +version = get_version(HERE / name / '_version.py') |
31 | 28 |
|
32 | 29 | cmdclass = create_cmdclass( |
33 | 30 | 'js', |
34 | 31 | 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') |
53 | 39 | ], |
54 | 40 | ) |
55 | 41 | cmdclass['js'] = combine_commands( |
56 | 42 | 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', |
60 | 46 | build_cmd='build:all' |
61 | 47 | ), |
62 | 48 | ensure_targets([ |
|
117 | 103 | ], |
118 | 104 | } |
119 | 105 |
|
120 | | -setup(**setup_args) |
| 106 | + |
| 107 | +if __name__ == "__main__": |
| 108 | + setuptools.setup(**setup_args) |
0 commit comments