Skip to content

Commit

Permalink
Merge pull request #448 from ianhi/model-version
Browse files Browse the repository at this point in the history
Add model version separate from package version
  • Loading branch information
ianhi committed Apr 13, 2022
2 parents 3e0a520 + a027447 commit 8911332
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 17 deletions.
8 changes: 7 additions & 1 deletion ipympl/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
version_info = (0, 8, 8)
__version__ = '.'.join(map(str, version_info))
js_semver = '^0.10.5'


# The versions of protocol of communication with the frontend that this python verison knows
# how to speak. See counterpart in the src/version.ts file.
# These should not be changed unless we introduce changes to communication between
# frontend and backend.
__MODEL_VERSION__ = "1.0.0"
10 changes: 5 additions & 5 deletions ipympl/backend_nbagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
observe,
)

from ._version import js_semver
from ._version import __MODEL_VERSION__

cursors_str = {
cursors.HAND: 'pointer',
Expand Down Expand Up @@ -93,11 +93,11 @@ def connection_info():
class Toolbar(DOMWidget, NavigationToolbar2WebAgg):

_model_module = Unicode('jupyter-matplotlib').tag(sync=True)
_model_module_version = Unicode(js_semver).tag(sync=True)
_model_module_version = Unicode(__MODEL_VERSION__).tag(sync=True)
_model_name = Unicode('ToolbarModel').tag(sync=True)

_view_module = Unicode('jupyter-matplotlib').tag(sync=True)
_view_module_version = Unicode(js_semver).tag(sync=True)
_view_module_version = Unicode(__MODEL_VERSION__).tag(sync=True)
_view_name = Unicode('ToolbarView').tag(sync=True)

toolitems = List().tag(sync=True)
Expand Down Expand Up @@ -180,11 +180,11 @@ def _on_orientation_collapsed_changed(self, change):
class Canvas(DOMWidget, FigureCanvasWebAggCore):

_model_module = Unicode('jupyter-matplotlib').tag(sync=True)
_model_module_version = Unicode(js_semver).tag(sync=True)
_model_module_version = Unicode(__MODEL_VERSION__).tag(sync=True)
_model_name = Unicode('MPLCanvasModel').tag(sync=True)

_view_module = Unicode('jupyter-matplotlib').tag(sync=True)
_view_module_version = Unicode(js_semver).tag(sync=True)
_view_module_version = Unicode(__MODEL_VERSION__).tag(sync=True)
_view_name = Unicode('MPLCanvasView').tag(sync=True)

toolbar = Instance(Toolbar, allow_none=True).tag(sync=True, **widget_serialization)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
'pillow',
'traitlets<6',
'ipywidgets>=7.6.0,<8',
'matplotlib>=2.0.0,<4',
'matplotlib>=3.4.0,<4',
],
extras_require={
"docs": [
Expand Down
6 changes: 3 additions & 3 deletions src/mpl_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {

import * as utils from './utils';

import { MODULE_VERSION } from './version';
import { MODEL_VERSION } from './version';

import { ToolbarView } from './toolbar_widget';

Expand All @@ -30,8 +30,8 @@ export class MPLCanvasModel extends DOMWidgetModel {
_view_name: 'MPLCanvasView',
_model_module: 'jupyter-matplotlib',
_view_module: 'jupyter-matplotlib',
_model_module_version: '^' + MODULE_VERSION,
_view_module_version: '^' + MODULE_VERSION,
_model_module_version: MODEL_VERSION,
_view_module_version: MODEL_VERSION,
header_visible: true,
footer_visible: true,
toolbar: null,
Expand Down
6 changes: 3 additions & 3 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Widget } from '@phosphor/widgets';

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

import { MODULE_NAME, MODULE_VERSION } from './version';
import { MODEL_VERSION, MODULE_NAME } from './version';

const EXTENSION_ID = 'matplotlib-jupyter:main';

Expand All @@ -31,7 +31,7 @@ function activateWidgetExtension(
): void {
registry.registerWidget({
name: MODULE_NAME,
version: MODULE_VERSION,
exports: () => import('./index'),
version: MODEL_VERSION,
exports: (): any => import('./index'),
});
}
6 changes: 3 additions & 3 deletions src/toolbar_widget.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DOMWidgetModel, DOMWidgetView } from '@jupyter-widgets/base';

import { MODULE_VERSION } from './version';
import { MODEL_VERSION } from './version';

import '../css/mpl_widget.css';

Expand All @@ -12,8 +12,8 @@ export class ToolbarModel extends DOMWidgetModel {
_view_name: 'ToolbarView',
_model_module: 'jupyter-matplotlib',
_view_module: 'jupyter-matplotlib',
_model_module_version: '^' + MODULE_VERSION,
_view_module_version: '^' + MODULE_VERSION,
_model_module_version: MODEL_VERSION,
_view_module_version: MODEL_VERSION,
toolitems: [],
position: 'left',
button_style: '',
Expand Down
11 changes: 10 additions & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ const data = require('../package.json');
*
* The html widget manager assumes that this is the same as the npm package
* version number.
*
* See counterparts in the _version.py file
* These should not be changed unless we introduce changes to communication between
* frontend and backend.
*/
export const MODULE_VERSION = data.version;
export const MODEL_VERSION = '1.0.0';

/*
* The current package name.
*/
export const MODULE_NAME = data.name;

/*
* The package version
*/
export const MODULE_VERSION = data.version;

0 comments on commit 8911332

Please sign in to comment.