From 1b722636c39f28728a94679d9bd2cb3c536156f9 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 5 Apr 2018 14:58:47 +0100 Subject: [PATCH] Test sdist process and make sure pywwt is installed/enabled as far as Jupyter is concerned. --- .check_enabled.py | 19 +++++++++++++++++++ .gitignore | 1 + .travis.yml | 7 ++++++- js/README.md | 11 ----------- .../jupyter_notebook_config.d/pywwt.json | 7 +++++++ pywwt.json => jupyter.d/notebook.d/pywwt.json | 0 package.json | 2 +- pywwt/qt.py | 4 ++-- pywwt/tests/test_core.py | 2 +- setup.py | 7 +++++-- 10 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 .check_enabled.py delete mode 100644 js/README.md create mode 100644 jupyter.d/jupyter_notebook_config.d/pywwt.json rename pywwt.json => jupyter.d/notebook.d/pywwt.json (100%) diff --git a/.check_enabled.py b/.check_enabled.py new file mode 100644 index 0000000..88afe67 --- /dev/null +++ b/.check_enabled.py @@ -0,0 +1,19 @@ +import sys + +from jupyterlab.commands import get_app_info +from notebook.nbextensions import validate_nbextension +from notebook.serverextensions import validate_serverextension + +if validate_nbextension('pywwt/extension') != []: + print("Issue detected with nbextension") + sys.exit(1) + +info = get_app_info() + +if 'pywwt' not in info['extensions'] or 'pywwt' in info['disabled']: + print("Issue detected with labextension") + sys.exit(1) + +if validate_serverextension('pywwt') != []: + print("Issue detected with serverextension") + sys.exit(1) diff --git a/.gitignore b/.gitignore index 0aa4a3d..8834644 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,4 @@ distribute-*.tar.gz .DS_Store js/node_modules +node_modules diff --git a/.travis.yml b/.travis.yml index 124ed76..0f62210 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,8 +25,13 @@ env: install: - git clone git://github.com/astropy/ci-helpers.git - source ci-helpers/travis/setup_conda.sh - - pip install . script: + - python setup.py sdist + - cd dist; pip install *.tar.gz --verbose; cd .. + - jupyter nbextension list + - jupyter labextension list + - jupyter serverextension list + - python .check_enabled.py - py.test pywwt - cd docs ; make html linkcheck diff --git a/js/README.md b/js/README.md deleted file mode 100644 index 4fd72ca..0000000 --- a/js/README.md +++ /dev/null @@ -1,11 +0,0 @@ -WorldWide Telescope Jupyter widget - -Package Install ---------------- - -**Prerequisites** -- [node](http://nodejs.org/) - -```bash -npm install --save pywwt -``` diff --git a/jupyter.d/jupyter_notebook_config.d/pywwt.json b/jupyter.d/jupyter_notebook_config.d/pywwt.json new file mode 100644 index 0000000..fa398b5 --- /dev/null +++ b/jupyter.d/jupyter_notebook_config.d/pywwt.json @@ -0,0 +1,7 @@ +{ + "NotebookApp": { + "nbserver_extensions": { + "pywwt": true + } + } +} diff --git a/pywwt.json b/jupyter.d/notebook.d/pywwt.json similarity index 100% rename from pywwt.json rename to jupyter.d/notebook.d/pywwt.json diff --git a/package.json b/package.json index 183ad35..263ce2b 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ }, "scripts": { "build": "npm run build:nbextension", - "build:labextension": "cd pywwt && rimraf labextension && mkdirp labextension && cd labextension && npm pack ../..", + "build:labextension": "cd pywwt && rimraf labextension && mkdir labextension && cd labextension && npm pack ../..", "build:nbextension": "webpack", "build:all": "npm run build:labextension && npm run build:nbextension", "clean": "npm run clean:nbextension", diff --git a/pywwt/qt.py b/pywwt/qt.py index fd9d454..dd789fb 100644 --- a/pywwt/qt.py +++ b/pywwt/qt.py @@ -16,12 +16,12 @@ from .logger import logger __all__ = ['WWTQtClient'] -WWT_JSON_FILE = os.path.join(os.path.dirname(__file__), 'static', 'wwt_json_api.js') +WWT_JSON_FILE = os.path.join(os.path.dirname(__file__), 'nbextension', 'static', 'wwt_json_api.js') with open(WWT_JSON_FILE) as f: WWT_JSON = f.read() -WWT_HTML_FILE = os.path.join(os.path.dirname(__file__), 'static', 'wwt.html') +WWT_HTML_FILE = os.path.join(os.path.dirname(__file__), 'nbextension', 'static', 'wwt.html') with open(WWT_HTML_FILE) as f: WWT_HTML = f.read() diff --git a/pywwt/tests/test_core.py b/pywwt/tests/test_core.py index aa7fd6b..6a3fbb3 100644 --- a/pywwt/tests/test_core.py +++ b/pywwt/tests/test_core.py @@ -5,7 +5,7 @@ from traitlets import TraitError from ..core import BaseWWTWidget, DEFAULT_SURVEYS_URL -WWT_HTML_FILE = os.path.join(os.path.dirname(__file__), '..', 'static', 'wwt.html') +WWT_HTML_FILE = os.path.join(os.path.dirname(__file__), '..', 'nbextension', 'static', 'wwt.html') with open(WWT_HTML_FILE) as f: WWT_HTML = f.read() diff --git a/setup.py b/setup.py index 03050f8..2533c95 100755 --- a/setup.py +++ b/setup.py @@ -5,6 +5,7 @@ # Distributed under the terms of the Modified BSD License. from __future__ import print_function +import os from glob import glob from os.path import join as pjoin @@ -47,8 +48,10 @@ data_files_spec = [ ('share/jupyter/nbextensions/pywwt', nb_path, '*.js*'), ('share/jupyter/lab/extensions', lab_path, '*.tgz'), - ('etc/jupyter/nbconfig/notebook.d' , HERE, 'pywwt.json') -] + ('etc/jupyter/nbconfig/notebook.d' , + os.path.join(HERE, 'jupyter.d', 'notebook.d'), 'pywwt.json'), + ('etc/jupyter/jupyter_notebook_config.d' , + os.path.join(HERE, 'jupyter.d', 'jupyter_notebook_config.d'), 'pywwt.json')] cmdclass = create_cmdclass('jsdeps', package_data_spec=package_data_spec,