From b16f2ec8c8c1e9a8d2b855cd702956a4ab50ee99 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Sat, 23 Oct 2021 13:18:13 -0400 Subject: [PATCH 1/2] Add drop-in configuration files to activate the server extension --- MANIFEST.in | 4 + .../nb-config/wwt_kernel_data_relay.json | 7 + .../server-config/wwt_kernel_data_relay.json | 7 + pyproject.toml | 4 + setup.py | 126 +++++++++++------- 5 files changed, 99 insertions(+), 49 deletions(-) create mode 100644 jupyter-config/nb-config/wwt_kernel_data_relay.json create mode 100644 jupyter-config/server-config/wwt_kernel_data_relay.json diff --git a/MANIFEST.in b/MANIFEST.in index 1c85f17..5ac104e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,6 @@ +include CHANGELOG.md include LICENSE +include README.md include .coveragerc include *.md include *.yml @@ -6,6 +8,8 @@ include *.yml graft docs prune docs/_build +recursive-include jupyter-config *.json + graft wwt_kernel_data_relay/tests global-exclude *~ diff --git a/jupyter-config/nb-config/wwt_kernel_data_relay.json b/jupyter-config/nb-config/wwt_kernel_data_relay.json new file mode 100644 index 0000000..5c58ec1 --- /dev/null +++ b/jupyter-config/nb-config/wwt_kernel_data_relay.json @@ -0,0 +1,7 @@ +{ + "NotebookApp": { + "nbserver_extensions": { + "wwt_kernel_data_relay": true + } + } +} \ No newline at end of file diff --git a/jupyter-config/server-config/wwt_kernel_data_relay.json b/jupyter-config/server-config/wwt_kernel_data_relay.json new file mode 100644 index 0000000..718cec4 --- /dev/null +++ b/jupyter-config/server-config/wwt_kernel_data_relay.json @@ -0,0 +1,7 @@ +{ + "ServerApp": { + "jpserver_extensions": { + "wwt_kernel_data_relay": true + } + } +} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 527a2db..73960d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,7 @@ +[build-system] +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.1"] +build-backend = "jupyter_packaging.build_api" + [tool.cranko] extra_python_rewrite_files = [ "docs/conf.py" diff --git a/setup.py b/setup.py index 0c0195a..b18c763 100644 --- a/setup.py +++ b/setup.py @@ -2,83 +2,111 @@ # Copyright 2019-2021 the .NET Foundation # Licensed under the MIT License -import os -from setuptools import setup, Extension +import sys +from setuptools import setup + def get_long_desc(): in_preamble = True lines = [] - with open('README.md', 'rt', encoding='utf8') as f: + with open("README.md", "rt", encoding="utf8") as f: for line in f: if in_preamble: - if line.startswith(''): + if line.startswith(""): in_preamble = False else: - if line.startswith(''): + if line.startswith(""): break else: lines.append(line) - lines.append(''' + lines.append( + """ For more information, including installation instructions, please visit [the project homepage]. [the project homepage]: https://github.com/WorldWideTelescope/wwt_kernel_data_relay/ -''') - return ''.join(lines) +""" + ) + return "".join(lines) + + +data_files_spec = [ + ( + "etc/jupyter/jupyter_server_config.d", + "jupyter-config/server-config", + "wwt_kernel_data_relay.json", + ), + # For backward compatibility with notebook server: + ( + "etc/jupyter/jupyter_notebook_config.d", + "jupyter-config/nb-config", + "wwt_kernel_data_relay.json", + ), +] setup_args = dict( - name = 'wwt_kernel_data_relay', # cranko project-name - version = '0.dev0', # cranko project-version - description = 'Jupyter server extension to allow kernels to make data web-accessible', - long_description = get_long_desc(), - long_description_content_type = 'text/markdown', - url = 'https://github.com/WorldWideTelescope/wwt_kernel_data_relay/', - license = 'MIT', - platforms = 'Linux, Mac OS X, Windows', - - author = 'AAS WorldWide Telescope Team', - author_email = 'wwt@aas.org', - - classifiers = [ - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Topic :: Scientific/Engineering :: Astronomy', - 'Topic :: Scientific/Engineering :: Visualization', + name="wwt_kernel_data_relay", # cranko project-name + version="0.dev0", # cranko project-version + description="Jupyter server extension to allow kernels to make data web-accessible", + long_description=get_long_desc(), + long_description_content_type="text/markdown", + url="https://github.com/WorldWideTelescope/wwt_kernel_data_relay/", + license="MIT", + platforms="Linux, Mac OS X, Windows", + author="AAS WorldWide Telescope Team", + author_email="wwt@aas.org", + classifiers=[ + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Topic :: Scientific/Engineering :: Astronomy", + "Topic :: Scientific/Engineering :: Visualization", ], - - packages = [ - 'wwt_kernel_data_relay', + packages=[ + "wwt_kernel_data_relay", #'wwt_kernel_data_relay.tests', ], - include_package_data = True, - - install_requires = [ - 'jupyter-client>=7', - 'notebook>=6', - 'tornado>=6', - 'traitlets>=5', + include_package_data=True, + install_requires=[ + "jupyter-client>=7", + "notebook>=6", + "tornado>=6", + "traitlets>=5", ], - - extras_require = { - 'test': [ - 'pytest-cov', + extras_require={ + "test": [ + "pytest-cov", ], - 'docs': [ - 'astropy-sphinx-theme', - 'numpydoc', - 'sphinx', - 'sphinx-automodapi', + "docs": [ + "astropy-sphinx-theme", + "numpydoc", + "sphinx", + "sphinx-automodapi", ], }, ) -if __name__ == '__main__': +try: + from jupyter_packaging import get_data_files + + setup_args["data_files"] = get_data_files(data_files_spec) +except ImportError as e: + import logging + + logging.basicConfig(format="%(levelname)s: %(message)s") + logging.warning( + "Build tool `jupyter-packaging` is missing. Install it with pip or conda." + ) + if not ("--name" in sys.argv or "--version" in sys.argv): + raise e + + +if __name__ == "__main__": setup(**setup_args) From 19314b9a9828686b7501fc51c8ebb0b8c01ec866 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Sat, 23 Oct 2021 13:25:44 -0400 Subject: [PATCH 2/2] ci: install jupyter-packaging for Python stuff --- ci/azure-build-and-test.yml | 4 ++-- ci/azure-sdist.yml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ci/azure-build-and-test.yml b/ci/azure-build-and-test.yml index 7e784b8..2396fbd 100644 --- a/ci/azure-build-and-test.yml +++ b/ci/azure-build-and-test.yml @@ -37,7 +37,7 @@ jobs: set -euo pipefail source activate-conda.sh set -x - \conda create -y -n build setuptools pip python="$PYTHON_SERIES" + \conda create -y -n build jupyter-packaging setuptools pip python="$PYTHON_SERIES" conda activate build pip install $BASH_WORKSPACE/sdist/*.tar.gz displayName: Install from sdist @@ -64,7 +64,7 @@ jobs: set -euo pipefail source activate-conda.sh set -x - \conda create -y -n build setuptools pip python=3.9 + \conda create -y -n build jupyter-packaging setuptools pip python=3.9 conda activate build pip install $BASH_WORKSPACE/sdist/*.tar.gz displayName: Install from sdist diff --git a/ci/azure-sdist.yml b/ci/azure-sdist.yml index 6ba95a6..f4e3d3c 100644 --- a/ci/azure-sdist.yml +++ b/ci/azure-sdist.yml @@ -53,6 +53,7 @@ jobs: conda config --add channels conda-forge conda install -y \ jupyter_client \ + jupyter-packaging \ notebook \ tornado \ traitlets