Skip to content

Commit 47c24b4

Browse files
authored
Port to JupyterLab 3 (#8)
1 parent 8b47e1b commit 47c24b4

File tree

17 files changed

+2875
-714
lines changed

17 files changed

+2875
-714
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,23 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout
14-
uses: actions/checkout@v1
14+
uses: actions/checkout@v2
1515
- name: Install node
1616
uses: actions/setup-node@v1
1717
with:
1818
node-version: '10.x'
1919
- name: Install Python
20-
uses: actions/setup-python@v1
20+
uses: actions/setup-python@v2
2121
with:
2222
python-version: '3.7'
2323
architecture: 'x64'
2424
- name: Install dependencies
25-
run: python -m pip install "jupyterlab~=2.0"
25+
run: python -m pip install jupyterlab~=3.0
2626
- name: Build the extension
2727
run: |
2828
jlpm
2929
jlpm run eslint:check
30+
python -m pip install .
3031
31-
jupyter labextension install .
32-
jupyter labextension disable @jupyterlab/launcher-extension
33-
32+
jupyter labextension list 2>&1 | grep -ie "@jlab-enhanced/launcher.*OK"
3433
python -m jupyterlab.browser_check

.gitignore

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,109 @@ node_modules/
44
*.egg-info/
55
.ipynb_checkpoints
66
*.tsbuildinfo
7+
jlab_enhanced_launcher/labextension
8+
9+
# Created by https://www.gitignore.io/api/python
10+
# Edit at https://www.gitignore.io/?templates=python
11+
12+
### Python ###
13+
# Byte-compiled / optimized / DLL files
14+
__pycache__/
15+
*.py[cod]
16+
*$py.class
17+
18+
# C extensions
19+
*.so
20+
21+
# Distribution / packaging
22+
.Python
23+
build/
24+
develop-eggs/
25+
dist/
26+
downloads/
27+
eggs/
28+
.eggs/
29+
lib/
30+
lib64/
31+
parts/
32+
sdist/
33+
var/
34+
wheels/
35+
pip-wheel-metadata/
36+
share/python-wheels/
37+
.installed.cfg
38+
*.egg
39+
MANIFEST
40+
41+
# PyInstaller
42+
# Usually these files are written by a python script from a template
43+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
44+
*.manifest
45+
*.spec
46+
47+
# Installer logs
48+
pip-log.txt
49+
pip-delete-this-directory.txt
50+
51+
# Unit test / coverage reports
52+
htmlcov/
53+
.tox/
54+
.nox/
55+
.coverage
56+
.coverage.*
57+
.cache
58+
nosetests.xml
59+
coverage.xml
60+
*.cover
61+
.hypothesis/
62+
.pytest_cache/
63+
64+
# Translations
65+
*.mo
66+
*.pot
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# pyenv
78+
.python-version
79+
80+
# celery beat schedule file
81+
celerybeat-schedule
82+
83+
# SageMath parsed files
84+
*.sage.py
85+
86+
# Spyder project settings
87+
.spyderproject
88+
.spyproject
89+
90+
# Rope project settings
91+
.ropeproject
92+
93+
# Mr Developer
94+
.mr.developer.cfg
95+
.project
96+
.pydevproject
97+
98+
# mkdocs documentation
99+
/site
100+
101+
# mypy
102+
.mypy_cache/
103+
.dmypy.json
104+
dmypy.json
105+
106+
# Pyre type checker
107+
.pyre/
108+
109+
# End of https://www.gitignore.io/api/python
110+
111+
# OSX files
112+
.DS_Store

MANIFEST.in

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

README.md

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# @jlab-enhanced/launcher
1+
# jlab_enhanced_launcher
22

3-
![Github Actions Status](https://github.com/fcollonval/jlab-enhanced-launcher/workflows/Build/badge.svg) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/fcollonval/jlab-enhanced-launcher/master?urlpath=lab) [![npm](https://img.shields.io/npm/v/@jlab-enhanced/launcher)](https://www.npmjs.com/package/@jlab-enhanced/launcher)
3+
![Github Actions Status](https://github.com/fcollonval/jlab-enhanced-launcher/workflows/Build/badge.svg) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/fcollonval/jlab-enhanced-launcher.git/master?urlpath=lab) [![npm](https://img.shields.io/npm/v/@jlab-enhanced/launcher)](https://www.npmjs.com/package/@jlab-enhanced/launcher)
44

55
A enhanced launcher for JupyterLab.
66

@@ -10,54 +10,66 @@ This codes started from https://github.com/jupyterlab/jupyterlab/pull/5953.
1010

1111
## Requirements
1212

13-
* JupyterLab >= 2.0
13+
- JupyterLab >= 3.0
1414

1515
## Install
1616

1717
```bash
18-
jupyter labextension install @jlab-enhanced/launcher
19-
jupyter labextension disable @jupyterlab/launcher-extension
18+
pip install jlab-enhanced-launcher
2019
```
2120

22-
## Uninstall
21+
or
2322

2423
```bash
25-
jupyter labextension uninstall @jlab-enhanced/launcher
26-
jupyter labextension enable @jupyterlab/launcher-extension
24+
conda install jlab-enhanced-launcher
25+
```
26+
27+
### Uninstall
28+
29+
```bash
30+
pip uninstall jlab-enhanced-launcher
31+
```
32+
33+
or
34+
35+
```bash
36+
conda remove jlab-enhanced-launcher
2737
```
2838

2939
## Contributing
3040

31-
### Development Install
41+
### Development install
42+
43+
Note: You will need NodeJS to build the extension package.
3244

3345
The `jlpm` command is JupyterLab's pinned version of
3446
[yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
3547
`yarn` or `npm` in lieu of `jlpm` below.
3648

3749
```bash
3850
# Clone the repo to your local environment
39-
# Move to launcher directory
40-
41-
# Install dependencies
42-
jlpm
43-
# Build Typescript source
44-
jlpm build
51+
# Change directory to the jlab_enhanced_launcher directory
52+
# Install package in development mode
53+
pip install -e .
4554
# Link your development version of the extension with JupyterLab
46-
jupyter labextension install .
47-
jupyter labextension disable @jupyterlab/launcher-extension
48-
# Rebuild Typescript source after making changes
49-
jlpm build
50-
# Rebuild JupyterLab after making any changes
51-
jupyter lab build
55+
jupyter labextension develop . --overwrite
56+
# Rebuild extension Typescript source after making changes
57+
jlpm run build
5258
```
5359

54-
You can watch the source directory and run JupyterLab in watch mode to watch for changes in the extension's source and automatically rebuild the extension and application.
60+
You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.
5561

5662
```bash
57-
# Watch the source directory in another terminal tab
58-
jlpm watch
59-
# Run jupyterlab in watch mode in one terminal tab
60-
jupyter lab --watch
63+
# Watch the source directory in one terminal, automatically rebuilding when needed
64+
jlpm run watch
65+
# Run JupyterLab in another terminal
66+
jupyter lab
6167
```
6268

63-
Now every change will be built locally and bundled into JupyterLab. Be sure to refresh your browser page after saving file changes to reload the extension (note: you'll need to wait for webpack to finish, which can take 10s+ at times).
69+
With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).
70+
71+
By default, the `jlpm run build` command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:
72+
73+
```bash
74+
jupyter lab build --minimize=False
75+
```

binder/environment.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
# a mybinder.org-ready environment for demoing launcher
1+
# a mybinder.org-ready environment for demoing jlab_enhanced_launcher
22
# this environment may also be used locally on Linux/MacOS/Windows, e.g.
33
#
44
# conda env update --file binder/environment.yml
5-
# conda activate launcher-demo
5+
# conda activate jlab-enhanced-launcher-demo
66
#
7-
name: launcher-demo
7+
name: jlab-enhanced-launcher-demo
88

99
channels:
1010
- conda-forge
1111

1212
dependencies:
1313
# runtime dependencies
1414
- python >=3.8,<3.9.0a0
15-
- jupyterlab >=2,<3.0.0a0
15+
- jupyterlab >=3,<4.0.0a0
1616
# labextension build dependencies
1717
- nodejs >=14,<15
18+
- pip
19+
- wheel
20+
# Fix binder
21+
- parso >=0.8.0,<0.9.0
22+
- jupyter_telemetry >=0.1.0

binder/postBuild

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,44 @@
1-
#!/bin/bash
2-
set -e
3-
jlpm
1+
#!/usr/bin/env python3
2+
""" perform a development install of jlab_enhanced_launcher
43
5-
# initially list installed extensions to determine if there are any surprises
6-
jupyter labextension list
4+
On Binder, this will run _after_ the environment has been fully created from
5+
the environment.yml in this directory.
6+
7+
This script should also run locally on Linux/MacOS/Windows:
8+
9+
python3 binder/postBuild
10+
"""
11+
import subprocess
12+
import sys
13+
from pathlib import Path
14+
15+
16+
ROOT = Path.cwd()
17+
18+
def _(*args, **kwargs):
19+
""" Run a command, echoing the args
20+
21+
fails hard if something goes wrong
22+
"""
23+
print("\n\t", " ".join(args), "\n")
24+
return_code = subprocess.call(args, **kwargs)
25+
if return_code != 0:
26+
print("\nERROR", return_code, " ".join(args))
27+
sys.exit(return_code)
28+
29+
# verify the environment is self-consistent before even starting
30+
_(sys.executable, "-m", "pip", "check")
731

832
# install the labextension
9-
jlpm pack
10-
jupyter labextension install --no-build jlab-enhanced-launcher-*.tgz
11-
jupyter labextension disable @jupyterlab/launcher-extension
33+
_(sys.executable, "-m", "pip", "install", "-e", ".")
34+
_("jupyter", "labextension", "disable", "@jupyterlab/launcher-extension")
1235

13-
# verify the list of extensions
14-
jupyter labextension list
36+
# verify the environment the extension didn't break anything
37+
_(sys.executable, "-m", "pip", "check")
38+
39+
# initially list installed extensions to determine if there are any surprises
40+
_("jupyter", "labextension", "list")
1541

16-
jupyter lab build --dev-build=False --minimize=True --debug
1742

18-
# verify the list of extensions one last time
19-
jupyter labextension list
43+
print("JupyterLab with jlab_enhanced_launcher is ready to run with:\n")
44+
print("\tjupyter lab\n")

install.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"packageManager": "python",
3+
"packageName": "jlab_enhanced_launcher",
4+
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jlab_enhanced_launcher"
5+
}

jlab_enhanced_launcher/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
import json
3+
import pathlib
4+
5+
from ._version import __version__
6+
7+
HERE = pathlib.Path(__file__).parent.absolute()
8+
9+
with (HERE / 'labextension' / 'package.json').open() 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+

jlab_enhanced_launcher/_version.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
__all__ = ['__version__']
2+
3+
def _fetchVersion():
4+
import json
5+
import pathlib
6+
7+
HERE = pathlib.Path(__file__).parent.absolute()
8+
9+
for d in HERE.rglob('package.json'):
10+
try:
11+
with d.open() as f:
12+
return json.load(f)['version']
13+
except FileNotFoundError:
14+
pass
15+
16+
raise FileNotFoundError('Could not find package.json under dir {}'.format(HERE))
17+
18+
__version__ = _fetchVersion()

0 commit comments

Comments
 (0)