diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 224751b1..9670f053 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -87,7 +87,10 @@ jobs: ${{ runner.os }}-pip- - name: Install the Python dependencies if: steps.filter.outputs.extension == 'true' - run: python -m pip install jupyterlab + run: | + python -m pip install --upgrade pip + python -m pip install jupyter_packaging + python -m pip install jupyterlab - name: Install the NPM dependencies if: steps.filter.outputs.extension == 'true' run: | @@ -108,9 +111,12 @@ jobs: if: steps.filter.outputs.extension == 'true' run: | cd ${EXAMPLE_FOLDER} - jlpm run build - jupyter labextension install . + pip install -e . + jupyter labextension list 1>labextensions 2>&1 + cat labextensions + cat labextensions | grep -i "@jupyterlab-examples/*.*OK" python -m jupyterlab.browser_check + pip uninstall -y $(python setup.py --name) env: EXAMPLE_FOLDER: ${{ matrix.example }} shell: bash @@ -176,6 +182,7 @@ jobs: - name: Install the Python dependencies if: steps.filter.outputs.extension == 'true' run: | + python -m pip install --upgrade pip python -m pip install jupyter_packaging python -m pip install jupyterlab - name: Install the NPM dependencies @@ -194,13 +201,12 @@ jobs: run: | cd advanced/server-extension python setup.py sdist - pip install jlab_ext_example --pre --find-links=dist --no-cache-dir - jupyter lab build + pip install ./dist/jlab_ext_example* --pre --find-links=dist --no-cache-dir python -m jupyterlab.browser_check - name: Check extension as dev if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') ) run: | - jupyter serverextension list 1>serverextensions 2>&1 + jupyter server extension list 1>serverextensions 2>&1 cat serverextensions | grep "jlab_ext_example.*OK" jupyter labextension list 1>labextensions 2>&1 cat labextensions | grep "@jupyterlab-examples/server-extension.*OK" @@ -209,19 +215,18 @@ jobs: run: | pip uninstall -y jlab_ext_example jupyter lab clean - jupyter serverextension list + jupyter server extension list jupyter labextension list - name: Build extension as dev if: steps.filter.outputs.extension == 'true' run: | cd advanced/server-extension pip install -e . - jupyter serverextension enable --py jlab_ext_example - jupyter labextension install . + jupyter server extension enable --py jlab_ext_example - name: Check extension as dev if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') ) run: | - jupyter serverextension list 1>serverextensions 2>&1 + jupyter server extension list 1>serverextensions 2>&1 cat serverextensions | grep "jlab_ext_example.*OK" jupyter labextension list 1>labextensions 2>&1 cat labextensions | grep "@jupyterlab-examples/server-extension.*OK" @@ -275,4 +280,3 @@ jobs: jlpm build-ext jlpm lint:check jlpm install-ext - jlpm build-jlab diff --git a/.gitignore b/.gitignore index 8f0a97df..a39dd1f9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,10 @@ node_modules/ .ipynb_checkpoints *.tsbuildinfo *.lock +__pycache__ + # Ensure embedme does not run ont node_modules README.md files. **/node_modules/**/README.md + +static +labextension diff --git a/.prettierignore b/.prettierignore index 8103ecd2..5c6e45ce 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,3 +2,4 @@ node_modules **/node_modules **/lib **/package.json +**/labextension diff --git a/README.md b/README.md index 5fc78936..c6b535f1 100644 --- a/README.md +++ b/README.md @@ -10,18 +10,41 @@ The goal of this repository is to show how to develop extensions for [JupyterLab To get started: ```bash -git clone https://github.com/jupyterlab/extension-examples.git jupyterlab-extension-examples && \ - cd jupyterlab-extension-examples && \ - conda env create && \ - conda activate jupyterlab-extension-examples && \ - cd basics/hello-world && \ - jlpm && \ - jlpm run build && \ - jupyter labextension install . && \ - jupyter lab +# clone the repository +git clone https://github.com/jupyterlab/extension-examples.git jupyterlab-extension-examples + +# go to the extension examples folder +cd jupyterlab-extension-examples + +# create a new environment +conda env create + +# activate the environment +conda activate jupyterlab-extension-examples + +# go to the hello world example +cd basics/hello-world + +# install the extension in editable mode +python -m pip install -e . + +# install your development version of the extension with JupyterLab +jupyter labextension develop . --overwrite + +# build the TypeScript source after making changes +jlpm run build + +# start JupyterLab +jupyter lab ``` -The examples currently target **JupyterLab 2.x**. If you would like to use the examples with JupyterLab 1.x, check out the [1.x branch](https://github.com/jupyterlab/extension-examples/tree/1.x). Note that the `1.x` branch is not updated anymore. +The examples currently target **JupyterLab 3.x**. + +If you would like to use the examples with JupyterLab 2.x, check out the [2.x branch](https://github.com/jupyterlab/extension-examples/tree/2.x). + +If you would like to use the examples with JupyterLab 1.x, check out the [1.x branch](https://github.com/jupyterlab/extension-examples/tree/1.x). + +Note that the `1.x` and `2.x` branches are not updated anymore. ## Develop by Examples @@ -210,11 +233,17 @@ conda env create && \ ```bash jlpm jlpm build-ext +jlpm install-py jlpm install-ext -jlpm build-jlab jupyter lab ``` +To rebuild all the extensions: + +```bash +jlpm build-ext +``` + To clean the lib folders: ```bash diff --git a/advanced/kernel-messaging/MANIFEST.in b/advanced/kernel-messaging/MANIFEST.in new file mode 100644 index 00000000..1ffdbd62 --- /dev/null +++ b/advanced/kernel-messaging/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_kernel_messaging.json + +include package.json +include ts*.json + +graft jupyterlab_examples_kernel_messaging/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/advanced/kernel-messaging/README.md b/advanced/kernel-messaging/README.md index 2020957f..e5950ae0 100644 --- a/advanced/kernel-messaging/README.md +++ b/advanced/kernel-messaging/README.md @@ -36,7 +36,7 @@ Jupyterlab provides a class `SessionContext` that manages a single kernel session. Here is the code to initialize such session: ```ts -// src/panel.ts#L33-L37 +// src/panel.ts#L41-L45 this._sessionContext = new SessionContext({ sessionManager: manager.sessions, @@ -46,7 +46,7 @@ this._sessionContext = new SessionContext({ ``` - + ```ts void this._sessionContext @@ -68,7 +68,7 @@ The session manager object is provided directly by the JupyterLab application: ```ts -// src/index.ts#L48-L48 +// src/index.ts#L52-L52 const manager = app.serviceManager; ``` @@ -81,14 +81,16 @@ to free the kernel session resources if the panel is closed. The whole adapted panel class looks like this: ```ts -// src/panel.ts#L25-L74 +// src/panel.ts#L31-L85 export class ExamplePanel extends StackedPanel { - constructor(manager: ServiceManager.IManager) { + constructor(manager: ServiceManager.IManager, translator?: ITranslator) { super(); + this._translator = translator || nullTranslator; + this._trans = this._translator.load('jupyterlab'); this.addClass(PANEL_CLASS); this.id = 'kernel-messaging-panel'; - this.title.label = 'Kernel Messaging Example View'; + this.title.label = this._trans.__('Kernel Messaging Example View'); this.title.closable = true; this._sessionContext = new SessionContext({ @@ -132,6 +134,9 @@ export class ExamplePanel extends StackedPanel { private _model: KernelModel; private _sessionContext: SessionContext; private _example: KernelView; + + private _translator: ITranslator; + private _trans: TranslationBundle; } ``` diff --git a/advanced/kernel-messaging/install.json b/advanced/kernel-messaging/install.json new file mode 100644 index 00000000..97ae33da --- /dev/null +++ b/advanced/kernel-messaging/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_kernel_messaging", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_kernel_messaging" +} diff --git a/advanced/kernel-messaging/jupyterlab_examples_kernel_messaging/__init__.py b/advanced/kernel-messaging/jupyterlab_examples_kernel_messaging/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/advanced/kernel-messaging/jupyterlab_examples_kernel_messaging/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/advanced/kernel-messaging/jupyterlab_examples_kernel_messaging/_version.py b/advanced/kernel-messaging/jupyterlab_examples_kernel_messaging/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/advanced/kernel-messaging/jupyterlab_examples_kernel_messaging/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/advanced/kernel-messaging/package.json b/advanced/kernel-messaging/package.json index 0ba26072..6f10debc 100644 --- a/advanced/kernel-messaging/package.json +++ b/advanced/kernel-messaging/package.json @@ -25,40 +25,55 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_kernel_messaging/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.0.0", - "@jupyterlab/launcher": "^2.0.0", - "@jupyterlab/mainmenu": "^2.0.0", - "@jupyterlab/nbformat": "^2.0.0", - "@lumino/algorithm": "^1.2.3", - "@lumino/coreutils": "^1.3.1", + "@jupyterlab/application": "^3.0.0-rc.15", + "@jupyterlab/launcher": "^3.0.0-rc.15", + "@jupyterlab/mainmenu": "^3.0.0-rc.15", + "@jupyterlab/nbformat": "^3.0.0-rc.15", + "@jupyterlab/translation": "^3.0.0-rc.15", + "@lumino/algorithm": "^1.3.3", + "@lumino/coreutils": "^1.5.3", "@lumino/datagrid": "^0.5.2", - "@lumino/disposable": "^1.3.1", - "@lumino/widgets": "^1.11.0" + "@lumino/disposable": "^1.4.3", + "@lumino/widgets": "^1.16.1" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" ], "jupyterlab": { - "extension": true + "extension": true, + "outputDir": "jupyterlab_examples_kernel_messaging/labextension" } -} +} \ No newline at end of file diff --git a/advanced/kernel-messaging/pyproject.toml b/advanced/kernel-messaging/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/advanced/kernel-messaging/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/advanced/kernel-messaging/setup.py b/advanced/kernel-messaging/setup.py new file mode 100644 index 00000000..6592ff5d --- /dev/null +++ b/advanced/kernel-messaging/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_kernel_messaging setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_kernel_messaging" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/kernel-messaging" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="minimal lab example", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/advanced/kernel-messaging/src/index.ts b/advanced/kernel-messaging/src/index.ts index 16b826cf..fc6a9945 100644 --- a/advanced/kernel-messaging/src/index.ts +++ b/advanced/kernel-messaging/src/index.ts @@ -9,6 +9,8 @@ import { ILauncher } from '@jupyterlab/launcher'; import { IMainMenu } from '@jupyterlab/mainmenu'; +import { ITranslator } from '@jupyterlab/translation'; + import { Menu } from '@lumino/widgets'; import { ExamplePanel } from './panel'; @@ -27,27 +29,30 @@ const extension: JupyterFrontEndPlugin = { id: 'kernel-messaging', autoStart: true, optional: [ILauncher], - requires: [ICommandPalette, IMainMenu], + requires: [ICommandPalette, IMainMenu, ITranslator], activate: activate }; /** * Activate the JupyterLab extension. * - * @param app Jupyter Font End + * @param app Jupyter Front End * @param palette Jupyter Commands Palette * @param mainMenu Jupyter Menu + * @param translator Jupyter Translator * @param launcher [optional] Jupyter Launcher */ function activate( app: JupyterFrontEnd, palette: ICommandPalette, mainMenu: IMainMenu, + translator: ITranslator, launcher: ILauncher | null ): void { const manager = app.serviceManager; const { commands, shell } = app; const category = 'Extension Examples'; + const trans = translator.load('jupyterlab'); // Add launcher if (launcher) { @@ -63,20 +68,20 @@ function activate( * @returns The panel */ async function createPanel(): Promise { - const panel = new ExamplePanel(manager); + const panel = new ExamplePanel(manager, translator); shell.add(panel, 'main'); return panel; } // add menu tab const exampleMenu = new Menu({ commands }); - exampleMenu.title.label = 'Kernel Messaging'; + exampleMenu.title.label = trans.__('Kernel Messaging'); mainMenu.addMenu(exampleMenu); // add commands to registry commands.addCommand(CommandIDs.create, { - label: 'Open the Kernel Messaging Panel', - caption: 'Open the Kernel Messaging Panel', + label: trans.__('Open the Kernel Messaging Panel'), + caption: trans.__('Open the Kernel Messaging Panel'), execute: createPanel }); diff --git a/advanced/kernel-messaging/src/panel.ts b/advanced/kernel-messaging/src/panel.ts index 0fd544ee..988dd2ca 100644 --- a/advanced/kernel-messaging/src/panel.ts +++ b/advanced/kernel-messaging/src/panel.ts @@ -4,6 +4,12 @@ import { sessionContextDialogs } from '@jupyterlab/apputils'; +import { + ITranslator, + nullTranslator, + TranslationBundle +} from '@jupyterlab/translation'; + import { ServiceManager } from '@jupyterlab/services'; import { Message } from '@lumino/messaging'; @@ -23,11 +29,13 @@ const PANEL_CLASS = 'jp-RovaPanel'; * A panel which has the ability to add other children. */ export class ExamplePanel extends StackedPanel { - constructor(manager: ServiceManager.IManager) { + constructor(manager: ServiceManager.IManager, translator?: ITranslator) { super(); + this._translator = translator || nullTranslator; + this._trans = this._translator.load('jupyterlab'); this.addClass(PANEL_CLASS); this.id = 'kernel-messaging-panel'; - this.title.label = 'Kernel Messaging Example View'; + this.title.label = this._trans.__('Kernel Messaging Example View'); this.title.closable = true; this._sessionContext = new SessionContext({ @@ -71,4 +79,7 @@ export class ExamplePanel extends StackedPanel { private _model: KernelModel; private _sessionContext: SessionContext; private _example: KernelView; + + private _translator: ITranslator; + private _trans: TranslationBundle; } diff --git a/advanced/kernel-messaging/style/base.css b/advanced/kernel-messaging/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/advanced/kernel-messaging/style/index.js b/advanced/kernel-messaging/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/advanced/kernel-messaging/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/advanced/kernel-output/MANIFEST.in b/advanced/kernel-output/MANIFEST.in new file mode 100644 index 00000000..d67f9240 --- /dev/null +++ b/advanced/kernel-output/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_kernel_output.json + +include package.json +include ts*.json + +graft jupyterlab_examples_kernel_output/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/advanced/kernel-output/README.md b/advanced/kernel-output/README.md index 61601a8d..e03e097b 100644 --- a/advanced/kernel-output/README.md +++ b/advanced/kernel-output/README.md @@ -41,7 +41,7 @@ object ([see the documentation](https://jupyterlab.github.io/jupyterlab/apputils Here it is stored in the private `_sessionContext` variable: ```ts -// src/panel.ts#L86-L86 +// src/panel.ts#L94-L94 private _sessionContext: SessionContext; ``` @@ -50,7 +50,7 @@ A `SessionContext` handles a single kernel session. The session itself (not yet the kernel) is started with these lines: ```ts -// src/panel.ts#L36-L40 +// src/panel.ts#L44-L48 this._sessionContext = new SessionContext({ sessionManager: manager.sessions, @@ -63,7 +63,7 @@ The private session variable is exposed as read-only for other users through a getter method: ```ts -// src/panel.ts#L64-L66 +// src/panel.ts#L72-L74 get session(): ISessionContext { return this._sessionContext; @@ -75,7 +75,7 @@ with this line: ```ts -// src/panel.ts#L50-L61 +// src/panel.ts#L58-L69 void this._sessionContext .initialize() @@ -99,7 +99,7 @@ The following two methods ensure the clean disposal of the session when you close the panel. ```ts -// src/panel.ts#L68-L71 +// src/panel.ts#L76-L79 dispose(): void { this._sessionContext.dispose(); @@ -108,7 +108,7 @@ dispose(): void { ``` ```ts -// src/panel.ts#L81-L84 +// src/panel.ts#L89-L92 protected onCloseRequest(msg: Message): void { super.onCloseRequest(msg); @@ -124,7 +124,7 @@ You can instantiate it with a new `OutputAreaModel`; this is class containing the data to show: ```ts -// src/panel.ts#L42-L46 +// src/panel.ts#L50-L54 this._outputareamodel = new OutputAreaModel(); this._outputarea = new SimplifiedOutputArea({ @@ -138,7 +138,7 @@ some code to a kernel through a `ISessionContext` ([see documentation](https://j in the specific `SimplifiedOutputArea` object you created: ```ts -// src/panel.ts#L73-L79 +// src/panel.ts#L81-L87 execute(code: string): void { SimplifiedOutputArea.execute(code, this._outputarea, this._sessionContext) @@ -158,7 +158,7 @@ To display the `SimplifiedOutputArea` Widget you need to add it to your panel with: ```ts -// src/panel.ts#L48-L48 +// src/panel.ts#L56-L56 this.addWidget(this._outputarea); ``` @@ -172,7 +172,7 @@ The last step is to add the panel to the JupyterLab main area. First, it is a good practice to unify the extension commands into one namespace at the top of the file: ```ts -// src/index.ts#L21-L25 +// src/index.ts#L23-L27 namespace CommandIDs { export const create = 'kernel-output:create'; @@ -185,7 +185,7 @@ You can then add the commands to the palette and the menu by iterating on a list: ```ts -// src/index.ts#L105-L109 +// src/index.ts#L110-L114 // add items in command palette and menu [CommandIDs.create, CommandIDs.execute].forEach(command => { @@ -198,7 +198,7 @@ To create a new client session, the service manager must be obtained from the JupyterLab application: ```ts -// src/index.ts#L54-L54 +// src/index.ts#L58-L58 const manager = app.serviceManager; ``` @@ -208,7 +208,7 @@ ready. Then once the panel is created and its session is ready, it can be added to the JupyterLab main area: ```ts -// src/index.ts#L58-L69 +// src/index.ts#L63-L74 let panel: ExamplePanel; @@ -218,7 +218,7 @@ let panel: ExamplePanel; * @returns The panel */ async function createPanel(): Promise { - panel = new ExamplePanel(manager, rendermime); + panel = new ExamplePanel(manager, rendermime, translator); shell.add(panel, 'main'); return panel; } @@ -231,11 +231,11 @@ to be executed by the kernel. Then you will send it to your panel for execution and display: ```ts -// src/index.ts#L83-L103 +// src/index.ts#L88-L108 commands.addCommand(CommandIDs.execute, { - label: 'Contact Kernel and Execute Code', - caption: 'Contact Kernel and Execute Code', + label: trans.__('Contact Kernel and Execute Code'), + caption: trans.__('Contact Kernel and Execute Code'), execute: async () => { // Create the panel if it does not exist if (!panel) { @@ -243,9 +243,9 @@ commands.addCommand(CommandIDs.execute, { } // Prompt the user about the statement to be executed const input = await InputDialog.getText({ - title: 'Code to execute', - okLabel: 'Execute', - placeholder: 'Statement to execute' + title: trans.__('Code to execute'), + okLabel: trans.__('Execute'), + placeholder: trans.__('Statement to execute') }); // Execute the statement if (input.button.accept) { diff --git a/advanced/kernel-output/install.json b/advanced/kernel-output/install.json new file mode 100644 index 00000000..4b8ad737 --- /dev/null +++ b/advanced/kernel-output/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_kernel_output", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_kernel_output" +} diff --git a/advanced/kernel-output/jupyterlab_examples_kernel_output/__init__.py b/advanced/kernel-output/jupyterlab_examples_kernel_output/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/advanced/kernel-output/jupyterlab_examples_kernel_output/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/advanced/kernel-output/jupyterlab_examples_kernel_output/_version.py b/advanced/kernel-output/jupyterlab_examples_kernel_output/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/advanced/kernel-output/jupyterlab_examples_kernel_output/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/advanced/kernel-output/package.json b/advanced/kernel-output/package.json index 1c85e901..73e6f93a 100644 --- a/advanced/kernel-output/package.json +++ b/advanced/kernel-output/package.json @@ -25,39 +25,54 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_kernel_output/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.0.0", - "@jupyterlab/launcher": "^2.0.0", - "@jupyterlab/mainmenu": "^2.0.0", - "@jupyterlab/outputarea": "^2.0.0", - "@lumino/algorithm": "^1.1.2", - "@lumino/coreutils": "^1.3.0", + "@jupyterlab/application": "^3.0.0-rc.15", + "@jupyterlab/launcher": "^3.0.0-rc.15", + "@jupyterlab/mainmenu": "^3.0.0-rc.15", + "@jupyterlab/outputarea": "^3.0.0-rc.15", + "@jupyterlab/translation": "^3.0.0-rc.15", + "@lumino/algorithm": "^1.3.3", + "@lumino/coreutils": "^1.5.3", "@lumino/datagrid": "^0.3.1", - "@lumino/disposable": "^1.1.2" + "@lumino/disposable": "^1.4.3" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" ], "jupyterlab": { - "extension": true + "extension": true, + "outputDir": "jupyterlab_examples_kernel_output/labextension" } -} +} \ No newline at end of file diff --git a/advanced/kernel-output/pyproject.toml b/advanced/kernel-output/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/advanced/kernel-output/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/advanced/kernel-output/setup.py b/advanced/kernel-output/setup.py new file mode 100644 index 00000000..4fb31193 --- /dev/null +++ b/advanced/kernel-output/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_kernel_output setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_kernel_output" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/kernel-output" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="minimal lab example", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/advanced/kernel-output/src/index.ts b/advanced/kernel-output/src/index.ts index d44715a2..f4966306 100644 --- a/advanced/kernel-output/src/index.ts +++ b/advanced/kernel-output/src/index.ts @@ -9,6 +9,8 @@ import { ILauncher } from '@jupyterlab/launcher'; import { IMainMenu } from '@jupyterlab/mainmenu'; +import { ITranslator } from '@jupyterlab/translation'; + import { IRenderMimeRegistry } from '@jupyterlab/rendermime'; import { Menu } from '@lumino/widgets'; @@ -31,17 +33,18 @@ const extension: JupyterFrontEndPlugin = { id: 'kernel-output', autoStart: true, optional: [ILauncher], - requires: [ICommandPalette, IMainMenu, IRenderMimeRegistry], + requires: [ICommandPalette, IMainMenu, IRenderMimeRegistry, ITranslator], activate: activate }; /** * Activate the JupyterLab extension. * - * @param app Jupyter Font End + * @param app Jupyter Front End * @param palette Jupyter Commands Palette * @param mainMenu Jupyter Menu * @param rendermime Jupyter Render Mime Registry + * @param translator Jupyter Translator * @param launcher [optional] Jupyter Launcher */ function activate( @@ -49,11 +52,13 @@ function activate( palette: ICommandPalette, mainMenu: IMainMenu, rendermime: IRenderMimeRegistry, + translator: ITranslator, launcher: ILauncher | null ): void { const manager = app.serviceManager; const { commands, shell } = app; const category = 'Extension Examples'; + const trans = translator.load('jupyterlab'); let panel: ExamplePanel; @@ -63,26 +68,26 @@ function activate( * @returns The panel */ async function createPanel(): Promise { - panel = new ExamplePanel(manager, rendermime); + panel = new ExamplePanel(manager, rendermime, translator); shell.add(panel, 'main'); return panel; } // add menu tab const exampleMenu = new Menu({ commands }); - exampleMenu.title.label = 'Kernel Output'; + exampleMenu.title.label = trans.__('Kernel Output'); mainMenu.addMenu(exampleMenu); // add commands to registry commands.addCommand(CommandIDs.create, { - label: 'Open the Kernel Output Panel', - caption: 'Open the Kernel Output Panel', + label: trans.__('Open the Kernel Output Panel'), + caption: trans.__('Open the Kernel Output Panel'), execute: createPanel }); commands.addCommand(CommandIDs.execute, { - label: 'Contact Kernel and Execute Code', - caption: 'Contact Kernel and Execute Code', + label: trans.__('Contact Kernel and Execute Code'), + caption: trans.__('Contact Kernel and Execute Code'), execute: async () => { // Create the panel if it does not exist if (!panel) { @@ -90,9 +95,9 @@ function activate( } // Prompt the user about the statement to be executed const input = await InputDialog.getText({ - title: 'Code to execute', - okLabel: 'Execute', - placeholder: 'Statement to execute' + title: trans.__('Code to execute'), + okLabel: trans.__('Execute'), + placeholder: trans.__('Statement to execute') }); // Execute the statement if (input.button.accept) { diff --git a/advanced/kernel-output/src/panel.ts b/advanced/kernel-output/src/panel.ts index 86849443..8494eaa1 100644 --- a/advanced/kernel-output/src/panel.ts +++ b/advanced/kernel-output/src/panel.ts @@ -9,6 +9,11 @@ import { OutputAreaModel, SimplifiedOutputArea } from '@jupyterlab/outputarea'; import { IRenderMimeRegistry } from '@jupyterlab/rendermime'; import { KernelMessage, ServiceManager } from '@jupyterlab/services'; +import { + ITranslator, + nullTranslator, + TranslationBundle +} from '@jupyterlab/translation'; import { Message } from '@lumino/messaging'; @@ -25,12 +30,15 @@ const PANEL_CLASS = 'jp-RovaPanel'; export class ExamplePanel extends StackedPanel { constructor( manager: ServiceManager.IManager, - rendermime: IRenderMimeRegistry + rendermime: IRenderMimeRegistry, + translator?: ITranslator ) { super(); + this._translator = translator || nullTranslator; + this._trans = this._translator.load('jupyterlab'); this.addClass(PANEL_CLASS); this.id = 'kernel-output-panel'; - this.title.label = 'Kernel Output Example View'; + this.title.label = this._trans.__('Kernel Output Example View'); this.title.closable = true; this._sessionContext = new SessionContext({ @@ -86,4 +94,7 @@ export class ExamplePanel extends StackedPanel { private _sessionContext: SessionContext; private _outputarea: SimplifiedOutputArea; private _outputareamodel: OutputAreaModel; + + private _translator: ITranslator; + private _trans: TranslationBundle; } diff --git a/advanced/kernel-output/style/base.css b/advanced/kernel-output/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/advanced/kernel-output/style/index.js b/advanced/kernel-output/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/advanced/kernel-output/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/advanced/server-extension/MANIFEST.in b/advanced/server-extension/MANIFEST.in index 549e2d7f..dbff3582 100644 --- a/advanced/server-extension/MANIFEST.in +++ b/advanced/server-extension/MANIFEST.in @@ -7,7 +7,7 @@ include jupyter-config/jlab_ext_example.json include package.json include ts*.json include jlab_ext_example/labextension/*.tgz -graft jlab_ext_example/static +graft jlab_ext_example/labextension # Javascript files graft src diff --git a/advanced/server-extension/README.md b/advanced/server-extension/README.md index 005450e3..b88414ef 100644 --- a/advanced/server-extension/README.md +++ b/advanced/server-extension/README.md @@ -89,12 +89,12 @@ to demonstrate the use of GET and POST HTTP requests. The entry point for the frontend extension is `src/index.ts`. The communication with the server extension is contained in another file -`src/jlabextexample.ts`. So you need to import it: +`src/handler.ts`. So you need to import it: ```ts // src/index.ts#L12-L12 -import { requestAPI } from './jlabextexample'; +import { requestAPI } from './handler'; ``` In the `activate` function, the server extension is first called through @@ -167,7 +167,7 @@ The communication logic with the server is hidden in the `requestAPI` function. Its definition is : ```ts -// src/jlabextexample.ts#L12-L37 +// src/handler.ts#L12-L37 export async function requestAPI( endPoint = '', @@ -200,7 +200,7 @@ export async function requestAPI( First the server settings are obtained from: ```ts -// src/jlabextexample.ts#L17-L17 +// src/handler.ts#L17-L17 const settings = ServerConnection.makeSettings(); ``` @@ -214,7 +214,7 @@ jlpm add @jupyterlab/services Then the class `ServerConnection` can be imported: ```ts -// src/jlabextexample.ts#L3-L3 +// src/handler.ts#L3-L3 import { ServerConnection } from '@jupyterlab/services'; ``` @@ -222,7 +222,7 @@ import { ServerConnection } from '@jupyterlab/services'; The next step is to build the full request URL: ```ts -// src/jlabextexample.ts#L18-L21 +// src/handler.ts#L18-L21 const requestUrl = URLExt.join( settings.baseUrl, @@ -233,7 +233,7 @@ const requestUrl = URLExt.join( To concatenate the various parts, the `URLExt` utility is imported: ```ts -// src/jlabextexample.ts#L1-L1 +// src/handler.ts#L1-L1 import { URLExt } from '@jupyterlab/coreutils'; ``` @@ -247,7 +247,7 @@ jlpm add @jupyterlab/coreutils You now have all the elements to make the request: ```ts -// src/jlabextexample.ts#L26-L26 +// src/handler.ts#L26-L26 response = await ServerConnection.makeRequest(requestUrl, init, settings); ``` @@ -256,7 +256,7 @@ Finally, once the server response is obtained, its body is interpreted as JSON. And the resulting data is returned. ```ts -// src/jlabextexample.ts#L31-L37 +// src/handler.ts#L31-L37 const data = await response.json(); @@ -296,7 +296,7 @@ if (launcher) { } ``` -Invoking the command (via the command palette or the launcher) will open a new tab with +Invoking the command (via the command palette or the launcher) will open a new tab with an `IFrame` that will display static content fetched from the server extension. **Note** @@ -312,14 +312,14 @@ an `IFrame` that will display static content fetched from the server extension. The server part of the extension is going to be presented in this section. -You first need to install the python source code. The following will install +You first need to install the python source code. The following will install the `jlab_ext_example` package in dev mode: ```bash pip install -e . ``` -Then you need to enable the package at the Jupyter level +Then you need to enable the package at the Jupyter level so that it becomes a server extension. ```bash @@ -332,8 +332,22 @@ your extension needs to be defined as a proper Python package with some hook fun ```py # jlab_ext_example/__init__.py -from ._version import __version__ +import json +import os.path as osp + from .handlers import setup_handlers +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] def _jupyter_server_extension_paths(): @@ -353,6 +367,7 @@ def load_jupyter_server_extension(lab_app): "Registered jlab_ext_example extension at URL path /{}".format(url_path) ) + ``` The `_jupyter_jlab_ext_example_paths` provides the Python package name @@ -360,7 +375,7 @@ to the server. But the most important one is `load_jupyter_jlab_ext_example` that register new handlers. ```py -# jlab_ext_example/__init__.py#L17-L17 +# jlab_ext_example/__init__.py#L31-L31 setup_handlers(lab_app.web_app, url_path) ``` @@ -435,16 +450,16 @@ input_data = self.get_json_body() data = {"greetings": "Hello {}, enjoy JupyterLab!".format(input_data["name"])} ``` -The part responsible to serve static content with a `StaticFileHandler` handler +The part responsible to serve static content with a `StaticFileHandler` handler is the following: ```py # jlab_ext_example/handlers.py#L37-L43 -doc_url = url_path_join(base_url, url_path, "static") +doc_url = url_path_join(base_url, url_path, "public") doc_dir = os.getenv( "JLAB_SERVER_EXAMPLE_STATIC_DIR", - os.path.join(os.path.dirname(__file__), "static"), + os.path.join(os.path.dirname(__file__), "public"), ) handlers = [("{}/(.*)".format(doc_url), StaticFileHandler, {"path": doc_dir})] web_app.add_handlers(".*$", handlers) @@ -471,7 +486,7 @@ through package managers like `pip`. > Note: In particular, [`jupyter-packaging`](https://github.com/jupyter/jupyter-packaging) provides helpers to package and install JS files > with a Python package for Jupyter frontends (classical notebook, -> JupyterLab,...). +> JupyterLab,...). > As this package is a setup requirement, it needs to be specified in the `pyproject.toml` to be installed by `pip`. The `setup.py` file is the entry point to describe package metadata: @@ -480,14 +495,14 @@ The `setup.py` file is the entry point to describe package metadata: # setup.py """ -Setup Module to setup Python Handlers for the jlab_ext_example extension. +jlab_ext_example setup """ +import json import os -from os.path import join as pjoin from jupyter_packaging import ( create_cmdclass, install_npm, ensure_targets, - combine_commands, ensure_python, get_version + combine_commands, skip_if_exists ) import setuptools @@ -496,17 +511,15 @@ HERE = os.path.abspath(os.path.dirname(__file__)) # The name of the project name="jlab_ext_example" -# Ensure a valid python version -ensure_python(">=3.5") +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] -# Get the version -version = get_version(pjoin(name, "_version.py")) - -lab_path = pjoin(HERE, name, "labextension") +lab_path = os.path.join(HERE, name, "labextension") # Representative files that should exist after a successful build jstargets = [ - pjoin(HERE, "lib", "jlabextexample.js"), + os.path.join(lab_path, "package.json"), ] package_data_spec = { @@ -515,10 +528,13 @@ package_data_spec = { ] } +labext_name = "@jupyterlab-examples/server-extension" + data_files_spec = [ - ("share/jupyter/lab/extensions", lab_path, "*.tgz"), - ("etc/jupyter/jupyter_notebook_config.d", + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"),("etc/jupyter/jupyter_server_config.d", "jupyter-config", "jlab_ext_example.json"), + ] cmdclass = create_cmdclass("jsdeps", @@ -526,37 +542,43 @@ cmdclass = create_cmdclass("jsdeps", data_files_spec=data_files_spec ) -cmdclass["jsdeps"] = combine_commands( - install_npm(HERE, build_cmd="build:all", npm=["jlpm"]), +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), ensure_targets(jstargets), ) +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + with open("README.md", "r") as fh: long_description = fh.read() setup_args = dict( name=name, version=version, - url="https://github.com/jupyterlab/extension-examples", - author="JupyterLab", + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", description="A minimal JupyterLab extension with backend and frontend parts.", long_description= long_description, long_description_content_type="text/markdown", cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab~=2.0", + "jupyterlab>=3.0.0rc15,==3.*", ], zip_safe=False, include_package_data=True, + python_requires=">=3.6", license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", - keywords=["Jupyter", "JupyterLab"], + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", @@ -565,7 +587,7 @@ setup_args = dict( ) -if __name__ == '__main__': +if __name__ == "__main__": setuptools.setup(**setup_args) ``` @@ -576,15 +598,15 @@ the frontend NPM package needs to be built and inserted in the Python package. T done using a special `cmdclass`: ```py -# setup.py#L43-L51 +# setup.py#L44-L52 cmdclass = create_cmdclass("jsdeps", package_data_spec=package_data_spec, data_files_spec=data_files_spec ) -cmdclass["jsdeps"] = combine_commands( - install_npm(HERE, build_cmd="build:all", npm=["jlpm"]), +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), ensure_targets(jstargets), ) ``` @@ -592,18 +614,19 @@ cmdclass["jsdeps"] = combine_commands( Basically it will build the frontend NPM package: ```py -# setup.py#L49-L49 +# setup.py#L50-L50 -install_npm(HERE, build_cmd="build:all", npm=["jlpm"]), +install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), ``` It will ensure one of the generated JS files is `lib/jlabextexample.js`: ```py -# setup.py#L27-L29 +# setup.py#L24-L27 +# Representative files that should exist after a successful build jstargets = [ - pjoin(HERE, "lib", "jlabextexample.js"), + os.path.join(lab_path, "package.json"), ] ``` @@ -611,9 +634,8 @@ It will copy the NPM package in the Python package and force it to be copied in JupyterLab is looking for frontend extensions when the Python package is installed: ```py -# setup.py#L38-L38 -("share/jupyter/lab/extensions", lab_path, "*.tgz"), +("share/jupyter/labextensions/%s" % labext_name, lab_path, "*.*") ``` The last piece of configuration needed is the enabling of the server extension. This is @@ -623,8 +645,8 @@ done by copying the following JSON file: // jupyter-config/jlab_ext_example.json { - "NotebookApp": { - "nbserver_extensions": { + "ServerApp": { + "jpserver_extensions": { "jlab_ext_example": true } } @@ -632,13 +654,12 @@ done by copying the following JSON file: ``` -in the appropriate jupyter folder (`etc/jupyter/jupyter_notebook_config.d`): +in the appropriate jupyter folder (`etc/jupyter/jupyter_server_config.d`): ```py -# setup.py#L39-L40 -("etc/jupyter/jupyter_notebook_config.d", - "jupyter-config", "jlab_ext_example.json"), + ("etc/jupyter/jupyter_server_config.d", + "jupyter-config", "jlab_ext_example.json"), ``` ### JupyterLab Extension Manager @@ -650,7 +671,7 @@ user about that dependency by adding the `discovery` metadata to your `package.j file: ```json5 -// package.json#L63-L73 +// package.json#L70-L80 "jupyterlab": { "discovery": { @@ -668,19 +689,19 @@ file: In this example, the extension requires a `server` extension: ```json5 -// package.json#L65-L65 +// package.json#L71-L71 -"server": { +"discovery": { ``` And that server extension is available through `pip`: ```json5 -// package.json#L66-L68 +// package.json#L72-L74 -"managers": [ - "pip" -], +"server": { + "managers": [ + "pip" ``` For more information on the `discovery` metadata, please refer to the [documentation](https://jupyterlab.readthedocs.io/en/stable/developer/extension_dev.html#ext-author-companion-packages). @@ -693,12 +714,8 @@ With the packaging described above, installing the extension is done in two comm # Install the server extension and # copy the frontend extension where JupyterLab can find it pip install jlab_ext_example -# Build JupyterLab to integrate the frontend extension -jupyter lab build ``` -> Note: User will need NodeJS to install the extension. - As developer, you might want to install the package in local editable mode. This will shunt the installation machinery described above. Therefore the commands to get you set are: @@ -706,18 +723,12 @@ to get you set are: ```bash # Install server extension in editable mode pip install -e . -# Register server extension -jupyter serverextension enable --py jlab_ext_example -# Install dependencies -jlpm # Build Typescript source jlpm build # Install your development version of the extension with JupyterLab -jupyter labextension install . +jupyter labextension develop . # Rebuild Typescript source after making changes jlpm build -# Rebuild JupyterLab after making any changes -jupyter lab build ``` diff --git a/advanced/server-extension/install.json b/advanced/server-extension/install.json new file mode 100644 index 00000000..772fb6ad --- /dev/null +++ b/advanced/server-extension/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jlab_ext_example", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jlab_ext_example" +} diff --git a/advanced/server-extension/jlab_ext_example/__init__.py b/advanced/server-extension/jlab_ext_example/__init__.py index a296f826..c6bf4615 100644 --- a/advanced/server-extension/jlab_ext_example/__init__.py +++ b/advanced/server-extension/jlab_ext_example/__init__.py @@ -1,5 +1,19 @@ -from ._version import __version__ +import json +import os.path as osp + from .handlers import setup_handlers +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] def _jupyter_server_extension_paths(): diff --git a/advanced/server-extension/jlab_ext_example/handlers.py b/advanced/server-extension/jlab_ext_example/handlers.py index b245800e..7effc12b 100644 --- a/advanced/server-extension/jlab_ext_example/handlers.py +++ b/advanced/server-extension/jlab_ext_example/handlers.py @@ -34,10 +34,10 @@ def setup_handlers(web_app, url_path): web_app.add_handlers(host_pattern, handlers) # Prepend the base_url so that it works in a jupyterhub setting - doc_url = url_path_join(base_url, url_path, "static") + doc_url = url_path_join(base_url, url_path, "public") doc_dir = os.getenv( "JLAB_SERVER_EXAMPLE_STATIC_DIR", - os.path.join(os.path.dirname(__file__), "static"), + os.path.join(os.path.dirname(__file__), "public"), ) handlers = [("{}/(.*)".format(doc_url), StaticFileHandler, {"path": doc_dir})] web_app.add_handlers(".*$", handlers) diff --git a/advanced/server-extension/jlab_ext_example/static/index.html b/advanced/server-extension/jlab_ext_example/public/index.html similarity index 100% rename from advanced/server-extension/jlab_ext_example/static/index.html rename to advanced/server-extension/jlab_ext_example/public/index.html diff --git a/advanced/server-extension/jupyter-config/jlab_ext_example.json b/advanced/server-extension/jupyter-config/jlab_ext_example.json index 26b21bd8..03f6eef1 100644 --- a/advanced/server-extension/jupyter-config/jlab_ext_example.json +++ b/advanced/server-extension/jupyter-config/jlab_ext_example.json @@ -1,6 +1,6 @@ { - "NotebookApp": { - "nbserver_extensions": { + "ServerApp": { + "jpserver_extensions": { "jlab_ext_example": true } } diff --git a/advanced/server-extension/package.json b/advanced/server-extension/package.json index 9824feec..776ec173 100644 --- a/advanced/server-extension/package.json +++ b/advanced/server-extension/package.json @@ -25,37 +25,44 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "jlpm run build:lib", - "build:labextension": "cd jlab_ext_example && rimraf labextension && mkdirp labextension && cd labextension && npm pack ../..", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:all": "jlpm run build:labextension", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", - "clean:lib": "rimraf lib tsconfig.tsbuildinfo", - "clean:labextension": "rimraf jlab_ext_example/labextension", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jlab_ext_example/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.0.0", - "@jupyterlab/coreutils": "^4.0.0", - "@jupyterlab/launcher": "^2.0.0", - "@jupyterlab/services": "^5.0.0" + "@jupyterlab/application": "^3.0.0-rc.15", + "@jupyterlab/coreutils": "^5.0.0-rc.15", + "@jupyterlab/launcher": "^3.0.0-rc.15", + "@jupyterlab/services": "^6.0.0-rc.15" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", "mkdirp": "^1.0.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" @@ -71,6 +78,7 @@ } } }, - "extension": true + "extension": true, + "outputDir": "jlab_ext_example/labextension" } -} +} \ No newline at end of file diff --git a/advanced/server-extension/pyproject.toml b/advanced/server-extension/pyproject.toml index 010df900..c40f3629 100644 --- a/advanced/server-extension/pyproject.toml +++ b/advanced/server-extension/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["jupyter_packaging~=0.4.0", "jupyterlab~=2.0", "setuptools>=40.8.0", "wheel"] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] build-backend = "setuptools.build_meta" diff --git a/advanced/server-extension/setup.py b/advanced/server-extension/setup.py index 7bdcd0cd..c59b9ae7 100644 --- a/advanced/server-extension/setup.py +++ b/advanced/server-extension/setup.py @@ -1,12 +1,12 @@ """ -Setup Module to setup Python Handlers for the jlab_ext_example extension. +jlab_ext_example setup """ +import json import os -from os.path import join as pjoin from jupyter_packaging import ( create_cmdclass, install_npm, ensure_targets, - combine_commands, ensure_python, get_version + combine_commands, skip_if_exists ) import setuptools @@ -15,17 +15,15 @@ # The name of the project name="jlab_ext_example" -# Ensure a valid python version -ensure_python(">=3.5") +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] -# Get the version -version = get_version(pjoin(name, "_version.py")) - -lab_path = pjoin(HERE, name, "labextension") +lab_path = os.path.join(HERE, name, "labextension") # Representative files that should exist after a successful build jstargets = [ - pjoin(HERE, "lib", "jlabextexample.js"), + os.path.join(lab_path, "package.json"), ] package_data_spec = { @@ -34,10 +32,13 @@ ] } +labext_name = "@jupyterlab-examples/server-extension" + data_files_spec = [ - ("share/jupyter/lab/extensions", lab_path, "*.tgz"), - ("etc/jupyter/jupyter_notebook_config.d", + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"),("etc/jupyter/jupyter_server_config.d", "jupyter-config", "jlab_ext_example.json"), + ] cmdclass = create_cmdclass("jsdeps", @@ -45,37 +46,43 @@ data_files_spec=data_files_spec ) -cmdclass["jsdeps"] = combine_commands( - install_npm(HERE, build_cmd="build:all", npm=["jlpm"]), +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), ensure_targets(jstargets), ) +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + with open("README.md", "r") as fh: long_description = fh.read() setup_args = dict( name=name, version=version, - url="https://github.com/jupyterlab/extension-examples", - author="JupyterLab", + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", description="A minimal JupyterLab extension with backend and frontend parts.", long_description= long_description, long_description_content_type="text/markdown", cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab~=2.0", + "jupyterlab>=3.0.0rc15,==3.*", ], zip_safe=False, include_package_data=True, + python_requires=">=3.6", license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", - keywords=["Jupyter", "JupyterLab"], + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", @@ -84,5 +91,5 @@ ) -if __name__ == '__main__': +if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/advanced/server-extension/src/jlabextexample.ts b/advanced/server-extension/src/handler.ts similarity index 100% rename from advanced/server-extension/src/jlabextexample.ts rename to advanced/server-extension/src/handler.ts diff --git a/advanced/server-extension/src/index.ts b/advanced/server-extension/src/index.ts index 948d5752..5883e09d 100644 --- a/advanced/server-extension/src/index.ts +++ b/advanced/server-extension/src/index.ts @@ -9,7 +9,7 @@ import { PageConfig } from '@jupyterlab/coreutils'; import { ILauncher } from '@jupyterlab/launcher'; -import { requestAPI } from './jlabextexample'; +import { requestAPI } from './handler'; /** * The command IDs used by the server extension plugin. @@ -86,7 +86,7 @@ class IFrameWidget extends IFrame { constructor() { super(); const baseUrl = PageConfig.getBaseUrl(); - this.url = baseUrl + 'jlab-ext-example/static/index.html'; + this.url = baseUrl + 'jlab-ext-example/public/index.html'; this.id = 'doc-example'; this.title.label = 'Server Doc'; this.title.closable = true; diff --git a/advanced/server-extension/style/base.css b/advanced/server-extension/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/advanced/server-extension/style/index.js b/advanced/server-extension/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/advanced/server-extension/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/basics/datagrid/MANIFEST.in b/basics/datagrid/MANIFEST.in new file mode 100644 index 00000000..a2f60e5c --- /dev/null +++ b/basics/datagrid/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_datagrid.json + +include package.json +include ts*.json + +graft jupyterlab_examples_datagrid/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/basics/datagrid/README.md b/basics/datagrid/README.md index 67cf5865..7d5d32ff 100644 --- a/basics/datagrid/README.md +++ b/basics/datagrid/README.md @@ -14,7 +14,7 @@ First you need to import `StackedPanel`, `DataGrid` and `DataModel` classes from lumino: ```ts -// src/index.ts#L10-L12 +// src/index.ts#L16-L18 import { DataGrid, DataModel } from '@lumino/datagrid'; @@ -35,14 +35,17 @@ the main area of JupyterLab as seen in the above screenshot. With these three classes, you can create your own widget, called `DataGridPanel` : ```ts -// src/index.ts#L49-L63 +// src/index.ts#L57-L77 class DataGridPanel extends StackedPanel { - constructor() { + constructor(translator?: ITranslator) { super(); + this._translator = translator || nullTranslator; + this._trans = this._translator.load('jupyterlab'); + this.addClass('jp-example-view'); this.id = 'datagrid-example'; - this.title.label = 'Datagrid Example View'; + this.title.label = this._trans.__('Datagrid Example View'); this.title.closable = true; const model = new LargeDataModel(); @@ -51,6 +54,9 @@ class DataGridPanel extends StackedPanel { this.addWidget(grid); } + + private _translator: ITranslator; + private _trans: TranslationBundle; } ``` @@ -58,12 +64,14 @@ Your widget is derived from `StackedPanel` to inherit its behavior. Then some properties for the panel. Then the `DataGrid` widget and its associated model are created. Finally the grid is inserted inside the panel. +Note that the private variables `_translator` and `_trans` are used for translating labels and other pieces of text that are displayed to the user. + The `DataModel` class is not used directly as it is an abstract class. Therefore in this example a class `LargeDataModel` is derived from it to implement its abstract methods: ```ts -// src/index.ts#L65-L74 +// src/index.ts#L79-L88 class LargeDataModel extends DataModel { rowCount(region: DataModel.RowRegion): number { @@ -108,7 +116,7 @@ values of the datagrid. In this case it simply displays the row and column index in each cell, and adds a letter prefix in the header regions: ```ts -// src/index.ts#L74-L85 +// src/index.ts#L88-L99 data(region: DataModel.CellRegion, row: number, column: number): any { if (region === 'row-header') { diff --git a/basics/datagrid/install.json b/basics/datagrid/install.json new file mode 100644 index 00000000..d35e2f7a --- /dev/null +++ b/basics/datagrid/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_datagrid", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_datagrid" +} diff --git a/basics/datagrid/jupyterlab_examples_datagrid/__init__.py b/basics/datagrid/jupyterlab_examples_datagrid/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/basics/datagrid/jupyterlab_examples_datagrid/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/basics/datagrid/jupyterlab_examples_datagrid/_version.py b/basics/datagrid/jupyterlab_examples_datagrid/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/basics/datagrid/jupyterlab_examples_datagrid/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/basics/datagrid/package.json b/basics/datagrid/package.json index dfe1036e..4f5a236d 100644 --- a/basics/datagrid/package.json +++ b/basics/datagrid/package.json @@ -25,37 +25,52 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_datagrid/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.0.0", - "@jupyterlab/mainmenu": "^2.0.0", - "@lumino/algorithm": "^1.2.3", - "@lumino/coreutils": "^1.3.1", - "@lumino/datagrid": "^0.5.2", - "@lumino/disposable": "^1.3.1" + "@jupyterlab/application": "^3.0.0-rc.15", + "@jupyterlab/mainmenu": "^3.0.0-rc.15", + "@jupyterlab/translation": "^3.0.0-rc.15", + "@lumino/algorithm": "^1.3.3", + "@lumino/coreutils": "^1.5.3", + "@lumino/datagrid": "^0.14.1", + "@lumino/disposable": "^1.4.3" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" ], "jupyterlab": { - "extension": true + "extension": true, + "outputDir": "jupyterlab_examples_datagrid/labextension" } -} +} \ No newline at end of file diff --git a/basics/datagrid/pyproject.toml b/basics/datagrid/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/basics/datagrid/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/basics/datagrid/setup.py b/basics/datagrid/setup.py new file mode 100644 index 00000000..47b028ff --- /dev/null +++ b/basics/datagrid/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_datagrid setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_datagrid" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/datagrid" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="minimal lab example", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/basics/datagrid/src/index.ts b/basics/datagrid/src/index.ts index 64098cf8..c78e7837 100644 --- a/basics/datagrid/src/index.ts +++ b/basics/datagrid/src/index.ts @@ -7,6 +7,12 @@ import { ICommandPalette } from '@jupyterlab/apputils'; import { IMainMenu } from '@jupyterlab/mainmenu'; +import { + ITranslator, + nullTranslator, + TranslationBundle +} from '@jupyterlab/translation'; + import { DataGrid, DataModel } from '@lumino/datagrid'; import { Menu, StackedPanel } from '@lumino/widgets'; @@ -17,18 +23,20 @@ import { Menu, StackedPanel } from '@lumino/widgets'; const extension: JupyterFrontEndPlugin = { id: 'datagrid', autoStart: true, - requires: [ICommandPalette, IMainMenu], + requires: [ICommandPalette, IMainMenu, ITranslator], activate: ( app: JupyterFrontEnd, palette: ICommandPalette, - mainMenu: IMainMenu + mainMenu: IMainMenu, + translator: ITranslator ) => { const { commands, shell } = app; + const trans = translator.load('jupyterlab'); const command = 'examples:datagrid'; commands.addCommand(command, { - label: 'Open a Datagrid', - caption: 'Open a Datagrid Panel', + label: trans.__('Open a Datagrid'), + caption: trans.__('Open a Datagrid Panel'), execute: () => { const widget = new DataGridPanel(); shell.add(widget, 'main'); @@ -38,7 +46,7 @@ const extension: JupyterFrontEndPlugin = { const exampleMenu = new Menu({ commands }); - exampleMenu.title.label = 'DataGrid Example'; + exampleMenu.title.label = trans.__('DataGrid Example'); mainMenu.addMenu(exampleMenu, { rank: 80 }); exampleMenu.addItem({ command }); } @@ -47,11 +55,14 @@ const extension: JupyterFrontEndPlugin = { export default extension; class DataGridPanel extends StackedPanel { - constructor() { + constructor(translator?: ITranslator) { super(); + this._translator = translator || nullTranslator; + this._trans = this._translator.load('jupyterlab'); + this.addClass('jp-example-view'); this.id = 'datagrid-example'; - this.title.label = 'Datagrid Example View'; + this.title.label = this._trans.__('Datagrid Example View'); this.title.closable = true; const model = new LargeDataModel(); @@ -60,6 +71,9 @@ class DataGridPanel extends StackedPanel { this.addWidget(grid); } + + private _translator: ITranslator; + private _trans: TranslationBundle; } class LargeDataModel extends DataModel { diff --git a/basics/datagrid/style/base.css b/basics/datagrid/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/basics/datagrid/style/index.js b/basics/datagrid/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/basics/datagrid/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/basics/hello-world/MANIFEST.in b/basics/hello-world/MANIFEST.in new file mode 100644 index 00000000..041b2fd7 --- /dev/null +++ b/basics/hello-world/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_hello_world.json + +include package.json +include ts*.json + +graft jupyterlab_examples_hello_world/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/basics/hello-world/README.md b/basics/hello-world/README.md index 9edb3f9e..70844c77 100644 --- a/basics/hello-world/README.md +++ b/basics/hello-world/README.md @@ -91,10 +91,10 @@ called `@jupyterlab/application`. The dependency of your extension on this package is declared in the file `package.json`: ```json5 -// package.json#L36-L38 +// package.json#L46-L48 "dependencies": { - "@jupyterlab/application": "^2.0.0" + "@jupyterlab/application": "^3.0.0-rc.15" }, ``` diff --git a/basics/hello-world/install.json b/basics/hello-world/install.json new file mode 100644 index 00000000..c867999e --- /dev/null +++ b/basics/hello-world/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_hello_world", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_hello_world" +} diff --git a/basics/hello-world/jupyterlab_examples_hello_world/__init__.py b/basics/hello-world/jupyterlab_examples_hello_world/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/basics/hello-world/jupyterlab_examples_hello_world/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/basics/hello-world/jupyterlab_examples_hello_world/_version.py b/basics/hello-world/jupyterlab_examples_hello_world/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/basics/hello-world/jupyterlab_examples_hello_world/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/basics/hello-world/package.json b/basics/hello-world/package.json index 5124b0ac..73200c65 100644 --- a/basics/hello-world/package.json +++ b/basics/hello-world/package.json @@ -25,32 +25,46 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_hello_world/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.0.0" + "@jupyterlab/application": "^3.0.0-rc.15" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" ], "jupyterlab": { - "extension": true + "extension": true, + "outputDir": "jupyterlab_examples_hello_world/labextension" } -} +} \ No newline at end of file diff --git a/basics/hello-world/pyproject.toml b/basics/hello-world/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/basics/hello-world/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/basics/hello-world/setup.py b/basics/hello-world/setup.py new file mode 100644 index 00000000..c257f4eb --- /dev/null +++ b/basics/hello-world/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_hello_world setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_hello_world" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/hello-world" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="minimal lab example", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/basics/hello-world/style/base.css b/basics/hello-world/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/basics/hello-world/style/index.js b/basics/hello-world/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/basics/hello-world/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/basics/signals/MANIFEST.in b/basics/signals/MANIFEST.in new file mode 100644 index 00000000..d65867cc --- /dev/null +++ b/basics/signals/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_signals.json + +include package.json +include ts*.json + +graft jupyterlab_examples_signals/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/basics/signals/README.md b/basics/signals/README.md index 0e2a7dfb..5b216e25 100644 --- a/basics/signals/README.md +++ b/basics/signals/README.md @@ -21,7 +21,7 @@ JupyterLab's Lumino engine uses the `ISignal` interface and the The basic concept is as follows: -First, a widget (`button.ts`), in this case the one that contains +First, a widget (`button.tsx`), in this case the one that contains some visual elements such as a button, defines a `_stateChanged` signal: ```ts @@ -44,7 +44,7 @@ Another widget, in this case the panel (`panel.ts`) that boxes several different subscribes to the `stateChanged` signal and links some function to it: ```ts -// src/panel.ts#L22-L22 +// src/panel.ts#L29-L29 this._widget.stateChanged.connect(this._logMessage, this); ``` @@ -141,13 +141,14 @@ The `panel.ts` class defines an extension panel that displays the This is done in the constructor. ```ts -// src/panel.ts#L13-L23 +// src/panel.ts#L19-L30 -constructor() { super(); + this._translator = translator || nullTranslator; + this._trans = this._translator.load('jupyterlab'); this.addClass(PANEL_CLASS); this.id = 'SignalExamplePanel'; - this.title.label = 'Signal Example View'; + this.title.label = this._trans.__('Signal Example View'); this.title.closable = true; this._widget = new ButtonWidget(); @@ -160,7 +161,7 @@ Subscription to a signal is done using the `connect` method of the `stateChanged` attribute. ```ts -// src/panel.ts#L22-L22 +// src/panel.ts#L29-L29 this._widget.stateChanged.connect(this._logMessage, this); ``` @@ -178,7 +179,7 @@ The `_logMessage` function receives as parameters the emitter (of type `ButtonWi and the count (of type `ICount`) sent by the signal emitter. ```ts -// src/panel.ts#L25-L25 +// src/panel.ts#L32-L32 private _logMessage(emitter: ButtonWidget, count: ICount): void { ``` @@ -187,7 +188,7 @@ In our case, that function writes `Button has been clicked ... times.` text to the browser console and in an alert when the big red button is clicked. ```ts -// src/panel.ts#L25-L29 +// src/panel.ts#L32-L36 private _logMessage(emitter: ButtonWidget, count: ICount): void { console.log('Hey, a Signal has been received from', emitter); diff --git a/basics/signals/install.json b/basics/signals/install.json new file mode 100644 index 00000000..81d834da --- /dev/null +++ b/basics/signals/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_signals", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_signals" +} diff --git a/basics/signals/jupyterlab_examples_signals/__init__.py b/basics/signals/jupyterlab_examples_signals/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/basics/signals/jupyterlab_examples_signals/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/basics/signals/jupyterlab_examples_signals/_version.py b/basics/signals/jupyterlab_examples_signals/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/basics/signals/jupyterlab_examples_signals/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/basics/signals/package.json b/basics/signals/package.json index 70a46700..66cd9c26 100644 --- a/basics/signals/package.json +++ b/basics/signals/package.json @@ -25,38 +25,53 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_signals/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.0.0", - "@jupyterlab/launcher": "^2.0.0", - "@jupyterlab/mainmenu": "^2.0.0", - "@lumino/algorithm": "^1.2.0", - "@lumino/coreutils": "^1.3.1", + "@jupyterlab/application": "^3.0.0-rc.15", + "@jupyterlab/launcher": "^3.0.0-rc.15", + "@jupyterlab/mainmenu": "^3.0.0-rc.15", + "@jupyterlab/translation": "^3.0.0-rc.15", + "@lumino/algorithm": "^1.3.3", + "@lumino/coreutils": "^1.5.3", "@lumino/datagrid": "^0.3.1", - "@lumino/disposable": "^1.3.1" + "@lumino/disposable": "^1.4.3" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" ], "jupyterlab": { - "extension": true + "extension": true, + "outputDir": "jupyterlab_examples_signals/labextension" } -} +} \ No newline at end of file diff --git a/basics/signals/pyproject.toml b/basics/signals/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/basics/signals/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/basics/signals/setup.py b/basics/signals/setup.py new file mode 100644 index 00000000..d7381cf3 --- /dev/null +++ b/basics/signals/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_signals setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_signals" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/signals" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="minimal lab example", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/basics/signals/src/index.ts b/basics/signals/src/index.ts index 26f08d86..2ff2dd17 100644 --- a/basics/signals/src/index.ts +++ b/basics/signals/src/index.ts @@ -9,6 +9,8 @@ import { ILauncher } from '@jupyterlab/launcher'; import { IMainMenu } from '@jupyterlab/mainmenu'; +import { ITranslator } from '@jupyterlab/translation'; + import { Menu } from '@lumino/widgets'; import { SignalExamplePanel } from './panel'; @@ -27,8 +29,8 @@ const extension: JupyterFrontEndPlugin = { id: 'signals', autoStart: true, optional: [ILauncher], - requires: [ICommandPalette, IMainMenu], - activate: activate + requires: [ICommandPalette, IMainMenu, ITranslator], + activate }; /** @@ -37,17 +39,20 @@ const extension: JupyterFrontEndPlugin = { * @param app Jupyter Font End * @param palette Jupyter Commands Palette * @param mainMenu Jupyter Menu + * @param translator Jupyter Translator * @param launcher [optional] Jupyter Launcher */ function activate( app: JupyterFrontEnd, palette: ICommandPalette, mainMenu: IMainMenu, + translator: ITranslator, launcher: ILauncher | null ): void { const manager = app.serviceManager; const { commands, shell } = app; const category = 'Extension Examples'; + const trans = translator.load('jupyterlab'); // Add launcher if (launcher) { @@ -65,7 +70,7 @@ function activate( function createPanel(): Promise { let panel: SignalExamplePanel; return manager.ready.then(() => { - panel = new SignalExamplePanel(); + panel = new SignalExamplePanel(translator); shell.add(panel, 'main'); return panel; }); @@ -73,13 +78,13 @@ function activate( // Add menu tab const signalMenu = new Menu({ commands }); - signalMenu.title.label = 'Signal Example'; + signalMenu.title.label = trans.__('Signal Example'); mainMenu.addMenu(signalMenu); // Add commands to registry commands.addCommand(CommandIDs.create, { - label: 'Open the Signal Example Panel', - caption: 'Open the Signal Example Panel', + label: trans.__('Open the Signal Example Panel'), + caption: trans.__('Open the Signal Example Panel'), execute: createPanel }); diff --git a/basics/signals/src/panel.ts b/basics/signals/src/panel.ts index 9e870881..ff5be3df 100644 --- a/basics/signals/src/panel.ts +++ b/basics/signals/src/panel.ts @@ -1,3 +1,8 @@ +import { + ITranslator, + nullTranslator, + TranslationBundle +} from '@jupyterlab/translation'; import { StackedPanel } from '@lumino/widgets'; import { ButtonWidget, ICount } from './button'; @@ -10,11 +15,13 @@ const PANEL_CLASS = 'jp-tutorial-view'; * A panel which contains a console and the ability to add other children. */ export class SignalExamplePanel extends StackedPanel { - constructor() { + constructor(translator?: ITranslator) { super(); + this._translator = translator || nullTranslator; + this._trans = this._translator.load('jupyterlab'); this.addClass(PANEL_CLASS); this.id = 'SignalExamplePanel'; - this.title.label = 'Signal Example View'; + this.title.label = this._trans.__('Signal Example View'); this.title.closable = true; this._widget = new ButtonWidget(); @@ -33,4 +40,7 @@ export class SignalExamplePanel extends StackedPanel { } private _widget: ButtonWidget; + + private _translator: ITranslator; + private _trans: TranslationBundle; } diff --git a/basics/signals/style/base.css b/basics/signals/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/basics/signals/style/index.js b/basics/signals/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/basics/signals/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/command-palette/MANIFEST.in b/command-palette/MANIFEST.in new file mode 100644 index 00000000..31fb6283 --- /dev/null +++ b/command-palette/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_command_palette.json + +include package.json +include ts*.json + +graft jupyterlab_examples_command_palette/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/command-palette/install.json b/command-palette/install.json new file mode 100644 index 00000000..c7c38a01 --- /dev/null +++ b/command-palette/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_command_palette", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_command_palette" +} diff --git a/command-palette/jupyterlab_examples_command_palette/__init__.py b/command-palette/jupyterlab_examples_command_palette/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/command-palette/jupyterlab_examples_command_palette/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/command-palette/jupyterlab_examples_command_palette/_version.py b/command-palette/jupyterlab_examples_command_palette/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/command-palette/jupyterlab_examples_command_palette/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/command-palette/package.json b/command-palette/package.json index 9c534f57..3572bcad 100644 --- a/command-palette/package.json +++ b/command-palette/package.json @@ -25,32 +25,46 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_command_palette/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.0.0" + "@jupyterlab/application": "^3.0.0-rc.15" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" ], "jupyterlab": { - "extension": true + "extension": true, + "outputDir": "jupyterlab_examples_command_palette/labextension" } -} +} \ No newline at end of file diff --git a/command-palette/pyproject.toml b/command-palette/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/command-palette/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/command-palette/setup.py b/command-palette/setup.py new file mode 100644 index 00000000..fe413975 --- /dev/null +++ b/command-palette/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_command_palette setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_command_palette" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/command-palette" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="Minimal JupyterLab example adding a new command to the palette.", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/command-palette/style/base.css b/command-palette/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/command-palette/style/index.js b/command-palette/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/command-palette/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/commands/MANIFEST.in b/commands/MANIFEST.in new file mode 100644 index 00000000..88b2f920 --- /dev/null +++ b/commands/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_commands.json + +include package.json +include ts*.json + +graft jupyterlab_examples_commands/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/commands/install.json b/commands/install.json new file mode 100644 index 00000000..ea862194 --- /dev/null +++ b/commands/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_commands", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_commands" +} diff --git a/commands/jupyterlab_examples_commands/__init__.py b/commands/jupyterlab_examples_commands/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/commands/jupyterlab_examples_commands/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/commands/jupyterlab_examples_commands/_version.py b/commands/jupyterlab_examples_commands/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/commands/jupyterlab_examples_commands/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/commands/package.json b/commands/package.json index 3cdbe104..5fdddfe9 100644 --- a/commands/package.json +++ b/commands/package.json @@ -25,32 +25,46 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_commands/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.0.0" + "@jupyterlab/application": "^3.0.0-rc.15" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" ], "jupyterlab": { - "extension": true + "extension": true, + "outputDir": "jupyterlab_examples_commands/labextension" } -} +} \ No newline at end of file diff --git a/commands/pyproject.toml b/commands/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/commands/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/commands/setup.py b/commands/setup.py new file mode 100644 index 00000000..1448ae43 --- /dev/null +++ b/commands/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_commands setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_commands" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/commands" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="Minimal JupyterLab example creating a new command.", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/commands/style/base.css b/commands/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/commands/style/index.js b/commands/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/commands/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/context-menu/MANIFEST.in b/context-menu/MANIFEST.in new file mode 100644 index 00000000..84b5924d --- /dev/null +++ b/context-menu/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_context_menu.json + +include package.json +include ts*.json + +graft jupyterlab_examples_context_menu/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/context-menu/install.json b/context-menu/install.json new file mode 100644 index 00000000..db8ba8e6 --- /dev/null +++ b/context-menu/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_context_menu", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_context_menu" +} diff --git a/context-menu/jupyterlab_examples_context_menu/__init__.py b/context-menu/jupyterlab_examples_context_menu/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/context-menu/jupyterlab_examples_context_menu/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/context-menu/jupyterlab_examples_context_menu/_version.py b/context-menu/jupyterlab_examples_context_menu/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/context-menu/jupyterlab_examples_context_menu/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/context-menu/package.json b/context-menu/package.json index 0dffb243..7d7e8d78 100644 --- a/context-menu/package.json +++ b/context-menu/package.json @@ -25,35 +25,49 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_context_menu/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.1.2", - "@jupyterlab/apputils": "^2.1.1", - "@jupyterlab/filebrowser": "^2.1.2", - "@jupyterlab/ui-components": "^2.1.1" + "@jupyterlab/application": "^3.0.0-rc.15", + "@jupyterlab/apputils": "^3.0.0-rc.15", + "@jupyterlab/filebrowser": "^3.0.0-rc.15", + "@jupyterlab/ui-components": "^3.0.0-rc.15" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" ], "jupyterlab": { - "extension": true + "extension": true, + "outputDir": "jupyterlab_examples_context_menu/labextension" } -} +} \ No newline at end of file diff --git a/context-menu/pyproject.toml b/context-menu/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/context-menu/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/context-menu/setup.py b/context-menu/setup.py new file mode 100644 index 00000000..ce0832aa --- /dev/null +++ b/context-menu/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_context_menu setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_context_menu" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/context-menu" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="A minimal JupyterLab example to develop a context-menu.", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/context-menu/style/base.css b/context-menu/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/context-menu/style/index.js b/context-menu/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/context-menu/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/environment.yml b/environment.yml index 76b35029..b80d7ad8 100644 --- a/environment.yml +++ b/environment.yml @@ -2,7 +2,7 @@ name: jupyterlab-extension-examples channels: - conda-forge dependencies: +- jupyterlab=3 - nodejs - python=3 - yarn -- jupyterlab=2 diff --git a/launcher/LICENSE b/launcher/LICENSE index 2649ea39..5df00610 100644 --- a/launcher/LICENSE +++ b/launcher/LICENSE @@ -27,4 +27,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/launcher/MANIFEST.in b/launcher/MANIFEST.in new file mode 100644 index 00000000..0551ee1f --- /dev/null +++ b/launcher/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_launcher.json + +include package.json +include ts*.json + +graft jupyterlab_examples_launcher/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/launcher/install.json b/launcher/install.json new file mode 100644 index 00000000..26ec5ef7 --- /dev/null +++ b/launcher/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_launcher", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_launcher" +} diff --git a/launcher/jupyterlab_examples_launcher/__init__.py b/launcher/jupyterlab_examples_launcher/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/launcher/jupyterlab_examples_launcher/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/launcher/jupyterlab_examples_launcher/_version.py b/launcher/jupyterlab_examples_launcher/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/launcher/jupyterlab_examples_launcher/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/launcher/package.json b/launcher/package.json index 2ffb3ffb..1c6b2f15 100644 --- a/launcher/package.json +++ b/launcher/package.json @@ -25,36 +25,50 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_launcher/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.0.0", - "@jupyterlab/filebrowser": "^2.0.0", - "@jupyterlab/launcher": "^2.0.0", - "@jupyterlab/mainmenu": "^2.0.0" + "@jupyterlab/application": "^3.0.0-rc.15", + "@jupyterlab/filebrowser": "^3.0.0-rc.15", + "@jupyterlab/launcher": "^3.0.0-rc.15", + "@jupyterlab/mainmenu": "^3.0.0-rc.15" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css", "style/*.svg" ], "jupyterlab": { - "extension": true + "extension": true, + "outputDir": "jupyterlab_examples_launcher/labextension" } -} +} \ No newline at end of file diff --git a/launcher/pyproject.toml b/launcher/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/launcher/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/launcher/setup.py b/launcher/setup.py new file mode 100644 index 00000000..1dd4ea27 --- /dev/null +++ b/launcher/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_launcher setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_launcher" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/launcher" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="A minimal JupyterLab example using the launcher.", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/launcher/style/base.css b/launcher/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/launcher/style/index.js b/launcher/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/launcher/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/log-console/custom-log-console/MANIFEST.in b/log-console/custom-log-console/MANIFEST.in new file mode 100644 index 00000000..2133e4ee --- /dev/null +++ b/log-console/custom-log-console/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_custom_log_console.json + +include package.json +include ts*.json + +graft jupyterlab_examples_custom_log_console/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/log-console/custom-log-console/install.json b/log-console/custom-log-console/install.json new file mode 100644 index 00000000..5e894618 --- /dev/null +++ b/log-console/custom-log-console/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_custom_log_console", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_custom_log_console" +} diff --git a/log-console/custom-log-console/jupyterlab_examples_custom_log_console/__init__.py b/log-console/custom-log-console/jupyterlab_examples_custom_log_console/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/log-console/custom-log-console/jupyterlab_examples_custom_log_console/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/log-console/custom-log-console/jupyterlab_examples_custom_log_console/_version.py b/log-console/custom-log-console/jupyterlab_examples_custom_log_console/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/log-console/custom-log-console/jupyterlab_examples_custom_log_console/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/log-console/custom-log-console/package.json b/log-console/custom-log-console/package.json index a16a0a49..4cb4c733 100644 --- a/log-console/custom-log-console/package.json +++ b/log-console/custom-log-console/package.json @@ -25,41 +25,55 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_custom_log_console/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.1.2", - "@jupyterlab/apputils": "^2.1.1", - "@jupyterlab/coreutils": "^4.1.0", - "@jupyterlab/logconsole": "^2.1.1", - "@jupyterlab/mainmenu": "^2.1.1", - "@jupyterlab/nbformat": "^2.1.0", - "@jupyterlab/rendermime": "^2.1.1", - "@jupyterlab/ui-components": "^2.1.1", - "@lumino/coreutils": "^1.5.0", - "@lumino/widgets": "^1.13.0" + "@jupyterlab/application": "^3.0.0-rc.15", + "@jupyterlab/apputils": "^3.0.0-rc.15", + "@jupyterlab/coreutils": "^5.0.0-rc.15", + "@jupyterlab/logconsole": "^3.0.0-rc.15", + "@jupyterlab/mainmenu": "^3.0.0-rc.15", + "@jupyterlab/nbformat": "^3.0.0-rc.15", + "@jupyterlab/rendermime": "^3.0.0-rc.15", + "@jupyterlab/ui-components": "^3.0.0-rc.15", + "@lumino/coreutils": "^1.5.3", + "@lumino/widgets": "^1.16.1" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" ], "jupyterlab": { - "extension": true + "extension": true, + "outputDir": "jupyterlab_examples_custom_log_console/labextension" } -} +} \ No newline at end of file diff --git a/log-console/custom-log-console/pyproject.toml b/log-console/custom-log-console/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/log-console/custom-log-console/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/log-console/custom-log-console/setup.py b/log-console/custom-log-console/setup.py new file mode 100644 index 00000000..bc188912 --- /dev/null +++ b/log-console/custom-log-console/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_custom_log_console setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_custom_log_console" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/custom-log-console" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="A minimal JupyterLab example to develop a custom log console.", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/log-console/custom-log-console/style/base.css b/log-console/custom-log-console/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/log-console/custom-log-console/style/index.js b/log-console/custom-log-console/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/log-console/custom-log-console/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/log-console/log-messages/MANIFEST.in b/log-console/log-messages/MANIFEST.in new file mode 100644 index 00000000..37ebc43a --- /dev/null +++ b/log-console/log-messages/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_log_messages.json + +include package.json +include ts*.json + +graft jupyterlab_examples_log_messages/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/log-console/log-messages/install.json b/log-console/log-messages/install.json new file mode 100644 index 00000000..be850e33 --- /dev/null +++ b/log-console/log-messages/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_log_messages", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_log_messages" +} diff --git a/log-console/log-messages/jupyterlab_examples_log_messages/__init__.py b/log-console/log-messages/jupyterlab_examples_log_messages/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/log-console/log-messages/jupyterlab_examples_log_messages/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/log-console/log-messages/jupyterlab_examples_log_messages/_version.py b/log-console/log-messages/jupyterlab_examples_log_messages/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/log-console/log-messages/jupyterlab_examples_log_messages/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/log-console/log-messages/package.json b/log-console/log-messages/package.json index 9127dc0d..dcd83e8d 100644 --- a/log-console/log-messages/package.json +++ b/log-console/log-messages/package.json @@ -25,42 +25,56 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_log_messages/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.1.2", - "@jupyterlab/apputils": "^2.1.1", - "@jupyterlab/coreutils": "^4.1.0", - "@jupyterlab/logconsole": "^2.1.1", - "@jupyterlab/mainmenu": "^2.1.1", - "@jupyterlab/nbformat": "^2.1.0", - "@jupyterlab/notebook": "^2.1.2", - "@jupyterlab/rendermime": "^2.1.1", - "@jupyterlab/ui-components": "^2.1.1", - "@lumino/coreutils": "^1.5.0", - "@lumino/widgets": "^1.13.0" + "@jupyterlab/application": "^3.0.0-rc.15", + "@jupyterlab/apputils": "^3.0.0-rc.15", + "@jupyterlab/coreutils": "^5.0.0-rc.15", + "@jupyterlab/logconsole": "^3.0.0-rc.15", + "@jupyterlab/mainmenu": "^3.0.0-rc.15", + "@jupyterlab/nbformat": "^3.0.0-rc.15", + "@jupyterlab/notebook": "^3.0.0-rc.15", + "@jupyterlab/rendermime": "^3.0.0-rc.15", + "@jupyterlab/ui-components": "^3.0.0-rc.15", + "@lumino/coreutils": "^1.5.3", + "@lumino/widgets": "^1.16.1" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" ], "jupyterlab": { - "extension": true + "extension": true, + "outputDir": "jupyterlab_examples_log_messages/labextension" } -} +} \ No newline at end of file diff --git a/log-console/log-messages/pyproject.toml b/log-console/log-messages/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/log-console/log-messages/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/log-console/log-messages/setup.py b/log-console/log-messages/setup.py new file mode 100644 index 00000000..0b2b0356 --- /dev/null +++ b/log-console/log-messages/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_log_messages setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_log_messages" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/log-messages" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="A minimal JupyterLab example to develop a custom log-messages.", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/log-console/log-messages/style/base.css b/log-console/log-messages/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/log-console/log-messages/style/index.js b/log-console/log-messages/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/log-console/log-messages/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/main-menu/MANIFEST.in b/main-menu/MANIFEST.in new file mode 100644 index 00000000..1a2c9e9a --- /dev/null +++ b/main-menu/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_main_menu.json + +include package.json +include ts*.json + +graft jupyterlab_examples_main_menu/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/main-menu/README.md b/main-menu/README.md index 1fdb7b84..4d56f9c5 100644 --- a/main-menu/README.md +++ b/main-menu/README.md @@ -85,12 +85,12 @@ After the execution of that command, `package.json` should list them in the `dependencies`: ```json5 -// package.json#L36-L40 +// package.json#L46-L50 "dependencies": { - "@jupyterlab/application": "^2.0.0", - "@jupyterlab/mainmenu": "^2.0.0", - "@lumino/widgets": "^1.9.3" + "@jupyterlab/application": "^3.0.0-rc.15", + "@jupyterlab/mainmenu": "^3.0.0-rc.15", + "@lumino/widgets": "^1.16.1" }, ``` diff --git a/main-menu/install.json b/main-menu/install.json new file mode 100644 index 00000000..0749265a --- /dev/null +++ b/main-menu/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_main_menu", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_main_menu" +} diff --git a/main-menu/jupyterlab_examples_main_menu/__init__.py b/main-menu/jupyterlab_examples_main_menu/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/main-menu/jupyterlab_examples_main_menu/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/main-menu/jupyterlab_examples_main_menu/_version.py b/main-menu/jupyterlab_examples_main_menu/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/main-menu/jupyterlab_examples_main_menu/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/main-menu/package.json b/main-menu/package.json index c84d7fca..30004a35 100644 --- a/main-menu/package.json +++ b/main-menu/package.json @@ -25,34 +25,48 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_main_menu/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.0.0", - "@jupyterlab/mainmenu": "^2.0.0", - "@lumino/widgets": "^1.9.3" + "@jupyterlab/application": "^3.0.0-rc.15", + "@jupyterlab/mainmenu": "^3.0.0-rc.15", + "@lumino/widgets": "^1.16.1" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" ], "jupyterlab": { - "extension": true + "extension": true, + "outputDir": "jupyterlab_examples_main_menu/labextension" } -} +} \ No newline at end of file diff --git a/main-menu/pyproject.toml b/main-menu/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/main-menu/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/main-menu/setup.py b/main-menu/setup.py new file mode 100644 index 00000000..67f3b592 --- /dev/null +++ b/main-menu/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_main_menu setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_main_menu" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/main-menu" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="Minimal JupyterLab example adding a menu.", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/main-menu/style/base.css b/main-menu/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/main-menu/style/index.js b/main-menu/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/main-menu/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/package.json b/package.json index d4e6e7c2..80aff00d 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,11 @@ "scripts": { "bootstrap": "lerna bootstrap", "install": "lerna bootstrap", - "build-jlab": "jupyter lab build --debug", - "build-ext": "lerna run build", + "build-ext": "lerna run build:all", "clean-ext": "lerna run clean", "embedme": "embedme \"[!n]*/**/README.md\"", - "install-ext": "lerna run install-ext", + "install-py": "lerna exec --concurrency 4 -- python -m pip install -e .", + "install-ext": "lerna run install:extension", "lint": "jlpm && jlpm run prettier", "lint:check": "jlpm run embedme --verify && jlpm run prettier:check", "prettier": "prettier --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"", diff --git a/react/react-widget/MANIFEST.in b/react/react-widget/MANIFEST.in new file mode 100644 index 00000000..6444b9ab --- /dev/null +++ b/react/react-widget/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_react_widget.json + +include package.json +include ts*.json + +graft jupyterlab_examples_react_widget/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/react/react-widget/install.json b/react/react-widget/install.json new file mode 100644 index 00000000..add866c4 --- /dev/null +++ b/react/react-widget/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_react_widget", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_react_widget" +} diff --git a/react/react-widget/jupyterlab_examples_react_widget/__init__.py b/react/react-widget/jupyterlab_examples_react_widget/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/react/react-widget/jupyterlab_examples_react_widget/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/react/react-widget/jupyterlab_examples_react_widget/_version.py b/react/react-widget/jupyterlab_examples_react_widget/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/react/react-widget/jupyterlab_examples_react_widget/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/react/react-widget/package.json b/react/react-widget/package.json index 9350e99d..482f68e2 100644 --- a/react/react-widget/package.json +++ b/react/react-widget/package.json @@ -25,33 +25,48 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_react_widget/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.0.0", - "@jupyterlab/launcher": "^2.0.0", - "@jupyterlab/ui-components": "^2.0.0" + "@jupyterlab/application": "^3.0.0-rc.15", + "@jupyterlab/launcher": "^3.0.0-rc.15", + "@jupyterlab/ui-components": "^3.0.0-rc.15" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" ], "jupyterlab": { - "extension": true + "extension": true, + "outputDir": "jupyterlab_examples_react_widget/labextension" } -} +} \ No newline at end of file diff --git a/react/react-widget/pyproject.toml b/react/react-widget/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/react/react-widget/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/react/react-widget/setup.py b/react/react-widget/setup.py new file mode 100644 index 00000000..931251aa --- /dev/null +++ b/react/react-widget/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_react_widget setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_react_widget" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/react-widget" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="Example of using a React Widget in a Jupyterlab extension", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/react/react-widget/src/index.ts b/react/react-widget/src/index.ts index 58e2f38d..efe11cee 100644 --- a/react/react-widget/src/index.ts +++ b/react/react-widget/src/index.ts @@ -37,6 +37,7 @@ const extension: JupyterFrontEndPlugin = { const content = new CounterWidget(); const widget = new MainAreaWidget({ content }); widget.title.label = 'React Widget'; + widget.title.icon = reactIcon; app.shell.add(widget, 'main'); } }); diff --git a/react/react-widget/style/base.css b/react/react-widget/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/react/react-widget/style/index.js b/react/react-widget/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/react/react-widget/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/scripts/upgrade_extensions.py b/scripts/upgrade_extensions.py new file mode 100644 index 00000000..da07c0c7 --- /dev/null +++ b/scripts/upgrade_extensions.py @@ -0,0 +1,45 @@ +import os +import os.path as osp +import shutil +import subprocess +import sys + + +HERE = osp.abspath(osp.dirname(__file__)) + +def get_exts(dname): + """Get the relative paths to all of the extensions""" + paths = [] + for path in os.listdir(dname): + if path in ['node_modules', '.git']: + continue + full_path = osp.join(dname, path) + package_path = osp.join(full_path, 'package.json') + if osp.exists(package_path): + paths.append(full_path) + elif osp.isdir(full_path): + paths.extend(get_exts(full_path)) + return paths + + +def main(): + """Upgrade all of the extensions""" + for ext in get_exts(osp.dirname(HERE)): + print(ext) + had_licence = osp.exists(osp.join(ext, 'LICENSE')) + subprocess.run([sys.executable, '-m', 'jupyterlab.upgrade_extension', '--no-input', ext]) + # Overwrite setup.py and pyproject.toml directly + for fname in ['setup.py', 'pyproject.toml']: + shutil.move(osp.join(ext, '_temp_extension', fname), osp.join(ext, fname)) + # Remove unused files from the cookiecutter + for fname in ['.prettierignore', '.prettierrc', 'LICENSE']: + if had_licence and fname == 'LICENSE': + continue + os.remove(osp.join(ext, fname)) + # Remove unused directories from the cookiecutter + for dname in ['.github', '_temp_extension']: + shutil.rmtree(osp.join(ext, dname)) + + +if __name__ == "__main__": + main() diff --git a/settings/MANIFEST.in b/settings/MANIFEST.in new file mode 100644 index 00000000..be45817b --- /dev/null +++ b/settings/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_settings.json + +include package.json +include ts*.json + +graft jupyterlab_examples_settings/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/settings/README.md b/settings/README.md index 2e5460d5..b6ebcea9 100644 --- a/settings/README.md +++ b/settings/README.md @@ -109,11 +109,12 @@ the `package.json` file in the `jupyterlab` section (here `schema`): ```json5 -// package.json#L57-L60 +// package.json#L70-L74 "jupyterlab": { "extension": true, - "schemaDir": "schema" + "schemaDir": "schema", + "outputDir": "jupyterlab_examples_settings/labextension" } ``` diff --git a/settings/install.json b/settings/install.json new file mode 100644 index 00000000..2e20e5d1 --- /dev/null +++ b/settings/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_settings", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_settings" +} diff --git a/settings/jupyterlab_examples_settings/__init__.py b/settings/jupyterlab_examples_settings/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/settings/jupyterlab_examples_settings/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/settings/jupyterlab_examples_settings/_version.py b/settings/jupyterlab_examples_settings/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/settings/jupyterlab_examples_settings/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/settings/package.json b/settings/package.json index 84fb3c61..cdbb7c96 100644 --- a/settings/package.json +++ b/settings/package.json @@ -26,36 +26,50 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_settings/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.0.0", - "@jupyterlab/mainmenu": "^2.0.0", - "@jupyterlab/settingregistry": "^2.0.0", - "@lumino/widgets": "^1.9.3" + "@jupyterlab/application": "^3.0.0-rc.15", + "@jupyterlab/mainmenu": "^3.0.0-rc.15", + "@jupyterlab/settingregistry": "^3.0.0-rc.15", + "@lumino/widgets": "^1.16.1" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" ], "jupyterlab": { "extension": true, - "schemaDir": "schema" + "schemaDir": "schema", + "outputDir": "jupyterlab_examples_settings/labextension" } -} +} \ No newline at end of file diff --git a/settings/pyproject.toml b/settings/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/settings/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/settings/setup.py b/settings/setup.py new file mode 100644 index 00000000..a3ed2a73 --- /dev/null +++ b/settings/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_settings setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_settings" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/settings" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="A JupyterLab minimal example using settings.", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/settings/style/base.css b/settings/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/settings/style/index.js b/settings/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/settings/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/state/MANIFEST.in b/state/MANIFEST.in new file mode 100644 index 00000000..2faf7778 --- /dev/null +++ b/state/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_state.json + +include package.json +include ts*.json + +graft jupyterlab_examples_state/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/state/install.json b/state/install.json new file mode 100644 index 00000000..e61b1e70 --- /dev/null +++ b/state/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_state", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_state" +} diff --git a/state/jupyterlab_examples_state/__init__.py b/state/jupyterlab_examples_state/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/state/jupyterlab_examples_state/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/state/jupyterlab_examples_state/_version.py b/state/jupyterlab_examples_state/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/state/jupyterlab_examples_state/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/state/package.json b/state/package.json index 192f3fdc..924260ca 100644 --- a/state/package.json +++ b/state/package.json @@ -25,35 +25,49 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_state/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.0.0", - "@jupyterlab/apputils": "^2.0.0", - "@jupyterlab/statedb": "^2.0.0", - "@lumino/coreutils": "^1.4.2" + "@jupyterlab/application": "^3.0.0-rc.15", + "@jupyterlab/apputils": "^3.0.0-rc.15", + "@jupyterlab/statedb": "^3.0.0-rc.15", + "@lumino/coreutils": "^1.5.3" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" ], "jupyterlab": { - "extension": true + "extension": true, + "outputDir": "jupyterlab_examples_state/labextension" } -} +} \ No newline at end of file diff --git a/state/pyproject.toml b/state/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/state/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/state/setup.py b/state/setup.py new file mode 100644 index 00000000..7a010652 --- /dev/null +++ b/state/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_state setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_state" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/state" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="A minimal JupyterLab example using state database (DB).", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/state/style/base.css b/state/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/state/style/index.js b/state/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/state/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/widget-tracker/widgets/MANIFEST.in b/widget-tracker/widgets/MANIFEST.in new file mode 100644 index 00000000..04b6c5db --- /dev/null +++ b/widget-tracker/widgets/MANIFEST.in @@ -0,0 +1,22 @@ +include LICENSE +include README.md +include pyproject.toml +include jupyter-config/jupyterlab_examples_widgets.json + +include package.json +include ts*.json + +graft jupyterlab_examples_widgets/labextension + +# Javascript files +graft src +graft style +prune **/node_modules +prune lib + +# Patterns to exclude from any directory +global-exclude *~ +global-exclude *.pyc +global-exclude *.pyo +global-exclude .git +global-exclude .ipynb_checkpoints diff --git a/widget-tracker/widgets/install.json b/widget-tracker/widgets/install.json new file mode 100644 index 00000000..947119e8 --- /dev/null +++ b/widget-tracker/widgets/install.json @@ -0,0 +1,5 @@ +{ + "packageManager": "python", + "packageName": "jupyterlab_examples_widgets", + "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_widgets" +} diff --git a/widget-tracker/widgets/jupyterlab_examples_widgets/__init__.py b/widget-tracker/widgets/jupyterlab_examples_widgets/__init__.py new file mode 100644 index 00000000..353ab522 --- /dev/null +++ b/widget-tracker/widgets/jupyterlab_examples_widgets/__init__.py @@ -0,0 +1,19 @@ + +import json +import os.path as osp + +from ._version import __version__ + +HERE = osp.abspath(osp.dirname(__file__)) + +with open(osp.join(HERE, 'labextension', 'package.json')) as fid: + data = json.load(fid) + +def _jupyter_labextension_paths(): + return [{ + 'src': 'labextension', + 'dest': data['name'] + }] + + + diff --git a/widget-tracker/widgets/jupyterlab_examples_widgets/_version.py b/widget-tracker/widgets/jupyterlab_examples_widgets/_version.py new file mode 100644 index 00000000..ee864fc9 --- /dev/null +++ b/widget-tracker/widgets/jupyterlab_examples_widgets/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 1, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/widget-tracker/widgets/package.json b/widget-tracker/widgets/package.json index 27e3ab61..918c4a01 100644 --- a/widget-tracker/widgets/package.json +++ b/widget-tracker/widgets/package.json @@ -25,36 +25,50 @@ "url": "https://github.com/jupyterlab/extension-examples.git" }, "scripts": { - "build": "tsc", - "clean": "rimraf lib tsconfig.tsbuildinfo", - "install-ext": "jupyter labextension install . --no-build", - "prepare": "jlpm run clean && jlpm run build", + "build": "jlpm run build:lib && jlpm run build:labextension:dev", + "build:all": "jlpm run build:lib && jlpm run build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc", + "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "clean": "jlpm run clean:lib", + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_widgets/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "watch": "tsc -w" + "install:extension": "jupyter labextension develop --overwrite .", + "prepare": "jlpm run clean && jlpm run build:prod", + "watch": "run-p watch:src watch:labextension", + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^2.0.0", - "@jupyterlab/mainmenu": "^2.0.0", - "@lumino/algorithm": "^1.2.0", - "@lumino/coreutils": "^1.3.1", - "@lumino/disposable": "^1.3.1" + "@jupyterlab/application": "^3.0.0-rc.15", + "@jupyterlab/mainmenu": "^3.0.0-rc.15", + "@lumino/algorithm": "^1.3.3", + "@lumino/coreutils": "^1.5.3", + "@lumino/disposable": "^1.4.3" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", + "@jupyterlab/builder": "^3.0.0-rc.15", + "@typescript-eslint/eslint-plugin": "^2.27.0", + "@typescript-eslint/parser": "^2.27.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.10.1", "eslint-plugin-jsdoc": "^22.0.0", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.18.3", - "rimraf": "^3.0.0", - "typescript": "~3.7.5" + "npm-run-all": "^4.1.5", + "prettier": "^1.19.0", + "rimraf": "^3.0.2", + "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css" ], "jupyterlab": { - "extension": true + "extension": true, + "outputDir": "jupyterlab_examples_widgets/labextension" } -} +} \ No newline at end of file diff --git a/widget-tracker/widgets/pyproject.toml b/widget-tracker/widgets/pyproject.toml new file mode 100644 index 00000000..c40f3629 --- /dev/null +++ b/widget-tracker/widgets/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/widget-tracker/widgets/setup.py b/widget-tracker/widgets/setup.py new file mode 100644 index 00000000..73c2c1e1 --- /dev/null +++ b/widget-tracker/widgets/setup.py @@ -0,0 +1,93 @@ +""" +jupyterlab_examples_widgets setup +""" +import json +import os + +from jupyter_packaging import ( + create_cmdclass, install_npm, ensure_targets, + combine_commands, skip_if_exists +) +import setuptools + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# The name of the project +name="jupyterlab_examples_widgets" + +# Get our version +with open(os.path.join(HERE, 'package.json')) as f: + version = json.load(f)['version'] + +lab_path = os.path.join(HERE, name, "labextension") + +# Representative files that should exist after a successful build +jstargets = [ + os.path.join(lab_path, "package.json"), +] + +package_data_spec = { + name: [ + "*" + ] +} + +labext_name = "@jupyterlab-examples/widgets" + +data_files_spec = [ + ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), + ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), +] + +cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec +) + +js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), +) + +is_repo = os.path.exists(os.path.join(HERE, ".git")) +if is_repo: + cmdclass["jsdeps"] = js_command +else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +with open("README.md", "r") as fh: + long_description = fh.read() + +setup_args = dict( + name=name, + version=version, + url="https://github.com/jupyterlab/extension-examples.git", + author="Project Jupyter Contributors", + description="minimal lab example", + long_description= long_description, + long_description_content_type="text/markdown", + cmdclass= cmdclass, + packages=setuptools.find_packages(), + install_requires=[ + "jupyterlab>=3.0.0rc15,==3.*", + ], + zip_safe=False, + include_package_data=True, + python_requires=">=3.6", + license="BSD-3-Clause", + platforms="Linux, Mac OS X, Windows", + keywords=["Jupyter", "JupyterLab", "JupyterLab3"], + classifiers=[ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Jupyter", + ], +) + + +if __name__ == "__main__": + setuptools.setup(**setup_args) diff --git a/widget-tracker/widgets/style/base.css b/widget-tracker/widgets/style/base.css new file mode 100644 index 00000000..e69de29b diff --git a/widget-tracker/widgets/style/index.js b/widget-tracker/widgets/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/widget-tracker/widgets/style/index.js @@ -0,0 +1 @@ +import './base.css';