Skip to content

Update for JupyterLab 3 #2973

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 19 commits into from
Sep 18, 2020
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
59 changes: 59 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build jupyterlab_widgets

on:
push:
branches: master
pull_request:
branches: '*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install node
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install Python
uses: actions/setup-python@v1
with:
python-version: '3.8'
architecture: 'x64'
- name: Cache pip on Linux
uses: actions/cache@v1
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache yarn
uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: |
python -m pip install --pre jupyterlab==3.0.0b7
python -m pip install jupyter_packaging
- name: Build the extension
run: |
pip install .
jlpm install
jlpm run build
cd jupyterlab_widgets
pwd
pip install -e .
jupyter labextension develop . --overwrite
jupyter labextension list

python -m jupyterlab.browser_check
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ language: python
dist: xenial
python:
- 2.7
- 3.4
- 3.5
- 3.6
- 3.7
- 3.8
Expand Down
2 changes: 1 addition & 1 deletion docs/source/dev_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ conda deactivate
conda remove --all -y -n releasewidgets
rm -rf ipywidgets

conda create -c conda-forge --override-channels -y -n releasewidgets notebook nodejs twine
conda create -c conda-forge --override-channels -y -n releasewidgets jupyter_packaging notebook nodejs twine
conda activate releasewidgets

git clone git@github.com:jupyter-widgets/ipywidgets.git
Expand Down
2 changes: 1 addition & 1 deletion examples/web1/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
},
module: {
rules: [
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.css$/, use: ['style-loader', 'css-loader']},
// jquery-ui loads some images
{ test: /\.(jpg|png|gif)$/, use: 'file-loader' },
]
Expand Down
2 changes: 1 addition & 1 deletion examples/web2/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
},
module: {
rules: [
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.css$/, use: ['style-loader', 'css-loader']},
{ test: /\.py$/, loader: "raw-loader" },
// jquery-ui loads some images
{ test: /\.(jpg|png|gif)$/, use: 'file-loader' },
Expand Down
2 changes: 1 addition & 1 deletion examples/web3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@jupyter-widgets/base": "^3.0.0",
"@jupyter-widgets/controls": "^2.0.0",
"@jupyter-widgets/html-manager": "^0.19.0",
"@jupyterlab/services": "^5.0.0-rc.0",
"@jupyterlab/services": "^6.0.0-beta.7",
"@lumino/widgets": "^1.3.0",
"codemirror": "^5.48.0",
"font-awesome": "^4.7.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/web4/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
},
module: {
rules: [
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.css$/, use: ['style-loader', 'css-loader']},
// jquery-ui loads some images
{ test: /\.(jpg|png|gif)$/, use: 'file-loader' },
// required to load font-awesome
Expand Down
12 changes: 12 additions & 0 deletions jupyterlab_widgets/.cookiecutter_replay
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"cookiecutter": {
"author_name": "Jupyter Development Team",
"python_name": "jupyterlab_widgets",
"labextension_name": "@jupyter-widgets/jupyterlab-manager",
"project_short_description": "A JupyterLab extension.",
"has_server_extension": "n",
"has_binder": "n",
"repository": "https://github.com/jupyter-widgets/ipywidgets",
"_template": "https://github.com/jupyterlab/extension-cookiecutter-ts"
}
}
5 changes: 5 additions & 0 deletions jupyterlab_widgets/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
coverage
**/*.d.ts
tests
32 changes: 32 additions & 0 deletions jupyterlab_widgets/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/interface-name-prefix': [
'error',
{ prefixWithI: 'always' }
],
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/quotes': [
'error',
'single',
{ avoidEscape: true, allowTemplateLiterals: false }
],
curly: ['error', 'all'],
eqeqeq: 'error',
'prefer-arrow-callback': 'error'
}
};
6 changes: 6 additions & 0 deletions jupyterlab_widgets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.bundle.*
lib/
node_modules/
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo
4 changes: 4 additions & 0 deletions jupyterlab_widgets/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
**/node_modules
**/lib
**/package.json
3 changes: 3 additions & 0 deletions jupyterlab_widgets/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
21 changes: 21 additions & 0 deletions jupyterlab_widgets/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
include LICENSE
include README.md
include pyproject.toml

