|
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 | | -log.set_verbosity(log.DEBUG) |
20 | | -log.info('setup.py entered') |
21 | | -log.info('$PATH=%s' % os.environ['PATH']) |
22 | | - |
23 | 15 | LONG_DESCRIPTION = 'A Python/ThreeJS bridge utilizing the Jupyter widget infrastructure.' |
24 | 16 |
|
25 | | -here = os.path.abspath(os.path.dirname(sys.argv[0])) |
| 17 | +HERE = Path(__file__).parent.resolve() |
26 | 18 | name = 'pythreejs' |
27 | | -version = get_version(os.path.join(here, name, '_version.py')) |
| 19 | +py_path = (HERE / name) |
| 20 | +js_path = (HERE / "js") |
| 21 | +lab_path = (py_path / "labextension") |
28 | 22 |
|
| 23 | +version = get_version(HERE / name / '_version.py') |
29 | 24 |
|
30 | 25 | cmdclass = create_cmdclass( |
31 | 26 | 'js', |
32 | 27 | data_files_spec=[ |
33 | | - ('share/jupyter/nbextensions/jupyter-threejs', |
34 | | - name + '/static', |
35 | | - '*.js'), |
36 | | - ('share/jupyter/nbextensions/jupyter-threejs', |
37 | | - name + '/static', |
38 | | - '*.js.map'), |
39 | | - ('share/jupyter/lab/extensions', |
40 | | - 'js/lab-dist', |
41 | | - 'jupyter-threejs-*.tgz'), |
42 | | - ('etc/jupyter/nbconfig', |
43 | | - 'jupyter-config', |
44 | | - '**/*.json'), |
| 28 | + # Support JupyterLab 3.x prebuilt extension |
| 29 | + ("share/jupyter/labextensions/jupyter-threejs", str(lab_path), "**"), |
| 30 | + ("share/jupyter/labextensions/jupyter-threejs", str(HERE), "install.json"), |
| 31 | + # Support JupyterLab 2.x |
| 32 | + ('share/jupyter/lab/extensions', str(js_path/'lab-dist'), 'jupyter-threejs-*.tgz'), |
| 33 | + # Support Jupyter Notebook |
| 34 | + ('etc/jupyter/nbconfig', str(HERE/'jupyter-config'), '**/*.json'), |
| 35 | + ('share/jupyter/nbextensions/jupyter-threejs', str(py_path/'static'), '**/*.js'), |
| 36 | + ('share/jupyter/nbextensions/jupyter-threejs', str(py_path/'static'), '**/*.js.map') |
45 | 37 | ], |
46 | 38 | ) |
47 | 39 | cmdclass['js'] = combine_commands( |
48 | 40 | install_npm( |
49 | | - path=os.path.join(here, 'js'), |
50 | | - build_dir=os.path.join(here, name, 'static'), |
51 | | - source_dir=os.path.join(here, 'js'), |
| 41 | + path=str(js_path), |
| 42 | + build_dir=str(py_path/'static'), |
| 43 | + source_dir=str(js_path), |
52 | 44 | build_cmd='build:all' |
53 | 45 | ), |
54 | 46 | ensure_targets([ |
55 | | - name + '/static/extension.js', |
56 | | - name + '/static/index.js', |
57 | | - 'js/src/core/BufferAttribute.autogen.js', |
58 | | - name + '/core/BufferAttribute_autogen.py', |
| 47 | + str(py_path/'static'/'extension.js'), |
| 48 | + str(py_path/'static'/'index.js'), |
| 49 | + str(js_path/'src'/'core'/'BufferAttribute.autogen.js'), |
| 50 | + str(py_path/'core'/'BufferAttribute_autogen.py'), |
59 | 51 | ]), |
60 | 52 | ) |
61 | 53 |
|
|
109 | 101 | ], |
110 | 102 | } |
111 | 103 |
|
112 | | -setup(**setup_args) |
| 104 | + |
| 105 | +if __name__ == "__main__": |
| 106 | + setuptools.setup(**setup_args) |
0 commit comments