Skip to content

Commit acef3bc

Browse files
committed
JupyterLab 3 update
Signed-off-by: martinRenou <[email protected]>
1 parent bd477f5 commit acef3bc

File tree

14 files changed

+11045
-348
lines changed

14 files changed

+11045
-348
lines changed

.github/workflows/reviewdog.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,7 @@ jobs:
2929
- name: Install flake8
3030
run: pip3 install flake8
3131

32-
- name: Set up reviewdog
33-
run: |
34-
mkdir -p $HOME/bin
35-
curl -sfL \
36-
https://github.com/reviewdog/reviewdog/raw/master/install.sh | \
37-
sh -s -- -b $HOME/bin
38-
echo ::add-path::$HOME/bin
39-
4032
- name: Run flake8
4133
env:
4234
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43-
run: flake8 | reviewdog -f=pep8 -name=flake8 -reporter=github-check
35+
run: flake8 ipympl

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ build/
66
node_modules/
77

88
# Generated Javascript
9-
ipympl/static/
10-
ipympl/staticlab/
9+
ipympl/nbextension/
10+
ipympl/labextension/
1111
ipympl/*.tgz
1212
js/*.tgz
1313

.travis.yml

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,31 @@ cache:
77
directories:
88
- $HOME/.npm
99
before_install:
10-
- wget https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux64.tar.gz
11-
- mkdir geckodriver
12-
- tar -xzf geckodriver-v0.11.1-linux64.tar.gz -C geckodriver
13-
- export PATH=$PATH:$PWD/geckodriver
14-
- export DISPLAY=:99.0
15-
- sh -e /etc/init.d/xvfb start || true
10+
- wget https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux64.tar.gz
11+
- mkdir geckodriver
12+
- tar -xzf geckodriver-v0.11.1-linux64.tar.gz -C geckodriver
13+
- export PATH=$PATH:$PWD/geckodriver
14+
- export DISPLAY=:99.0
15+
- sh -e /etc/init.d/xvfb start || true
1616
install:
17-
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
18-
- bash miniconda.sh -b -p $HOME/miniconda
19-
- export PATH="$HOME/miniconda/bin:$PATH"
20-
- hash -r
21-
- conda config --set always_yes yes --set changeps1 no
22-
- conda update -q conda
23-
- conda info -a
24-
- conda install -c conda-forge nodejs=13 notebook matplotlib ipywidgets jupyterlab
25-
- pip install -v .
17+
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
18+
- bash miniconda.sh -b -p $HOME/miniconda
19+
- export PATH="$HOME/miniconda/bin:$PATH"
20+
- hash -r
21+
- conda config --set always_yes yes --set changeps1 no
22+
- conda update -q conda
23+
- conda info -a
24+
- conda install -c conda-forge mamba
25+
- mamba install -c conda-forge nodejs=13 matplotlib pytest nbval
26+
- pip install pytest-tornasync --no-deps
27+
- mamba install jupyterlab=3 ipywidgets=7.6 -c conda-forge
28+
- pip install .
2629
script:
27-
- jupyter nbextension install --py --symlink --sys-prefix ipympl
28-
- jupyter nbextension enable --py --sys-prefix ipympl
29-
- jupyter labextension list 2>&1 | grep -q jupyter-matplotlib
30-
- jupyter labextension install @jupyter-widgets/jupyterlab-manager
31-
- jupyter labextension link js
32-
- python -m jupyterlab.browser_check --NotebookApp.ip=127.0.0.1
30+
- pytest
31+
- test -d $HOME/miniconda/share/jupyter/nbextensions/jupyter-matplotlib
32+
- test -f $HOME/miniconda/share/jupyter/nbextensions/jupyter-matplotlib/extension.js
33+
- test -f $HOME/miniconda/share/jupyter/nbextensions/jupyter-matplotlib/index.js
34+
- test -d $HOME/miniconda/share/jupyter/labextensions/jupyter-matplotlib
35+
- test -f $HOME/miniconda/share/jupyter/labextensions/jupyter-matplotlib/package.json
36+
- jupyter labextension list 2>&1 | grep -q jupyter-matplotlib
37+
- python -m jupyterlab.browser_check --NotebookApp.ip=127.0.0.1

MANIFEST.in

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
recursive-include ipympl/static *.*
1+
recursive-include ipympl/nbextension *.*
2+
recursive-include ipympl/labextension *.*
3+
24
include js/*.tgz
35
include js/package.json
46
include LICENSE
57
include jupyter-matplotlib.json
8+
9+
include setup.py
10+
include pyproject.toml

README.md

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,13 @@ conda install -c conda-forge ipympl
3939
pip install ipympl
4040
```
4141

42-
### Install the JupyterLab extension
42+
### Use in JupyterLab
4343

44-
In order to install the JupyterLab extension `jupyter-matplotlib`, you will first need to install `nodejs` and `npm`.
45-
You can install both with `conda` doing
46-
47-
```bash
48-
conda install -c conda-forge nodejs
49-
```
50-
51-
Starting from ipympl `0.5.6`, **you do not need to manually install the JupyterLab extension**, but you still need to install the JupyterLab widget manager:
52-
```bash
53-
jupyter labextension install @jupyter-widgets/jupyterlab-manager
54-
55-
# If you already installed the @jupyter-widgets/jupyterlab-manager extension, you will still need to rebuild JupyterLab after you installed ipympl
56-
jupyter lab build
57-
```
44+
If you want to use ipympl in JupyterLab, we recommend using JupyterLab >= 3.
5845

5946
#### Install an old JupyterLab extension
6047

61-
You will need to install the right `jupyter-matplotlib` version, according to the `ipympl` and `jupyterlab` versions you installed.
48+
If you are using JupyterLab 1 or 2, you will need to install the right `jupyter-matplotlib` version, according to the `ipympl` and `jupyterlab` versions you installed.
6249
For example, if you installed ipympl `0.5.1`, you need to install jupyter-matplotlib `0.7.0`, and this version is only compatible with JupyterLab `1`.
6350

6451
```bash
@@ -68,7 +55,6 @@ jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-matplot
6855

6956
Versions lookup table:
7057

71-
7258
| `ipympl` | `jupyter-matplotlib` | `JupyterLab` | `Matplotlib` |
7359
|----------|----------------------|--------------|--------------|
7460
| 0.5.8 | 0.7.4 | 1 or 2 | 3.3.1 |

ipympl/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@
44
npm_pkg_name = 'jupyter-matplotlib'
55

66

7+
def _jupyter_labextension_paths():
8+
return [{
9+
'src': 'labextension',
10+
'dest': npm_pkg_name
11+
}]
12+
13+
714
def _jupyter_nbextension_paths():
815
return [{
916
'section': 'notebook',
10-
'src': 'static',
17+
'src': 'nbextension',
1118
'dest': npm_pkg_name,
1219
'require': npm_pkg_name + '/extension'
1320
}]

ipympl/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
version_info = (0, 5, 8)
22
__version__ = '.'.join(map(str, version_info))
3+
js_semver = '^0.7.4'

ipympl/backend_nbagg.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from base64 import b64encode
44
import json
55
import io
6-
import os
76

87
from IPython.display import display, HTML
98

@@ -23,9 +22,7 @@
2322
from matplotlib.backend_bases import (ShowBase, NavigationToolbar2,
2423
FigureCanvasBase, cursors)
2524

26-
here = os.path.dirname(__file__)
27-
with open(os.path.join(here, 'static', 'package.json')) as fid:
28-
js_semver = '^%s' % json.load(fid)['version']
25+
from ._version import js_semver
2926

3027
cursors_str = {
3128
cursors.HAND: 'pointer',
@@ -84,8 +81,8 @@ def connection_info():
8481
result = []
8582
for manager in Gcf.get_all_fig_managers():
8683
fig = manager.canvas.figure
87-
result.append('{0} - {0}'.format((fig.get_label() or
88-
"Figure {0}".format(manager.num)),
84+
result.append('{0} - {1}'.format((fig.get_label() or
85+
"Figure {}".format(manager.num)),
8986
manager.web_sockets))
9087
if not is_interactive():
9188
result.append('Figures pending show: {0}'.format(len(Gcf._activeQue)))

0 commit comments

Comments
 (0)