Skip to content

Commit 944f073

Browse files
authored
Merge pull request #137 from jupyterlab/3.0
Merge 3.0 -> master
2 parents 802561f + 4f15b8e commit 944f073

File tree

181 files changed

+3272
-516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+3272
-516
lines changed

.github/workflows/main.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ jobs:
8787
${{ runner.os }}-pip-
8888
- name: Install the Python dependencies
8989
if: steps.filter.outputs.extension == 'true'
90-
run: python -m pip install jupyterlab
90+
run: |
91+
python -m pip install --upgrade pip
92+
python -m pip install jupyter_packaging
93+
python -m pip install jupyterlab
9194
- name: Install the NPM dependencies
9295
if: steps.filter.outputs.extension == 'true'
9396
run: |
@@ -108,9 +111,12 @@ jobs:
108111
if: steps.filter.outputs.extension == 'true'
109112
run: |
110113
cd ${EXAMPLE_FOLDER}
111-
jlpm run build
112-
jupyter labextension install .
114+
pip install -e .
115+
jupyter labextension list 1>labextensions 2>&1
116+
cat labextensions
117+
cat labextensions | grep -i "@jupyterlab-examples/*.*OK"
113118
python -m jupyterlab.browser_check
119+
pip uninstall -y $(python setup.py --name)
114120
env:
115121
EXAMPLE_FOLDER: ${{ matrix.example }}
116122
shell: bash
@@ -176,6 +182,7 @@ jobs:
176182
- name: Install the Python dependencies
177183
if: steps.filter.outputs.extension == 'true'
178184
run: |
185+
python -m pip install --upgrade pip
179186
python -m pip install jupyter_packaging
180187
python -m pip install jupyterlab
181188
- name: Install the NPM dependencies
@@ -194,13 +201,12 @@ jobs:
194201
run: |
195202
cd advanced/server-extension
196203
python setup.py sdist
197-
pip install jlab_ext_example --pre --find-links=dist --no-cache-dir
198-
jupyter lab build
204+
pip install ./dist/jlab_ext_example* --pre --find-links=dist --no-cache-dir
199205
python -m jupyterlab.browser_check
200206
- name: Check extension as dev
201207
if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') )
202208
run: |
203-
jupyter serverextension list 1>serverextensions 2>&1
209+
jupyter server extension list 1>serverextensions 2>&1
204210
cat serverextensions | grep "jlab_ext_example.*OK"
205211
jupyter labextension list 1>labextensions 2>&1
206212
cat labextensions | grep "@jupyterlab-examples/server-extension.*OK"
@@ -209,19 +215,18 @@ jobs:
209215
run: |
210216
pip uninstall -y jlab_ext_example
211217
jupyter lab clean
212-
jupyter serverextension list
218+
jupyter server extension list
213219
jupyter labextension list
214220
- name: Build extension as dev
215221
if: steps.filter.outputs.extension == 'true'
216222
run: |
217223
cd advanced/server-extension
218224
pip install -e .
219-
jupyter serverextension enable --py jlab_ext_example
220-
jupyter labextension install .
225+
jupyter server extension enable --py jlab_ext_example
221226
- name: Check extension as dev
222227
if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') )
223228
run: |
224-
jupyter serverextension list 1>serverextensions 2>&1
229+
jupyter server extension list 1>serverextensions 2>&1
225230
cat serverextensions | grep "jlab_ext_example.*OK"
226231
jupyter labextension list 1>labextensions 2>&1
227232
cat labextensions | grep "@jupyterlab-examples/server-extension.*OK"
@@ -275,4 +280,3 @@ jobs:
275280
jlpm build-ext
276281
jlpm lint:check
277282
jlpm install-ext
278-
jlpm build-jlab

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,10 @@ node_modules/
66
.ipynb_checkpoints
77
*.tsbuildinfo
88
*.lock
9+
__pycache__
10+
911
# Ensure embedme does not run ont node_modules README.md files.
1012
**/node_modules/**/README.md
13+
14+
static
15+
labextension

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
**/node_modules
33
**/lib
44
**/package.json
5+
**/labextension

