code: 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
      "version" task, which ensures that changes are made `after` the version
      has been updated, but `before` the changes made as part of `lerna version`
      are committed."""
      logging.info("Updating Python `__version__` from `package.json`")
  
      here = os.path.abspath(os.path.dirname(__file__))
      package_json_path = os.path.join(here, "..", "package.json")
      version = None
  
      with open(os.path.realpath(package_json_path), "r") as f:
          version = json.load(f)["version"]
  
      logging.info(
          "Updating `perspective-python` to version `{}`".format(
              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
          )
      )
  
imports: import os
  import json
  import logging
label_desc: Use image node_id 2 for calling a global function with example usage: write_version() without return types