Skip to content

Commit 17c0bfa

Browse files
authored
Merge pull request #272 from martinRenou/clean_setup
JupyterLab 3 update
2 parents bd477f5 + e31db70 commit 17c0bfa

15 files changed

+11085
-393
lines changed

.github/workflows/main.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
run:
13+
runs-on: ${{ matrix.os }}
14+
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest, macos-latest]
19+
python-version: [3.7, 3.8]
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v2
24+
25+
- name: Setup conda
26+
uses: conda-incubator/setup-miniconda@v2
27+
with:
28+
mamba-version: "*"
29+
channels: conda-forge
30+
31+
- name: Mamba install dependencies
32+
shell: bash -l {0}
33+
run: mamba install python=${{ matrix.python-version }} pip nodejs ipywidgets=7.6 jupyter jupyterlab=3 pillow numpy matplotlib flake8 pytest nbval
34+
35+
- name: Install ipympl
36+
shell: bash -l {0}
37+
run: pip install -e .
38+
39+
- name: Check installation files
40+
shell: bash -l {0}
41+
run: |
42+
test -d $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-matplotlib
43+
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-matplotlib/extension.js
44+
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-matplotlib/index.js
45+
test -d $CONDA_PREFIX/share/jupyter/labextensions/jupyter-matplotlib
46+
test -f $CONDA_PREFIX/share/jupyter/labextensions/jupyter-matplotlib/package.json
47+
48+
- name: Check nbextension and labextension
49+
shell: bash -l {0}
50+
run: |
51+
jupyter nbextension list 2>&1 | grep -ie "jupyter-matplotlib/extension.*enabled" -
52+
jupyter labextension list 2>&1 | grep -ie "jupyter-matplotlib.*enabled.*ok" -
53+
54+
- name: Run tests
55+
shell: bash -l {0}
56+
run: pytest .
57+
58+
- name: Test flake8
59+
shell: bash -l {0}
60+
run: flake8 ipympl --ignore=E501,W504,W503
61+
62+
- name: Test JS linters
63+
shell: bash -l {0}
64+
working-directory: js
65+
run: |
66+
npm run eslint:check
67+
npm run prettier:check

.github/workflows/reviewdog.yml

-43
This file was deleted.

.gitignore

+2-2
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

-32
This file was deleted.

MANIFEST.in

+6-1
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

+3-17
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

+8-1
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

+1
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

+3-6
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)