README.md

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,41 @@ The goal of this repository is to show how to develop extensions for [JupyterLab
1010
To get started:
1111

1212
```bash
13-
git clone https://github.com/jupyterlab/extension-examples.git jupyterlab-extension-examples && \
14-
cd jupyterlab-extension-examples && \
15-
conda env create && \
16-
conda activate jupyterlab-extension-examples && \
17-
cd basics/hello-world && \
18-
jlpm && \
19-
jlpm run build && \
20-
jupyter labextension install . && \
21-
jupyter lab
13+
# clone the repository
14+
git clone https://github.com/jupyterlab/extension-examples.git jupyterlab-extension-examples
15+
16+
# go to the extension examples folder
17+
cd jupyterlab-extension-examples
18+
19+
# create a new environment
20+
conda env create
21+
22+
# activate the environment
23+
conda activate jupyterlab-extension-examples
24+
25+
# go to the hello world example
26+
cd basics/hello-world
27+
28+
# install the extension in editable mode
29+
python -m pip install -e .
30+
31+
# install your development version of the extension with JupyterLab
32+
jupyter labextension develop . --overwrite
33+
34+
# build the TypeScript source after making changes
35+
jlpm run build
36+
37+
# start JupyterLab
38+
jupyter lab
2239
```
2340

24-
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.
41+
The examples currently target **JupyterLab 3.x**.
42+
43+
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).
44+
45+
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).
46+
47+
Note that the `1.x` and `2.x` branches are not updated anymore.
2548

2649
## Develop by Examples
2750

@@ -210,11 +233,17 @@ conda env create && \
210233
```bash
211234
jlpm
212235
jlpm build-ext
236+
jlpm install-py
213237
jlpm install-ext
214-
jlpm build-jlab
215238
jupyter lab
216239
```
217240

241+
To rebuild all the extensions:
242+
243+
```bash
244+
jlpm build-ext
245+
```
246+
218247
To clean the lib folders:
219248

220249
```bash

advanced/kernel-messaging/MANIFEST.in

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
include LICENSE
2+
include README.md
3+
include pyproject.toml
4+
include jupyter-config/jupyterlab_examples_kernel_messaging.json
5+
6+
include package.json
7+
include ts*.json
8+
9+
graft jupyterlab_examples_kernel_messaging/labextension
10+
11+
# Javascript files
12+
graft src
13+
graft style
14+
prune **/node_modules
15+
prune lib
16+
17+
# Patterns to exclude from any directory
18+
global-exclude *~
19+
global-exclude *.pyc
20+
global-exclude *.pyo
21+
global-exclude .git
22+
global-exclude .ipynb_checkpoints

advanced/kernel-messaging/README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Jupyterlab provides a class `SessionContext`
3636
that manages a single kernel session. Here is the code to initialize such session:
3737

3838
```ts
39-
// src/panel.ts#L33-L37
39+
// src/panel.ts#L41-L45
4040

