Skip to content
Prev Previous commit
Next Next commit
WIP: simplify setup.py to bundle all extension types
Also, convert pathlib.Path instances to str for consistency
  • Loading branch information
agoose77 committed Feb 12, 2021
commit 01c7fbfdd970fdb4e6961af739e74b340e9d76cb
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"
}
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
},
"jupyterlab": {
"extension": "src/jupyterlab-plugin",
"outputDir": "../share/jupyter/labextensions/jupyter-threejs",
"outputDir": "../pythreejs/labextension",
"sharedPackages": {
"@jupyter-widgets/base": {
"bundled": false,
Expand Down
48 changes: 18 additions & 30 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,8 +9,7 @@
ensure_targets,
get_version,
)

from setuptools import setup
import setuptools


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

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

here = os.path.dirname(os.path.abspath(__file__))
HERE = Path(__file__).parent.resolve()
name = 'pythreejs'
version = get_version(os.path.join(here, name, '_version.py'))
lab_path = (HERE / name / "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'),
('share/jupyter/labextensions/jupyter-threejs/',
'share/jupyter/labextensions/jupyter-threejs/',
'*.*'),
('share/jupyter/labextensions/jupyter-threejs/static',
'share/jupyter/labextensions/jupyter-threejs/static/',
'*.*'),
('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(HERE/'js'/'lab-dist'), 'jupyter-threejs-*.tgz'),
# Support Jupyter Notebook
('etc/jupyter/nbconfig', str(HERE/'jupyter-config'), '**/*.json')
],
)
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=HERE/'js',
build_dir=HERE/'name'/'static',
source_dir=HERE/'js',
build_cmd='build:all'
),
ensure_targets([
Expand Down Expand Up @@ -117,4 +103,6 @@
],
}

setup(**setup_args)

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