include package.json
include ts*.json

graft jupyterlab_widgets/static

# Javascript files
graft src
graft style
prune **/node_modules
prune lib

# Patterns to exclude from any directory
global-exclude *~
global-exclude *.pyc
global-exclude *.pyo
global-exclude .git
global-exclude .ipynb_checkpoints
80 changes: 80 additions & 0 deletions jupyterlab_widgets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
Jupyter Widgets JupyterLab Extension
====================================

![Github Actions Status](https://github.com/jupyter-widgets/ipywidgets/workflows/Build/badge.svg)

A JupyterLab extension for Jupyter/IPython widgets.

Package Install
---------------



## Requirements

* JupyterLab >= 3.0

## Install

```bash
pip install jupyterlab_widgets
```


### Version compatibility

Prior to JupyterLab 3.0, use the appropriate command from the following list
to install a compatible JupyterLab extension.

* For JupyterLab 0.30, use `jupyter labextension install @jupyter-widgets/jupyterlab-manager@0.31`
* For JupyterLab 0.31rc1, use `jupyter labextension install @jupyter-widgets/jupyterlab-manager@0.32`
* For JupyterLab 0.31rc2, use `jupyter labextension install @jupyter-widgets/jupyterlab-manager@0.33`
* For JupyterLab 0.31.x, use `jupyter labextension install @jupyter-widgets/jupyterlab-manager@0.34`
* For JupyterLab 0.32.x, use `jupyter labextension install @jupyter-widgets/jupyterlab-manager@0.35`
* For JupyterLab 0.33.x, use `jupyter labextension install @jupyter-widgets/jupyterlab-manager@0.36`
* For JupyterLab 0.34.x, use `jupyter labextension install @jupyter-widgets/jupyterlab-manager@0.37`
* For JupyterLab 0.35.x, use `jupyter labextension install @jupyter-widgets/jupyterlab-manager@0.38`
* For JupyterLab 1.0.x and 1.1.x, use `jupyter labextension install @jupyter-widgets/jupyterlab-manager@1.0`
* For JupyterLab 1.2.x, use `jupyter labextension install @jupyter-widgets/jupyterlab-manager@1.1`
* For JupyterLab 2.x, use `jupyter labextension install @jupyter-widgets/jupyterlab-manager@2`



## Contributing

### Development install

Note: You will need NodeJS to build the extension package.

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

```bash
# Clone the repo to your local environment
# Change directory to the jupyterlab_widgets directory
# Install package in development mode
pip install -e .
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Rebuild extension Typescript source after making changes
jlpm run build
```

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.

```bash
# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm run watch
# Run JupyterLab in another terminal
jupyter lab
```

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).

### Uninstall

```bash
pip uninstall jupyterlab_widgets
jupyter labextension uninstall @jupyter-widgets/jupyterlab-manager
```
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ dist
build
docs
example/*.js
static/
19 changes: 19 additions & 0 deletions jupyterlab_widgets/jupyterlab_widgets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

import json
import os.path as osp

from ._version import __version__

HERE = osp.abspath(osp.dirname(__file__))

with open(osp.join(HERE, 'static', 'package.json')) as fid:
data = json.load(fid)

def _jupyter_labextension_paths():
return [{
'src': 'static',
'dest': data['name']
}]



6 changes: 6 additions & 0 deletions jupyterlab_widgets/jupyterlab_widgets/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version_info = (1, 0, 0, 'alpha', 1)

_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}

__version__ = '%s.%s.%s%s'%(version_info[0], version_info[1], version_info[2],
'' if version_info[3]=='final' else _specifier_[version_info[3]]+str(version_info[4]))
Loading