Skip to content

Commit 60c1b9e

Browse files
committed
[WIP] update to modern JupyterLab
1 parent 54e1cc3 commit 60c1b9e

Some content is hidden

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

59 files changed

+6006
-5241
lines changed

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
dist
3+
coverage
4+
**/*.d.ts
5+
tests

.eslintrc.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
extends: [
3+
'eslint:recommended',
4+
'plugin:@typescript-eslint/eslint-recommended',
5+
'plugin:@typescript-eslint/recommended',
6+
'plugin:prettier/recommended'
7+
],
8+
parser: '@typescript-eslint/parser',
9+
parserOptions: {
10+
project: 'tsconfig.eslint.json',
11+
sourceType: 'module'
12+
},
13+
plugins: ['@typescript-eslint'],
14+
rules: {
15+
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
16+
'@typescript-eslint/no-explicit-any': 'off',
17+
'@typescript-eslint/no-namespace': 'off',
18+
'@typescript-eslint/no-use-before-define': 'off',
19+
'@typescript-eslint/quotes': [
20+
'error',
21+
'single',
22+
{ avoidEscape: true, allowTemplateLiterals: false }
23+
],
24+
curly: ['error', 'all'],
25+
eqeqeq: 'error',
26+
'prefer-arrow-callback': 'error'
27+
}
28+
};

.github/workflows/build.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: main
6+
pull_request:
7+
branches: "*"
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest, windows-latest, macos-latest]
16+
python-version: ["3.7", "3.10"]
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
21+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
22+
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install -U codecov
26+
npm install -g codecov
27+
- name: Test the extension
28+
run: |
29+
python -m pip install --upgrade -v -e ".[test, examples, docs]"
30+
python -m pytest
31+
yarn run test
32+
33+
- name: Linting
34+
if: ${{ matrix.os == 'ubuntu-latest' }}
35+
run: |
36+
yarn run lint:check
37+
38+
- name: Check docs can be build + links
39+
if: ${{ matrix.os == 'ubuntu-latest' }}
40+
working-directory: docs
41+
run: |
42+
sudo apt install -y pandoc
43+
make html
44+
python -m pytest --check-links

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ var/
2323
*.egg-info/
2424
.installed.cfg
2525
*.egg
26-
MANIFEST
2726

2827
# PyInstaller
2928
# Usually these files are written by a python script from a template
@@ -146,14 +145,11 @@ $RECYCLE.BIN/
146145
# ----
147146

148147
**/node_modules/
149-
ipymidicontrols/nbextension/static/index.*
150-
ipymidicontrols/labextension/*.tgz
148+
ipymidicontrols/nbextension/index.*
151149

152150
# Coverage data
153151
# -------------
154152
**/coverage/
155153

156154
# Packed lab extensions
157155
ipymidicontrols/labextension
158-
159-
tsconfig.tsbuildinfo

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
**/node_modules
3+
**/lib
4+
**/package.json

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

.travis.yml

Lines changed: 0 additions & 73 deletions
This file was deleted.

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2018 Project Jupyter Contributors
1+
Copyright (c) 2023 Project Jupyter Contributors
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without

MANIFEST.in

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
include LICENSE.txt
22
include README.md
33

4-
include setupbase.py
5-
# include pytest.ini
6-
# include .coveragerc
4+
include setup.py
5+
include pyproject.toml
6+
include pytest.ini
7+
include .coverage.rc
78

8-
# include package.json
9-
# include webpack.config.js
9+
include tsconfig.json
10+
include package.json
11+
include webpack.config.js
1012
include ipymidicontrols/labextension/*.tgz
1113

1214
# Documentation
@@ -20,12 +22,13 @@ prune docs/dist
2022
graft examples
2123

2224
# Tests
23-
# graft tests
24-
# prune tests/build
25+
graft tests
26+
prune tests/build
2527

2628
# Javascript files
2729
graft ipymidicontrols/nbextension
28-
# graft src
30+
graft src
31+
graft css
2932
prune **/node_modules
3033
prune coverage
3134
prune lib

README.md

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,69 @@ You can install using `pip`:
1515
pip install ipymidicontrols
1616
```
1717

18-
Or if you use jupyterlab:
18+
If you are using Jupyter Notebook 5.2 or earlier, you may also need to enable
19+
the nbextension:
20+
```bash
21+
jupyter nbextension enable --py [--sys-prefix|--user|--system] ipymidicontrols
22+
```
23+
24+
## Development Installation
1925

26+
Create a dev environment:
2027
```bash
21-
pip install ipymidicontrols
22-
jupyter labextension install @jupyter-widgets/jupyterlab-manager
28+
conda create -n ipymidicontrols-dev -c conda-forge nodejs yarn python jupyterlab
29+
conda activate ipymidicontrols-dev
2330
```
2431

25-
If you are using Jupyter Notebook 5.2 or earlier, you may also need to enable
26-
the nbextension:
32+
Install the python. This will also build the TS package.
2733
```bash
28-
jupyter nbextension enable --py [--sys-prefix|--user|--system] ipymidicontrols
34+
pip install -e ".[test, examples]"
2935
```
3036

31-
## Usage
37+
When developing your extensions, you need to manually enable your extensions with the
38+
notebook / lab frontend. For lab, this is done by the command:
3239

33-
Create a controller widget for a [Behringer XTouch Mini](https://www.musictribe.com/Categories/Behringer/Computer-Audio/Desktop-Controllers/X-TOUCH-MINI/p/P0B3M):
40+
```
41+
jupyter labextension develop --overwrite .
42+
yarn run build
43+
```
3444

35-
```python
36-
from ipymidicontrols import XTouchMini
37-
x = XTouchMini()
45+
For classic notebook, you need to run:
46+
47+
```
48+
jupyter nbextension install --sys-prefix --symlink --overwrite --py ipymidicontrols
49+
jupyter nbextension enable --sys-prefix --py ipymidicontrols
3850
```
3951

40-
See a simple widgets-based UI for the controls:
52+
Note that the `--symlink` flag doesn't work on Windows, so you will here have to run
53+
the `install` command every time that you rebuild your extension. For certain installations
54+
you might also need another flag instead of `--sys-prefix`, but we won't cover the meaning
55+
of those flags here.
56+
57+
### How to see your changes
58+
#### Typescript:
59+
If you use JupyterLab to develop then you can watch the source directory and run JupyterLab at the same time in different
60+
terminals to watch for changes in the extension's source and automatically rebuild the widget.
61+
62+
```bash
63+
# Watch the source directory in one terminal, automatically rebuilding when needed
64+
yarn run watch
65+
# Run JupyterLab in another terminal
66+
jupyter lab
67+
```
4168

42-
```python
43-
from ipymidicontrols import xtouchmini_ui
44-
xtouchmini_ui(x)
69+
After a change wait for the build to finish and then refresh your browser and the changes should take effect.
70+
71+
#### Python:
72+
If you make a change to the python code then you will need to restart the notebook kernel to have it take effect.
73+
74+
## Updating the version
75+
76+
To update the version, install tbump and use it to bump the version.
77+
By default it will also create a tag.
78+
79+
```bash
80+
pip install tbump
81+
tbump <new-version>
4582
```
4683

47-
![screenshot](https://raw.githubusercontent.com/jupyter-widgets/midicontrols/master/XTouchMini.png)

0 commit comments

Comments
 (0)