Skip to content

Commit e9632d0

Browse files
authored
Merge pull request #14 from osscar-org/ipywidgets8.x
use the new template for ipywidgets v8.x
2 parents 1529380 + ab2b3bd commit e9632d0

File tree

14 files changed

+152
-184
lines changed

14 files changed

+152
-184
lines changed

.eslintrc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@ module.exports = {
1515
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
1616
'@typescript-eslint/no-explicit-any': 'off',
1717
'@typescript-eslint/no-namespace': 'off',
18+
'prefer-rest-params': 'off',
1819
'@typescript-eslint/no-use-before-define': 'off',
1920
'@typescript-eslint/quotes': [
2021
'error',
2122
'single',
2223
{ avoidEscape: true, allowTemplateLiterals: false }
2324
],
25+
'@typescript-eslint/no-this-alias': [
26+
'error',
27+
{ "allowDestructuring": true, "allowedNames": ["_this"] }
28+
],
2429
curly: ['error', 'all'],
2530
eqeqeq: 'error',
2631
'prefer-arrow-callback': 'error'
2732
}
28-
};
33+
};

css/widget.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.custom-widget {
2-
background-color: blue;
2+
background-color: lightseagreen;
3+
padding: 0px 2px;
34
}

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
#
8989
# This is also used if you do content translation via gettext catalogs.
9090
# Usually you set "language" from the command line for these cases.
91-
language = None
91+
language = "en"
9292

9393
# List of patterns, relative to source directory, that match files and
9494
# directories to ignore when looking for source files.
@@ -175,7 +175,7 @@
175175
'widget_code_input Documentation',
176176
author,
177177
'widget_code_input',
178-
'A Jupyter widget to allow input of a python function, with syntax highlighting.',
178+
'A widget to allow input of a python function, with syntax highlighting.',
179179
'Miscellaneous'),
180180
]
181181

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ widget_code_input
44

55
Version: |release|
66

7-
A Jupyter widget to allow input of a python function, with syntax highlighting.
7+
A widget to allow input of a python function, with syntax highlighting.
88

99

