From 7f28567ea1552474a363082eae0025f72134bf08 Mon Sep 17 00:00:00 2001 From: Tim Paine Date: Wed, 15 Mar 2023 14:02:16 -0400 Subject: [PATCH] Add some fixes to enable prebuilt in classic notebook --- .gitignore | 1 - packages/perspective-jupyterlab/build.js | 11 ++-- packages/perspective-jupyterlab/package.json | 2 +- .../src/js/notebook/extension.js | 8 ++- .../src/js/notebook/index.js | 9 +++- python/perspective/README.md | 1 + .../perspective/extension/install.json | 5 ++ python/perspective/pyproject.toml | 13 ++++- python/perspective/setup.cfg | 10 ---- python/perspective/setup.py | 53 ++++++++----------- scripts/lint_python.js | 2 +- scripts/script_utils.js | 5 +- yarn.lock | 47 ++++++++-------- 13 files changed, 90 insertions(+), 77 deletions(-) create mode 120000 python/perspective/README.md create mode 100644 python/perspective/perspective/extension/install.json diff --git a/.gitignore b/.gitignore index 3e7a2063cc..81ea5b1dad 100644 --- a/.gitignore +++ b/.gitignore @@ -170,7 +170,6 @@ python/perspective/perspective/tests/table/psp_test python/perspective/perspective/node/assets/* /__pycache__ python/perspective/pip-wheel-metadata -python/perspective/README.md python/perspective/python_junit.xml python/perspective/coverage.xml python/perspective/bench/stresstest/results diff --git a/packages/perspective-jupyterlab/build.js b/packages/perspective-jupyterlab/build.js index 4f4f8233a2..c18adbba3d 100644 --- a/packages/perspective-jupyterlab/build.js +++ b/packages/perspective-jupyterlab/build.js @@ -62,7 +62,11 @@ const NB_BUILDS = [ define: { global: "window", }, - plugins: [WasmPlugin(true), WorkerPlugin(true), AMDLoader([])], + plugins: [ + WasmPlugin(true), + WorkerPlugin({ inline: true }), + AMDLoader([]), + ], loader: { ".ttf": "file", ".css": "text", @@ -78,13 +82,14 @@ const NB_BUILDS = [ }, plugins: [ WasmPlugin(true), - WorkerPlugin(true), - AMDLoader([`@jupyter-widgets/base`]), + WorkerPlugin({ inline: true }), + AMDLoader(["@jupyter-widgets/base"]), ], external: ["@jupyter*"], format: "cjs", loader: { ".ttf": "file", + ".css": "text", }, outfile: path.join(NBEXTENSION_PATH, "index.js"), }, diff --git a/packages/perspective-jupyterlab/package.json b/packages/perspective-jupyterlab/package.json index b5b750613e..7771851601 100644 --- a/packages/perspective-jupyterlab/package.json +++ b/packages/perspective-jupyterlab/package.json @@ -42,7 +42,7 @@ "@finos/perspective-viewer-d3fc": "^1.9.4", "@finos/perspective-viewer-datagrid": "^1.9.4", "@finos/perspective-viewer-openlayers": "^1.9.4", - "@jupyter-widgets/base": "^6", + "@jupyter-widgets/base": "^2 || ^3 || ^4 || ^5 || ^6", "@jupyterlab/application": "^3.6.1", "@lumino/application": "^1.27.0", "@lumino/widgets": "^1.37.0" diff --git a/packages/perspective-jupyterlab/src/js/notebook/extension.js b/packages/perspective-jupyterlab/src/js/notebook/extension.js index cd053d94d6..d636059857 100644 --- a/packages/perspective-jupyterlab/src/js/notebook/extension.js +++ b/packages/perspective-jupyterlab/src/js/notebook/extension.js @@ -17,6 +17,8 @@ // url for the notebook is not known at build time and is therefore computed // dynamically. +import THEMES from "../../../dist/css/perspective-jupyterlab.css"; + if (window.require) { window.require.config({ map: { @@ -29,4 +31,8 @@ if (window.require) { } // Export the required load_ipython_extension -export function load_ipython_extension() {} +exports.load_ipython_extension = () => { + const style = document.createElement("style"); + style.textContent = THEMES; + document.head.appendChild(style); +}; diff --git a/packages/perspective-jupyterlab/src/js/notebook/index.js b/packages/perspective-jupyterlab/src/js/notebook/index.js index 4b08a12c96..997c540fe5 100644 --- a/packages/perspective-jupyterlab/src/js/notebook/index.js +++ b/packages/perspective-jupyterlab/src/js/notebook/index.js @@ -9,5 +9,10 @@ import "@finos/perspective-viewer-datagrid"; import "@finos/perspective-viewer-d3fc"; -export { PerspectiveView } from "../view"; -export { PerspectiveModel } from "../model"; +import "@finos/perspective-viewer-openlayers/dist/umd/perspective-viewer-openlayers.js"; + +import { PerspectiveView } from "../view"; +import { PerspectiveModel } from "../model"; + +exports.PerspectiveModel = PerspectiveModel; +exports.PerspectiveView = PerspectiveView; diff --git a/python/perspective/README.md b/python/perspective/README.md new file mode 120000 index 0000000000..fe84005413 --- /dev/null +++ b/python/perspective/README.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/python/perspective/perspective/extension/install.json b/python/perspective/perspective/extension/install.json new file mode 100644 index 0000000000..1066bfef50 --- /dev/null +++ b/python/perspective/perspective/extension/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "perspective-python", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package perspective-python" +} \ No newline at end of file diff --git a/python/perspective/pyproject.toml b/python/perspective/pyproject.toml index 069eec233a..574ba0310f 100644 --- a/python/perspective/pyproject.toml +++ b/python/perspective/pyproject.toml @@ -3,8 +3,19 @@ requires = [ "setuptools", "wheel", "numpy>=1.13.1,<2", - "jupyter-packaging==0.12.0", + "jupyter-packaging==0.12.3", ] +build-backend = "jupyter_packaging.build_api" [tool.black] exclude = "perspective/tests/*" + +[tool.check-manifest] +ignore = [ + "dist/**", + "perspective/table/*.so", + "perspective/table/*.pyd", + "perspective/table/*.dll", + "perspective/labextension/**", + "perspective/nbextension/perspective-nbextension.js ", +] diff --git a/python/perspective/setup.cfg b/python/perspective/setup.cfg index 81f499663b..8c1f02523c 100644 --- a/python/perspective/setup.cfg +++ b/python/perspective/setup.cfg @@ -20,13 +20,3 @@ per-file-ignores = asyncio_mode=strict testpaths = perspective/tests - -[check-manifest] -# ignore files legitimately missing in VCS -ignore = - dist/** - perspective/table/*.so - perspective/table/*.pyd - perspective/table/*.dll - perspective/labextension/** - perspective/nbextension/perspective-nbextension.js diff --git a/python/perspective/setup.py b/python/perspective/setup.py index 99c448adec..a8dab13c08 100644 --- a/python/perspective/setup.py +++ b/python/perspective/setup.py @@ -16,6 +16,7 @@ import sysconfig from codecs import open from distutils.version import LooseVersion +from jupyter_packaging import get_data_files, wrap_installers, get_version from setuptools import Extension, find_packages, setup from setuptools.command.build_ext import build_ext @@ -28,14 +29,6 @@ except ImportError: raise Exception("Requires Python 3.7 or later") -# try/except on jupyter_packaging to allow setup.py to be evaluated -try: - from jupyter_packaging import get_version -except ImportError: - - def get_version(file): - return "0.0.0" - here = os.path.abspath(os.path.dirname(__file__)) nb_path = os.path.join("perspective", "nbextension", "static") @@ -309,31 +302,28 @@ def run_check(self): "perspective/labextension", "**", ), + # Labextension install command + ( + "share/jupyter/labextensions/@finos/perspective-jupyterlab", + "perspective/extension", + "install.json", + ), ] -try: - from jupyter_packaging import ( - combine_commands, - create_cmdclass, - ensure_targets, - ) - - cmdclass = create_cmdclass("js", data_files_spec=data_files_spec) - cmdclass["js"] = combine_commands( - ensure_targets( - [] - if SKIP_JS_FILES - else [ - os.path.join("perspective", "nbextension", "static", "index.js"), - os.path.join("perspective", "labextension", "package.json"), - os.path.join("perspective", "labextension", "static", "style.js"), - ] - ), - ) - cmdclass["build_ext"] = PSPBuild - cmdclass["sdist"] = combine_commands(cmdclass["sdist"], PSPCheckSDist) -except ImportError: - cmdclass = {} +ensured_targets = ( + [] + if SKIP_JS_FILES + else [ + os.path.join("perspective", "nbextension", "static", "index.js"), + os.path.join("perspective", "labextension", "package.json"), + os.path.join("perspective", "labextension", "static", "style.js"), + ] +) + +cmdclass = {} +cmdclass["js"] = wrap_installers(ensured_targets=ensured_targets) +cmdclass["build_ext"] = PSPBuild +cmdclass["sdist"] = PSPCheckSDist setup( @@ -355,6 +345,7 @@ def run_check(self): ], keywords="analytics tools plotting", packages=find_packages(exclude=["bench", "bench.*"]), + data_files=get_data_files(data_files_spec), include_package_data=True, zip_safe=False, python_requires=">=3.7", diff --git a/scripts/lint_python.js b/scripts/lint_python.js index 70a359023e..58f7b958b5 100644 --- a/scripts/lint_python.js +++ b/scripts/lint_python.js @@ -44,7 +44,7 @@ try { let cmd; let lint_cmd = "flake8 perspective bench setup.py"; let fix_cmd = "black perspective bench setup.py --exclude tests"; - let check_cmd = "check-manifest"; + let check_cmd = "check-manifest -v ."; if (CMD_TYPE === "fix") { cmd = fix_cmd; diff --git a/scripts/script_utils.js b/scripts/script_utils.js index 36da7eb789..25d9c61234 100644 --- a/scripts/script_utils.js +++ b/scripts/script_utils.js @@ -449,13 +449,12 @@ exports.copy_files_to_python_folder = () => { const dist = resolve`${__dirname}/../python/perspective/dist`; const cpp = resolve`${__dirname}/../cpp/perspective/src`; const cmakelists = resolve`${__dirname}/../cpp/perspective/CMakeLists.txt`; - const lic = resolve`${__dirname}/../LICENSE`; - const readme = resolve`${__dirname}/../README.md`; const cmake = resolve`${__dirname}/../cmake`; const dcmake = resolve`${dist}/cmake`; + + const lic = resolve`${__dirname}/../LICENSE`; const dlic = resolve`${dist}/LICENSE`; - const dreadme = resolve`${dist}/../README.md`; fse.mkdirpSync(dist); fse.copySync(cmakelists, resolve`${dist}/CMakeLists.txt`, { diff --git a/yarn.lock b/yarn.lock index 6031d797ed..b7a85f069e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3271,18 +3271,19 @@ dependencies: lodash "^4.17.21" -"@jupyter-widgets/base@^6": - version "6.0.2" - resolved "https://registry.yarnpkg.com/@jupyter-widgets/base/-/base-6.0.2.tgz#ee6e614eb70f2593fce61eea8731217d869c5a2a" - integrity sha512-CIVjSTrqQFzkg9VCdDjrjDqwbba3eZfNigCPFSuKmMVXc+ATAOFczOv9/9uaCPzQ+E+0g6SOLhJ25SpKB0cl9g== +"@jupyter-widgets/base@^2 || ^3 || ^4 || ^5 || ^6": + version "4.1.2" + resolved "https://registry.yarnpkg.com/@jupyter-widgets/base/-/base-4.1.2.tgz#b0b1d94232b8e54c77d11c21de4127ca2e22fd69" + integrity sha512-URaQ6rUR0ZC1G1g0pSZHcV8W9x5pK/FnC/zSF5/i2QHmjLVfwVRBFt7a8VL88xZG8V4G8tOIDZTTg1NZcHfB0A== dependencies: "@jupyterlab/services" "^6.0.0" - "@lumino/coreutils" "^1.11.1" - "@lumino/messaging" "^1.10.1" - "@lumino/widgets" "^1.30.0" - "@types/backbone" "1.4.14" + "@lumino/coreutils" "^1.2.0" + "@lumino/messaging" "^1.2.1" + "@lumino/widgets" "^1.3.0" + "@types/backbone" "^1.4.1" "@types/lodash" "^4.14.134" - backbone "1.4.0" + backbone "1.2.3" + base64-js "^1.2.1" jquery "^3.1.1" lodash "^4.17.4" @@ -3804,7 +3805,7 @@ resolved "https://registry.yarnpkg.com/@lumino/coreutils/-/coreutils-1.12.0.tgz#fbdef760f736eaf2bd396a5c6fc3a68a4b449b15" integrity sha512-DSglh4ylmLi820CNx9soJmDJCpUgymckdWeGWuN0Ash5g60oQvrQDfosVxEhzmNvtvXv45WZEqSBzDP6E5SEmQ== -"@lumino/coreutils@^1.11.0 || ^2.0.0-alpha.6", "@lumino/coreutils@^1.11.1", "@lumino/coreutils@^1.12.1": +"@lumino/coreutils@^1.11.0 || ^2.0.0-alpha.6", "@lumino/coreutils@^1.12.1", "@lumino/coreutils@^1.2.0": version "1.12.1" resolved "https://registry.yarnpkg.com/@lumino/coreutils/-/coreutils-1.12.1.tgz#79860c9937483ddf6cda87f6c2b9da8eb1a5d768" integrity sha512-JLu3nTHzJk9N8ohZ85u75YxemMrmDzJdNgZztfP7F7T7mxND3YVNCkJG35a6aJ7edu1sIgCjBxOvV+hv27iYvQ== @@ -3869,7 +3870,7 @@ "@lumino/algorithm" "^1.9.1" "@lumino/collections" "^1.9.1" -"@lumino/messaging@^1.10.3": +"@lumino/messaging@^1.10.3", "@lumino/messaging@^1.2.1": version "1.10.3" resolved "https://registry.yarnpkg.com/@lumino/messaging/-/messaging-1.10.3.tgz#b6227bdfc178a8542571625ecb68063691b6af3c" integrity sha512-F/KOwMCdqvdEG8CYAJcBSadzp6aI7a47Fr60zAKGqZATSRRRV41q53iXU7HjFPqQqQIvdn9Z7J32rBEAyQAzww== @@ -3934,7 +3935,7 @@ dependencies: "@lumino/algorithm" "^1.9.2" -"@lumino/widgets@^1.30.0", "@lumino/widgets@^1.37.0", "@lumino/widgets@^1.37.1": +"@lumino/widgets@^1.3.0", "@lumino/widgets@^1.37.0", "@lumino/widgets@^1.37.1": version "1.37.1" resolved "https://registry.yarnpkg.com/@lumino/widgets/-/widgets-1.37.1.tgz#d7a2398b276e15e60aff4fec58c035d46549a75b" integrity sha512-/whz5B/hL0fjv0bR8JYZ+Emx+CH7HBwXc4TqI9PrrHGm3g6+jRJAyIFGZcQubqkPxxHrRE/VxQgoDKGhINw/Gw== @@ -4536,10 +4537,10 @@ dependencies: "@babel/types" "^7.3.0" -"@types/backbone@1.4.14": - version "1.4.14" - resolved "https://registry.yarnpkg.com/@types/backbone/-/backbone-1.4.14.tgz#4b71f0c25d89cfa9a10b18042f0b03d35a53364c" - integrity sha512-85ldQ99fiYTJFBlZuAJRaCdvTZKZ2p1fSs3fVf+6Ub6k1X0g0hNJ0qJ/2FOByyyAQYLtbEz3shX5taKQfBKBDw== +"@types/backbone@^1.4.1": + version "1.4.15" + resolved "https://registry.yarnpkg.com/@types/backbone/-/backbone-1.4.15.tgz#505323ab8fea11ecaec74cb3f73d569a4e5eb779" + integrity sha512-WWeKtYlsIMtDyLbbhkb96taJMEbfQBnuz7yw1u0pkphCOtksemoWhIXhK74VRCY9hbjnsH3rsJu2uUiFtnsEYg== dependencies: "@types/jquery" "*" "@types/underscore" "*" @@ -5976,12 +5977,12 @@ babel-preset-jest@^25.5.0: babel-plugin-jest-hoist "^25.5.0" babel-preset-current-node-syntax "^0.1.2" -backbone@1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/backbone/-/backbone-1.4.0.tgz#54db4de9df7c3811c3f032f34749a4cd27f3bd12" - integrity sha512-RLmDrRXkVdouTg38jcgHhyQ/2zjg7a8E6sz2zxfz21Hh17xDJYUHBZimVIt5fUyS8vbfpeSmTL3gUjTEvUV3qQ== +backbone@1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/backbone/-/backbone-1.2.3.tgz#c22cfd07fc86ebbeae61d18929ed115e999d65b9" + integrity sha512-1/eXj4agG79UDN7TWnZXcGD6BJrBwLZKCX7zYcBIy9jWf4mrtVkw7IE1VOYFnrKahsmPF9L55Tib9IQRvk027w== dependencies: - underscore ">=1.8.3" + underscore ">=1.7.0" bail@^1.0.0: version "1.0.5" @@ -6003,7 +6004,7 @@ base16@^1.0.0: resolved "https://registry.yarnpkg.com/base16/-/base16-1.0.0.tgz#e297f60d7ec1014a7a971a39ebc8a98c0b681e70" integrity sha512-pNdYkNPiJUnEhnfXV56+sQy8+AaPcG3POZAUnwr4EeqCUZFz4u2PePbo3e5Gj4ziYPCWGUZT9RHisvJKnwFuBQ== -base64-js@^1.0.2, base64-js@^1.2.3, base64-js@^1.3.1: +base64-js@^1.0.2, base64-js@^1.2.1, base64-js@^1.2.3, base64-js@^1.3.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== @@ -17794,7 +17795,7 @@ unbzip2-stream@1.4.3, unbzip2-stream@^1.0.9: buffer "^5.2.1" through "^2.3.8" -underscore@>=1.8.3, underscore@~1.13.2: +underscore@>=1.7.0, underscore@~1.13.2: version "1.13.6" resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.6.tgz#04786a1f589dc6c09f761fc5f45b89e935136441" integrity sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==