code: def write_executable(path, source):
      if sys.platform == "win32":
          script = path.dirpath() / path.purebasename + "-script.py"
          exe = path.dirpath() / path.purebasename + ".exe"
      else:
          script = path
  
      script.write(source)
      script.chmod(0o700)
  
      if sys.platform == "win32":
          try:
              import importlib.resources
  
              if not hasattr(importlib.resources, "files"):
                  raise ImportError
              wp = importlib.resources.files("setuptools").joinpath(
                  "cli-32.exe"
              )
              w = wp.read_bytes()
          except (ImportError, FileNotFoundError, SystemError):
              pytest.skip(
                  "Need importlib.resources and setuptools to make scripts executable on Windows"
              )
          exe.write(w, "wb")
          exe.chmod(0o700)
  
imports: from __future__ import annotations
  import json
  import os
  import sys
  import sysconfig
  from subprocess import PIPE, CalledProcessError, check_output
  from unittest.mock import patch
  import pytest
  from jupyter_core import __version__
  from jupyter_core.command import list_subcommands
  from jupyter_core.paths import jupyter_config_dir, jupyter_config_path, jupyter_data_dir, jupyter_path, jupyter_runtime_dir
label_desc: Use image node_id 4 for calling a global function with example usage: write_executable(path, source) without return types