diff --git a/.check_enabled.py b/.check_enabled.py index e943869b..05eddc24 100644 --- a/.check_enabled.py +++ b/.check_enabled.py @@ -2,22 +2,32 @@ import sys from jupyterlab.commands import get_app_info -from notebook.nbextensions import validate_nbextension -from notebook.serverextensions import validate_serverextension + +try: + from nbclassic.nbextensions import validate_nbextension +except ImportError: + # `notebook` <= 6 + from notebook.nbextensions import validate_nbextension + +try: + from nbclassic.serverextensions import validate_serverextension +except ImportError: + # `notebook` <= 6 + from notebook.serverextensions import validate_serverextension # If there's a problem and we don't provide this, the validate function crashes :-( -logger = logging.getLogger('') +logger = logging.getLogger("") -if validate_nbextension('pywwt/extension', logger=logger) != []: +if validate_nbextension("pywwt/extension", logger=logger) != []: print("Issue detected with nbextension") sys.exit(1) info = get_app_info() -if 'pywwt' not in info['extensions'] or 'pywwt' in info['disabled']: +if "pywwt" not in info["extensions"] or "pywwt" in info["disabled"]: print("Issue detected with labextension") sys.exit(1) -if validate_serverextension('pywwt', logger=logger) != []: +if validate_serverextension("pywwt", logger=logger) != []: print("Issue detected with serverextension") sys.exit(1) diff --git a/.readthedocs_env.yml b/.readthedocs_env.yml index 5f5ade13..72ca5299 100644 --- a/.readthedocs_env.yml +++ b/.readthedocs_env.yml @@ -14,6 +14,7 @@ dependencies: - krb5 - lxml - matplotlib + - nbclassic - nodejs - notebook - numpydoc diff --git a/CHANGELOG.md b/CHANGELOG.md index 70722a8e..6f47c53e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# pypa:pywwt 0.21.0 (2023-07-28) + +- Update `pywwt` to work with version 7 of the Jupyter `notebook` package (#356, + @Carifio24, @pkgw). This new version is a major update on the Jupyter side, + but it is only used in a few minor places within `pywwt`. The `pywwt` package + should remain compatible with older versions of `notebook`. +- Fix pywwt’s default ecliptic grid color to match the engine (#356, + @Carifio24). + + # pypa:pywwt 0.20.0 (2023-07-06) - Expose new engine settings relating to the display of constellations, diff --git a/ci/azure-build-and-test.yml b/ci/azure-build-and-test.yml index 3b0ad53f..b3504e92 100644 --- a/ci/azure-build-and-test.yml +++ b/ci/azure-build-and-test.yml @@ -144,9 +144,9 @@ jobs: source activate-conda.sh conda activate build set -x - \conda install -y jupyterlab jupyter_contrib_nbextensions - jupyter nbextension list - jupyter serverextension list + \conda install -y jupyterlab nbclassic + jupyter nbclassic-extension list + jupyter nbclassic-serverextension list jupyter labextension list displayName: Print Jupyter extension status diff --git a/ci/zenodo.json5 b/ci/zenodo.json5 index b15c201f..a58fc616 100644 --- a/ci/zenodo.json5 +++ b/ci/zenodo.json5 @@ -61,13 +61,13 @@ ], "language": "eng", "license": "BSD-3-Clause", - "publication_date": "2023-07-06", - "title": "pypa:pywwt 0.20.0", + "publication_date": "2023-07-28", + "title": "pypa:pywwt 0.21.0", "upload_type": "software", - "version": "0.20.0" + "version": "0.21.0" }, "conceptdoi": "10.5281/zenodo.7164147", - "record_id": "8120820", - "doi": "10.5281/zenodo.8120820", - "bucket_link": "https://zenodo.org/api/files/a0907e42-079d-4015-bc52-955559160589" + "record_id": "8193603", + "doi": "10.5281/zenodo.8193603", + "bucket_link": "https://zenodo.org/api/files/7fe44d30-f757-497f-8468-df0bf078b6af" } diff --git a/docs/installation.rst b/docs/installation.rst index 09023323..e4d4d070 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -244,13 +244,18 @@ this repository and install the package manually (note that this requires `npm cd pywwt pip install -e . -If you want to use the Jupyter widget, you will also need to run:: - - jupyter nbextension install --py --symlink --sys-prefix pywwt - jupyter nbextension enable --py --sys-prefix pywwt - jupyter nbextension list # check that the output shows pywwt as enabled and OK - jupyter serverextension enable --py --sys-prefix pywwt - jupyter serverextension list # check that the output shows pywwt as enabled and OK +If you want to use the Jupyter widget with a recent installation of the Jupyter +stack, you will also need to run:: + + jupyter nbclassic-extension install --py --symlink --sys-prefix pywwt + jupyter nbclassic-extension enable --py --sys-prefix pywwt + jupyter nbclassic-extension list # check that the output shows pywwt as enabled and OK + jupyter nbclassic-serverextension enable --py --sys-prefix pywwt + jupyter nbclassic-serverextension list # check that the output shows pywwt as enabled and OK + +On older versions of Jupyter, use the ``nbextension`` subcommand instead of +``nbclassic-extension``, and use just ``serverextension`` instead of +``nbclassic-serverextension``. And if you additionally want to use the widget in JupyterLab, run:: diff --git a/pywwt/_version.py b/pywwt/_version.py index e6eb5f91..81dd459a 100644 --- a/pywwt/_version.py +++ b/pywwt/_version.py @@ -1,4 +1,4 @@ -version_info = (0, 20, 0, 'final', 0) # cranko project-version tuple +version_info = (0, 21, 0, 'final', 0) # cranko project-version tuple _specifier_ = { "alpha": ".a", @@ -18,5 +18,5 @@ ) # The strings are auto-updated by Cranko during formal releases: -version_doi = "10.5281/zenodo.8120820" +version_doi = "10.5281/zenodo.8193603" concept_doi = "10.5281/zenodo.7164147" diff --git a/pywwt/core.py b/pywwt/core.py index 9caad63f..cc29fd7e 100644 --- a/pywwt/core.py +++ b/pywwt/core.py @@ -680,7 +680,7 @@ def instruments(self): ).tag(wwt="showEclipticGrid", wwt_reset=True) ecliptic_grid_color = Color( - "blue", help="The color of the ecliptic grid " "(`str` or `tuple`)" + "green", help="The color of the ecliptic grid " "(`str` or `tuple`)" ).tag(wwt="eclipticGridColor", wwt_reset=True) ecliptic_text = Bool( diff --git a/pywwt/jupyter_relay.py b/pywwt/jupyter_relay.py index fc60c76e..1573b31a 100644 --- a/pywwt/jupyter_relay.py +++ b/pywwt/jupyter_relay.py @@ -519,11 +519,16 @@ def get_relay_hub(kernel=None): def _list_running_servers_jl3(): import io import json - from notebook.utils import check_pid from jupyter_core.paths import jupyter_runtime_dir import os.path import re + try: + from jupyter_server.utils import check_pid + except ImportError: + # `notebook` <= 6 + from notebook.utils import check_pid + runtime_dir = jupyter_runtime_dir() if not os.path.isdir(runtime_dir): diff --git a/pywwt/jupyter_server.py b/pywwt/jupyter_server.py index 053009c9..a89c60df 100644 --- a/pywwt/jupyter_server.py +++ b/pywwt/jupyter_server.py @@ -19,12 +19,21 @@ # so let's try to fail gracefully if Jupyter modules are missing. `tornado` is a # hard requirement appearing in setup.py. try: - from notebook.utils import url_path_join - from notebook.base.handlers import IPythonHandler + try: + from jupyter_server.utils import url_path_join + except ImportError: + # `notebook` <= 6 + from notebook.utils import url_path_join + + try: + from jupyter_server.base.handlers import JupyterHandler + except ImportError: + # `notebook` <= 6 + from notebook.base.handlers import IPythonHandler as JupyterHandler HAVE_NOTEBOOK = True except ImportError: - IPythonHandler = object + JupyterHandler = object HAVE_NOTEBOOK = False __all__ = [ @@ -35,7 +44,7 @@ STATIC_DIR = os.path.join(os.path.dirname(__file__), "web_static") -class WWTStaticFileHandler(IPythonHandler): +class WWTStaticFileHandler(JupyterHandler): def get(self, filename): static_path = os.path.join(STATIC_DIR, filename)