code: def build_mupdf_windows(mupdf_local, env, build_type):
      assert mupdf_local
  
      wp = pipcl.wdev.WindowsPython()
      tesseract = (
          ""
          if os.environ.get("PYMUPDF_SETUP_MUPDF_TESSERACT") == "0"
          else "tesseract-"
      )
      windows_build_tail = f"build\\shared-{tesseract}{build_type}-x{wp.cpu.bits}-py{wp.version}"
      windows_build_dir = f"{mupdf_local}\\{windows_build_tail}"
      # log( f'Building mupdf.')
      devenv = os.environ.get("PYMUPDF_SETUP_DEVENV")
      if not devenv:
          vs = pipcl.wdev.WindowsVS()
          devenv = vs.devenv
      if not devenv:
          devenv = "devenv.com"
          log(
              f"Cannot find devenv.com in default locations, using: {devenv!r}"
          )
      command = f'cd "{mupdf_local}" && "{sys.executable}" ./scripts/mupdfwrap.py'
      if os.environ.get("PYMUPDF_SETUP_MUPDF_VS_UPGRADE") == "1":
          command += " --vs-upgrade 1"
  
      # Would like to simply do f'... --devenv {shutil.quote(devenv)}', but
      # it looks like if `devenv` has spaces then `shutil.quote()` puts it
      # inside single quotes, which then appear to be ignored when run by
      # subprocess.run().
      #
      # So instead we strip any enclosing quotes and the enclose with
      # double-quotes.
      #
      if len(devenv) >= 2:
          for q in '"', "'":
              if devenv.startswith(q) and devenv.endswith(q):
                  devenv = devenv[1:-1]
      command += f' -d {windows_build_tail} -b --refcheck-if "#if 1" --devenv "{devenv}" '
      if "b" in _implementations():
          command += "all"
      else:
          command += "01"  # No need for C++/Python bindings.
      env2 = os.environ.copy()
      env2.update(env)
      if os.environ.get("PYMUPDF_SETUP_MUPDF_REBUILD") == "0":
          log(
              f'PYMUPDF_SETUP_MUPDF_REBUILD is "0" so not building MuPDF; would have run with env={env!r}: {command}'
          )
      else:
          log(
              f"Building MuPDF by running with {env}={env!r}: {command}"
          )
          subprocess.run(command, shell=True, check=True, env=env2)
          log(f"Finished building mupdf.")
  
      return windows_build_dir
  
imports: import glob
  import io
  import os
  import textwrap
  import time
  import platform
  import shlex
  import shutil
  import stat
  import subprocess
  import sys
  import tarfile
  import urllib.request
  import zipfile
  import pipcl
  import sys
label_desc: Use image node_id 14 for calling a global function with example usage: build_mupdf_windows(mupdf_local, env, build_type) and returns: windows_build_dir