Skip to content

JupyterLab 3 update #272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Tests

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
run:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.7, 3.8]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup conda
uses: conda-incubator/setup-miniconda@v2
with:
mamba-version: "*"
channels: conda-forge

- name: Mamba install dependencies
shell: bash -l {0}
run: mamba install python=${{ matrix.python-version }} pip nodejs ipywidgets=7.6 jupyter jupyterlab=3 pillow numpy matplotlib flake8 pytest nbval

- name: Install ipympl
shell: bash -l {0}
run: pip install -e .

- name: Check installation files
shell: bash -l {0}
run: |
test -d $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-matplotlib
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-matplotlib/extension.js
test -f $CONDA_PREFIX/share/jupyter/nbextensions/jupyter-matplotlib/index.js
test -d $CONDA_PREFIX/share/jupyter/labextensions/jupyter-matplotlib
test -f $CONDA_PREFIX/share/jupyter/labextensions/jupyter-matplotlib/package.json

- name: Check nbextension and labextension
shell: bash -l {0}
run: |
jupyter nbextension list 2>&1 | grep -ie "jupyter-matplotlib/extension.*enabled" -
jupyter labextension list 2>&1 | grep -ie "jupyter-matplotlib.*enabled.*ok" -

- name: Run tests
shell: bash -l {0}
run: pytest .

- name: Test flake8
shell: bash -l {0}
run: flake8 ipympl --ignore=E501,W504,W503

- name: Test JS linters
shell: bash -l {0}
working-directory: js
run: |
npm run eslint:check
npm run prettier:check
43 changes: 0 additions & 43 deletions .github/workflows/reviewdog.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ build/
node_modules/

# Generated Javascript
ipympl/static/
ipympl/staticlab/
ipympl/nbextension/
ipympl/labextension/
ipympl/*.tgz
js/*.tgz

Expand Down
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

7 changes: 6 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
recursive-include ipympl/static *.*
recursive-include ipympl/nbextension *.*
recursive-include ipympl/labextension *.*

include js/*.tgz
include js/package.json
include LICENSE
include jupyter-matplotlib.json

include setup.py
include pyproject.toml
20 changes: 3 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,13 @@ conda install -c conda-forge ipympl
pip install ipympl
```

### Install the JupyterLab extension
### Use in JupyterLab

In order to install the JupyterLab extension `jupyter-matplotlib`, you will first need to install `nodejs` and `npm`.
You can install both with `conda` doing

```bash
conda install -c conda-forge nodejs
```

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:
```bash
jupyter labextension install @jupyter-widgets/jupyterlab-manager

# If you already installed the @jupyter-widgets/jupyterlab-manager extension, you will still need to rebuild JupyterLab after you installed ipympl
jupyter lab build
```
If you want to use ipympl in JupyterLab, we recommend using JupyterLab >= 3.

#### Install an old JupyterLab extension

You will need to install the right `jupyter-matplotlib` version, according to the `ipympl` and `jupyterlab` versions you installed.
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.
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`.

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

Versions lookup table:


| `ipympl` | `jupyter-matplotlib` | `JupyterLab` | `Matplotlib` |
|----------|----------------------|--------------|--------------|
| 0.5.8 | 0.7.4 | 1 or 2 | 3.3.1 |
Expand Down
9 changes: 8 additions & 1 deletion ipympl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
npm_pkg_name = 'jupyter-matplotlib'


def _jupyter_labextension_paths():
return [{
'src': 'labextension',
'dest': npm_pkg_name
}]


def _jupyter_nbextension_paths():
return [{
'section': 'notebook',
'src': 'static',
'src': 'nbextension',
'dest': npm_pkg_name,
'require': npm_pkg_name + '/extension'
}]
Expand Down
1 change: 1 addition & 0 deletions ipympl/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
version_info = (0, 5, 8)
__version__ = '.'.join(map(str, version_info))
js_semver = '^0.7.4'
9 changes: 3 additions & 6 deletions ipympl/backend_nbagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from base64 import b64encode
import json
import io
import os

from IPython.display import display, HTML

Expand All @@ -23,9 +22,7 @@
from matplotlib.backend_bases import (ShowBase, NavigationToolbar2,
FigureCanvasBase, cursors)

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

cursors_str = {
cursors.HAND: 'pointer',
Expand Down Expand Up @@ -84,8 +81,8 @@ def connection_info():
result = []
for manager in Gcf.get_all_fig_managers():
fig = manager.canvas.figure
result.append('{0} - {0}'.format((fig.get_label() or
"Figure {0}".format(manager.num)),
result.append('{0} - {1}'.format((fig.get_label() or
"Figure {}".format(manager.num)),
manager.web_sockets))
if not is_interactive():
result.append('Figures pending show: {0}'.format(len(Gcf._activeQue)))
Expand Down
Loading