4141
this._sessionContext = new SessionContext({
4242
sessionManager: manager.sessions,
@@ -46,7 +46,7 @@ this._sessionContext = new SessionContext({
4646
```
4747

4848
<!-- prettier-ignore-start -->
49-
<!-- embedme src/panel.ts#L43-L54 -->
49+
<!-- embedme src/panel.ts#L51-L62 -->
5050

5151
```ts
5252
void this._sessionContext
@@ -68,7 +68,7 @@ The session manager object is
6868
provided directly by the JupyterLab application:
6969

7070
```ts
71-
// src/index.ts#L48-L48
71+
// src/index.ts#L52-L52
7272

7373
const manager = app.serviceManager;
7474
```
@@ -81,14 +81,16 @@ to free the kernel session resources if the panel is closed. The whole adapted
8181
panel class looks like this:
8282

8383
```ts
84-
// src/panel.ts#L25-L74
84+
// src/panel.ts#L31-L85
8585

8686
export class ExamplePanel extends StackedPanel {
87-
constructor(manager: ServiceManager.IManager) {
87+
constructor(manager: ServiceManager.IManager, translator?: ITranslator) {
8888
super();
89+
this._translator = translator || nullTranslator;
90+
this._trans = this._translator.load('jupyterlab');
8991
this.addClass(PANEL_CLASS);
9092
this.id = 'kernel-messaging-panel';
91-
this.title.label = 'Kernel Messaging Example View';
93+
this.title.label = this._trans.__('Kernel Messaging Example View');
9294
this.title.closable = true;
9395

9496
this._sessionContext = new SessionContext({
@@ -132,6 +134,9 @@ export class ExamplePanel extends StackedPanel {
132134
private _model: KernelModel;
133135
private _sessionContext: SessionContext;
134136
private _example: KernelView;
137+
138+
private _translator: ITranslator;
139+
private _trans: TranslationBundle;
135140
}
136141
```
137142

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"packageManager": "python",
3+
"packageName": "jupyterlab_examples_kernel_messaging",
4+
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_examples_kernel_messaging"
5+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
import json
3+
import os.path as osp
4+
5+
from ._version import __version__
6+
7+
HERE = osp.abspath(osp.dirname(__file__))
8+
9+
with open(osp.join(HERE, 'labextension', 'package.json')) as fid:
10+
data = json.load(fid)
11+
12+
def _jupyter_labextension_paths():
13+
return [{
14+
'src': 'labextension',
15+
'dest': data['name']
16+
}]
17+
18+
19+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version_info = (0, 1, 0)
2+
__version__ = ".".join(map(str, version_info))

advanced/kernel-messaging/package.json

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,55 @@
2525
"url": "https://github.com/jupyterlab/extension-examples.git"
2626
},
2727
"scripts": {
28-
"build": "tsc",
29-
"clean": "rimraf lib tsconfig.tsbuildinfo",
30-
"install-ext": "jupyter labextension install . --no-build",
31-
"prepare": "jlpm run clean && jlpm run build",
28+
"build": "jlpm run build:lib && jlpm run build:labextension:dev",
29+
"build:all": "jlpm run build:lib && jlpm run build:labextension",
30+
"build:labextension": "jupyter labextension build .",
31+
"build:labextension:dev": "jupyter labextension build --development True .",
32+
"build:lib": "tsc",
33+
"build:prod": "jlpm run build:lib && jlpm run build:labextension",
34+
"clean": "jlpm run clean:lib",
35+
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
36+
"clean:labextension": "rimraf jupyterlab_examples_kernel_messaging/labextension",
37+
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
3238
"eslint": "eslint . --ext .ts,.tsx --fix",
3339
"eslint:check": "eslint . --ext .ts,.tsx",
34-
"watch": "tsc -w"
40+
"install:extension": "jupyter labextension develop --overwrite .",
41+
"prepare": "jlpm run clean && jlpm run build:prod",
42+
"watch": "run-p watch:src watch:labextension",
43+
"watch:labextension": "jupyter labextension watch .",
44+
"watch:src": "tsc -w"
3545
},
3646
"dependencies": {
37-
"@jupyterlab/application": "^2.0.0",
38-
"@jupyterlab/launcher": "^2.0.0",
39-
"@jupyterlab/mainmenu": "^2.0.0",
40-
"@jupyterlab/nbformat": "^2.0.0",
41-
"@lumino/algorithm": "^1.2.3",
42-
"@lumino/coreutils": "^1.3.1",
47+
"@jupyterlab/application": "^3.0.0-rc.15",
48+
"@jupyterlab/launcher": "^3.0.0-rc.15",
49+
"@jupyterlab/mainmenu": "^3.0.0-rc.15",
50+
"@jupyterlab/nbformat": "^3.0.0-rc.15",
51+
"@jupyterlab/translation": "^3.0.0-rc.15",
52+
"@lumino/algorithm": "^1.3.3",
53+
"@lumino/coreutils": "^1.5.3",
4354
"@lumino/datagrid": "^0.5.2",
44-
"@lumino/disposable": "^1.3.1",
45-
"@lumino/widgets": "^1.11.0"
55+
"@lumino/disposable": "^1.4.3",
56+
"@lumino/widgets": "^1.16.1"
4657
},
4758
"devDependencies": {
48-
"@typescript-eslint/eslint-plugin": "^2.21.0",
49-
"@typescript-eslint/parser": "^2.21.0",
50-
"eslint": "^6.8.0",
51-
"eslint-config-prettier": "^6.10.0",
59+
"@jupyterlab/builder": "^3.0.0-rc.15",
60+
"@typescript-eslint/eslint-plugin": "^2.27.0",
61+
"@typescript-eslint/parser": "^2.27.0",
62+
"eslint": "^7.5.0",
63+
"eslint-config-prettier": "^6.10.1",
5264
"eslint-plugin-jsdoc": "^22.0.0",
5365
"eslint-plugin-prettier": "^3.1.2",
5466
"eslint-plugin-react": "^7.18.3",
55-
"rimraf": "^3.0.0",
56-
"typescript": "~3.7.5"
67+
"npm-run-all": "^4.1.5",
68+
"prettier": "^1.19.0",
69+
"rimraf": "^3.0.2",
70+
"typescript": "~4.1.3"
5771
},
5872
"sideEffects": [
5973
"style/*.css"
6074
],
6175
"jupyterlab": {
62-
"extension": true
76+
"extension": true,
77+
"outputDir": "jupyterlab_examples_kernel_messaging/labextension"
6378
}
64-
}
79+
}

0 commit comments

Comments
 (0)