1010
Quickstart

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "widget-code-input",
3-
"version": "3.0.0",
4-
"description": "A Jupyter widget to allow input of a python function, with syntax highlighting.",
3+
"version": "3.5.0",
4+
"description": "A widget to allow input of a python function, with syntax highlighting.",
55
"keywords": [
66
"jupyter",
77
"jupyterlab",
@@ -19,7 +19,7 @@
1919
},
2020
"license": "BSD-3-Clause",
2121
"author": {
22-
"name": "Dou Du",
22+
"name": "Dou Du and Giovanni Pizzi",
2323
"email": "[email protected]"
2424
},
2525
"main": "lib/index.js",
@@ -49,15 +49,16 @@
4949
"watch:labextension": "jupyter labextension watch ."
5050
},
5151
"dependencies": {
52-
"@jupyter-widgets/base": "^1.1.10 || ^2.0.0 || ^3.0.0 || ^4.0.0",
53-
"codemirror": "5.58.2"
52+
"@jupyter-widgets/base": "^1.1.10 || ^2 || ^3 || ^4 || ^5 || ^6",
53+
"codemirror": "5.65.9"
5454
},
5555
"devDependencies": {
5656
"@babel/core": "^7.5.0",
5757
"@babel/preset-env": "^7.5.0",
58+
"@jupyter-widgets/base-manager": "^1.0.2",
5859
"@jupyterlab/builder": "^3.0.0",
59-
"@phosphor/application": "^1.6.0",
60-
"@phosphor/widgets": "^1.6.0",
60+
"@lumino/application": "^1.6.0",
61+
"@lumino/widgets": "^1.6.0",
6162
"@types/jest": "^26.0.0",
6263
"@types/webpack-env": "^1.13.6",
6364
"@typescript-eslint/eslint-plugin": "^3.6.0",
@@ -79,7 +80,7 @@
7980
"ts-jest": "^26.0.0",
8081
"ts-loader": "^8.0.0",
8182
"typescript": "~4.1.3",
82-
"webpack": "^5.0.0",
83+
"webpack": "^5.61.0",
8384
"webpack-cli": "^4.0.0",
8485
"underscore": "^1.13.2",
8586
"@types/codemirror": "^0.0.76"

pyproject.toml

Lines changed: 111 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,112 @@
11
[build-system]
2-
requires = ["jupyter_packaging==0.7.9", "jupyterlab==3.*", "setuptools>=40.8.0", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = [
3+
"hatchling>=1.3.1",
4+
"jupyterlab==3.*",
5+
]
6+
build-backend = "hatchling.build"
7+
8+
[project]
9+
name = "widget_code_input"
10+
description = "A widget to allow input of a python function, with syntax highlighting."
11+
readme = "README.md"
12+
license = { file = "LICENSE.txt" }
13+
requires-python = ">=3.7"
14+
authors = [
15+
{ name = "Dou Du", email = "[email protected]" },
16+
]
17+
keywords = [
18+
"IPython",
19+
"Jupyter",
20+
"Widgets",
21+
]
22+
classifiers = [
23+
"Framework :: Jupyter",
24+
"Intended Audience :: Developers",
25+
"Intended Audience :: Science/Research",
26+
"License :: OSI Approved :: BSD License",
27+
"Programming Language :: Python",
28+
"Programming Language :: Python :: 3",
29+
"Programming Language :: Python :: 3.7",
30+
"Programming Language :: Python :: 3.8",
31+
"Programming Language :: Python :: 3.9",
32+
"Programming Language :: Python :: 3.10",
33+
]
34+
dependencies = [
35+
"ipywidgets>=7.0.0",
36+
]
37+
version = "0.1.0.dev0"
38+
39+
[project.optional-dependencies]
40+
docs = [
41+
"jupyter_sphinx",
42+
"nbsphinx",
43+
"nbsphinx-link",
44+
"pypandoc",
45+
"pytest_check_links",
46+
"recommonmark",
47+
"sphinx>=1.5",
48+
"sphinx_rtd_theme",
49+
]
50+
examples = []
51+
test = [
52+
"nbval",
53+
"pytest-cov",
54+
"pytest>=6.0",
55+
]
56+
57+
[project.urls]
58+
Homepage = "https://github.com/osscar-org/widget-code-input"
59+
60+
[tool.hatch.build]
61+
artifacts = [
62+
"widget_code_input/nbextension/index.*",
63+
"widget_code_input/labextension/*.tgz",
64+
"widget_code_input/labextension",
65+
]
66+
67+
[tool.hatch.build.targets.wheel.shared-data]
68+
"widget_code_input/nbextension" = "share/jupyter/nbextensions/widget_code_input"
69+
"widget_code_input/labextension" = "share/jupyter/labextensions/widget_code_input"
70+
"./install.json" = "share/jupyter/labextensions/widget_code_input/install.json"
71+
"./widget_code_input.json" = "etc/jupyter/nbconfig/notebook.d/widget_code_input.json"
72+
73+
[tool.hatch.build.targets.sdist]
74+
exclude = [
75+
".github",
76+
]
77+
78+
[tool.hatch.build.hooks.jupyter-builder]
79+
build-function = "hatch_jupyter_builder.npm_builder"
80+
ensured-targets = [
81+
"widget_code_input/nbextension/index.js",
82+
"widget_code_input/labextension/package.json",
83+
]
84+
skip-if-exists = [
85+
"widget_code_input/nbextension/index.js",
86+
"widget_code_input/labextension/package.json",
87+
]
88+
dependencies = [
89+
"hatch-jupyter-builder>=0.5.0",
90+
]
91+
92+
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
93+
path = "."
94+
build_cmd = "build:prod"
95+
96+
[tool.tbump]
97+
field = [
98+
{ name = "channel", default = "" },
99+
{ name = "release", default = "" },
100+
]
101+
file = [
102+
{ src = "pyproject.toml", version_template = "version = \"{major}.{minor}.{patch}{channel}{release}\"" },
103+
{ src = "widget_code_input/_version.py" },
104+
]
105+
106+
[tool.tbump.version]
107+
current = "0.1.0.dev0"
108+
regex = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)((?P<channel>a|b|rc|.dev)(?P<release>\\d+))?"
109+
110+
[tool.tbump.git]
111+
message_template = "Bump to {new_version}"
112+
tag_template = "v{new_version}"

setup.py

Lines changed: 2 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,2 @@
1-
#!/usr/bin/env python
2-
# coding: utf-8
3-
4-
# Copyright (c) Jupyter Development Team.
5-
# Distributed under the terms of the Modified BSD License.
6-
7-
from __future__ import print_function
8-
from glob import glob
9-
import os
10-
from os.path import join as pjoin
11-
from setuptools import setup, find_packages
12-
13-
14-
from jupyter_packaging import (
15-
create_cmdclass,
16-
install_npm,
17-
ensure_targets,
18-
combine_commands,
19-
get_version,
20-
skip_if_exists
21-
)
22-
23-
HERE = os.path.dirname(os.path.abspath(__file__))
24-
25-
26-
27-
28-
# The name of the project
29-
name = 'widget_code_input'
30-
31-
# Get the version
32-
version = get_version(pjoin(name, '_version.py'))
33-
34-
35-
# Representative files that should exist after a successful build
36-
jstargets = [
37-
pjoin(HERE, name, 'nbextension', 'index.js'),
38-
pjoin(HERE, name, 'labextension', 'package.json'),
39-
]
40-
41-
42-
package_data_spec = {
43-
name: [
44-
'nbextension/**js*',
45-
'labextension/**'
46-
]
47-
}
48-
49-
50-
data_files_spec = [
51-
('share/jupyter/nbextensions/widget_code_input', 'widget_code_input/nbextension', '**'),
52-
('share/jupyter/labextensions/widget-code-input', 'widget_code_input/labextension', '**'),
53-
('share/jupyter/labextensions/widget-code-input', '.', 'install.json'),
54-
('etc/jupyter/nbconfig/notebook.d', '.', 'widget_code_input.json'),
55-
]
56-
57-
58-
cmdclass = create_cmdclass('jsdeps', package_data_spec=package_data_spec,
59-
data_files_spec=data_files_spec)
60-
npm_install = combine_commands(
61-
install_npm(HERE, build_cmd='build:prod'),
62-
ensure_targets(jstargets),
63-
)
64-
cmdclass['jsdeps'] = skip_if_exists(jstargets, npm_install)
65-
66-
67-
setup_args = dict(
68-
name = name,
69-
description = 'A Jupyter widget to allow input of a python function, with syntax highlighting.',
70-
version = version,
71-
scripts = glob(pjoin('scripts', '*')),
72-
cmdclass = cmdclass,
73-
packages = find_packages(),
74-
author = 'Dou Du',
75-
author_email = '[email protected]',
76-
url = 'https://github.com/osscar-org/widget-code-input',
77-
license = 'BSD',
78-
platforms = "Linux, Mac OS X, Windows",
79-
keywords = ['Jupyter', 'Widgets', 'IPython'],
80-
classifiers = [
81-
'Intended Audience :: Developers',
82-
'Intended Audience :: Science/Research',
83-
'License :: OSI Approved :: BSD License',
84-
'Programming Language :: Python',
85-
'Programming Language :: Python :: 3',
86-
'Programming Language :: Python :: 3.4',
87-
'Programming Language :: Python :: 3.5',
88-
'Programming Language :: Python :: 3.6',
89-
'Programming Language :: Python :: 3.7',
90-
'Framework :: Jupyter',
91-
],
92-
include_package_data = True,
93-
python_requires=">=3.6",
94-
install_requires = [
95-
'ipywidgets>=7.0.0',
96-
],
97-
extras_require = {
98-
'test': [
99-
'pytest>=4.6',
100-
'pytest-cov',
101-
'nbval',
102-
],
103-
'examples': [
104-
# Any requirements for the examples to run
105-
],
106-
'docs': [
107-
'jupyter_sphinx',
108-
'nbsphinx',
109-
'nbsphinx-link',
110-
'pytest_check_links',
111-
'pypandoc',
112-
'recommonmark',
113-
'sphinx>=1.5',
114-
'sphinx_rtd_theme',
115-
],
116-
},
117-
entry_points = {
118-
},
119-
)
120-
121-
if __name__ == '__main__':
122-
setup(**setup_args)
1+
# setup.py shim for use with applications that require it.
2+
__import__("setuptools").setup()

src/__tests__/index.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66

77
import { createTestModel } from './utils';
88

9-
import { ExampleModel } from '..';
9+
import { WidgetCodeModel } from '..';
1010

1111
describe('Example', () => {
12-
describe('ExampleModel', () => {
12+
describe('WidgetCodeModel', () => {
1313
it('should be createable', () => {
14-
const model = createTestModel(ExampleModel);
15-
expect(model).toBeInstanceOf(ExampleModel);
14+
const model = createTestModel(WidgetCodeModel);
15+
expect(model).toBeInstanceOf(WidgetCodeModel);
1616
expect(model.get('value')).toEqual('Hello World');
1717
});
1818

1919
it('should be createable with a value', () => {
2020
const state = { value: 'Foo Bar!' };
21-
const model = createTestModel(ExampleModel, state);
22-
expect(model).toBeInstanceOf(ExampleModel);
21+
const model = createTestModel(WidgetCodeModel, state);
22+
expect(model).toBeInstanceOf(WidgetCodeModel);
2323
expect(model.get('value')).toEqual('Foo Bar!');
2424
});
2525
});

src/__tests__/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Distributed under the terms of the Modified BSD License.
33

44
import * as widgets from '@jupyter-widgets/base';
5+
import * as baseManager from '@jupyter-widgets/base-manager';
56
import * as services from '@jupyterlab/services';
67

78
let numComms = 0;
@@ -44,7 +45,7 @@ export class MockComm implements widgets.IClassicComm {
4445
_on_close: ((x?: any) => void) | null = null;
4546
}
4647

47-
export class DummyManager extends widgets.ManagerBase<HTMLElement> {
48+
export class DummyManager extends baseManager.ManagerBase {
4849
constructor() {
4950
super();
5051
this.el = window.document.createElement('div');

src/plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Copyright (c) Dou Du
22
// Distributed under the terms of the Modified BSD License.
33

4-
import { Application, IPlugin } from '@phosphor/application';
4+
import { Application, IPlugin } from '@lumino/application';
55

6-
import { Widget } from '@phosphor/widgets';
6+
import { Widget } from '@lumino/widgets';
77

88
import { IJupyterWidgetRegistry } from '@jupyter-widgets/base';
99

0 commit comments

Comments
 (0)