Skip to content

Commit

Permalink
use major and minor versions only for PerspectiveWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
sc1f committed Feb 14, 2020
1 parent fb004fd commit bff7410
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions python/perspective/perspective/core/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__version__ = "0.4.3"
major_minor_version = "0.4"
6 changes: 3 additions & 3 deletions python/perspective/perspective/widget/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ..core.exception import PerspectiveError
from ..libpsp import is_libpsp
from ..viewer import PerspectiveViewer
from ..core import __version__
from ..core._version import major_minor_version


def _type_to_string(t):
Expand Down Expand Up @@ -142,10 +142,10 @@ class PerspectiveWidget(Widget, PerspectiveViewer):
# Required by ipywidgets for proper registration of the backend
_model_name = Unicode('PerspectiveModel').tag(sync=True)
_model_module = Unicode('@finos/perspective-jupyterlab').tag(sync=True)
_model_module_version = Unicode(__version__).tag(sync=True)
_model_module_version = Unicode("~{}".format(major_minor_version)).tag(sync=True)
_view_name = Unicode('PerspectiveView').tag(sync=True)
_view_module = Unicode('@finos/perspective-jupyterlab').tag(sync=True)
_view_module_version = Unicode(__version__).tag(sync=True)
_view_module_version = Unicode("~{}".format(major_minor_version)).tag(sync=True)

def __init__(self,
table_or_data,
Expand Down
11 changes: 11 additions & 0 deletions python/perspective/scripts/write_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
logging.basicConfig(level=logging.INFO)


def truncate_patch_version(version):
"""Return just the major and minor versions from `version`."""
split_version = version.split(".")
return "{}.{}".format(split_version[0], split_version[1])


def write_version():
"""Retrieves the version string from `package.json` managed by Lerna,
and writes it into `_version.py`. This script is run as part of Lerna's
Expand All @@ -32,10 +38,15 @@ def write_version():

version_py_path = os.path.join(here, "..", "perspective", "core", "_version.py")

# PerspectiveWidget uses the major and minor versions for semver only.
truncated = truncate_patch_version(version)

with open(os.path.realpath(version_py_path), "w") as f:
f.write('__version__ = "{}"\n'.format(version))
f.write('major_minor_version = "{}"\n'.format(truncated))

logging.info("`perspective-python` updated to version `{}`".format(version))
logging.info("`PerspectiveWidget` now requires `perspective-jupyterlab` version `~{}`".format(truncated))


if __name__ == "__main__":
Expand Down

0 comments on commit bff7410

Please sign in to comment.