Skip to content

Commit b2e6e3d

Browse files
authored
Merge pull request #13 from astrofrog/fix-versions
Fix model and view versions to match between Python and JS
2 parents 0e4078c + b0a0da5 commit b2e6e3d

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

{{cookiecutter.github_project_name}}/src/plugin.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ import {
1818
} from './widget';
1919

2020
import {
21-
JUPYTER_EXTENSION_VERSION
21+
EXTENSION_SPEC_VERSION
2222
} from './version';
2323

24-
2524
const EXTENSION_ID = '{{ cookiecutter.jlab_extension_id }}';
2625

2726

@@ -44,7 +43,7 @@ export default examplePlugin;
4443
function activateWidgetExtension(app: Application<Widget>, registry: IJupyterWidgetRegistry): void {
4544
registry.registerWidget({
4645
name: '{{ cookiecutter.npm_package_name }}',
47-
version: JUPYTER_EXTENSION_VERSION,
46+
version: EXTENSION_SPEC_VERSION,
4847
exports: {
4948
ExampleModel: ExampleModel,
5049
ExampleView: ExampleView

{{cookiecutter.github_project_name}}/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
* your models, or serialized format changes.
1111
*/
1212
export
13-
const JUPYTER_EXTENSION_VERSION = '1.0.0';
13+
const EXTENSION_SPEC_VERSION = '1.0.0';

{{cookiecutter.github_project_name}}/src/widget.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from '@jupyter-widgets/base';
77

88
import {
9-
JUPYTER_EXTENSION_VERSION
9+
EXTENSION_SPEC_VERSION
1010
} from './version';
1111

1212

@@ -31,10 +31,10 @@ class ExampleModel extends DOMWidgetModel {
3131

3232
static model_name = 'ExampleModel';
3333
static model_module = '{{ cookiecutter.npm_package_name }}';
34-
static model_module_version = JUPYTER_EXTENSION_VERSION;
34+
static model_module_version = EXTENSION_SPEC_VERSION;
3535
static view_name = 'ExampleView'; // Set to null if no view
3636
static view_module = '{{ cookiecutter.npm_package_name }}'; // Set to null if no view
37-
static view_module_version = JUPYTER_EXTENSION_VERSION;
37+
static view_module_version = EXTENSION_SPEC_VERSION;
3838
}
3939

4040

{{cookiecutter.github_project_name}}/{{cookiecutter.python_package_name}}/_version.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,11 @@
66

77
version_info = (0, 1, 0, 'dev')
88
__version__ = ".".join(map(str, version_info))
9+
10+
# The version of the attribute spec that this package
11+
# implements. This is the value used in
12+
# _model_module_version/_view_module_version.
13+
#
14+
# Update this value when attributes are added/removed from
15+
# your models, or serialized format changes.
16+
EXTENSION_SPEC_VERSION = '1.0.0'

{{cookiecutter.github_project_name}}/{{cookiecutter.python_package_name}}/example.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010

1111
from ipywidgets import DOMWidget
1212
from traitlets import Unicode
13+
from ._version import EXTENSION_SPEC_VERSION
1314

1415
module_name = "{{ cookiecutter.npm_package_name }}"
15-
module_version = "{{ cookiecutter.npm_package_version }}"
1616

1717

1818
class ExampleWidget(DOMWidget):
1919
"""TODO: Add docstring here
2020
"""
21-
_model_name = Unicode('ExampleModel').tag(sync=True)
21+
_model_name = Unicode('ExampleModel').tag(sync=True)
2222
_model_module = Unicode(module_name).tag(sync=True)
23-
_model_module_version = Unicode(module_version).tag(sync=True)
24-
_view_name = Unicode('ExampleView').tag(sync=True)
23+
_model_module_version = Unicode(EXTENSION_SPEC_VERSION).tag(sync=True)
24+
_view_name = Unicode('ExampleView').tag(sync=True)
2525
_view_module = Unicode(module_name).tag(sync=True)
26-
_view_module_version = Unicode(module_version).tag(sync=True)
26+
_view_module_version = Unicode(EXTENSION_SPEC_VERSION).tag(sync=True)
2727

2828
value = Unicode('Hello World')

0 commit comments

Comments
 (0)