code: def create_archive(
      source: Path,
      target: Path,
      interpreter: str,
      main: str,
      compressed: bool = True
  ) -> None:
      
      # Check that main has the right format.
      mod, sep, fn = main.partition(":")
      mod_ok = all(part.isidentifier() for part in mod.split("."))
      fn_ok = all(part.isidentifier() for part in fn.split("."))
      if not (sep == ":" and mod_ok and fn_ok):
          raise zipapp.ZipAppError("Invalid entry point: " + main)
  
      main_py = MAIN_TEMPLATE.format(module=mod, fn=fn)
  
      with maybe_open(target, "wb") as fd:
          # write shebang
          write_file_prefix(fd, interpreter)
  
          # determine compression
          compression = zipfile.ZIP_DEFLATED if compressed else zipfile.ZIP_STORED
  
          # create zipapp
          with zipfile.ZipFile(fd, "w", compression=compression) as z:
              for child in source.rglob("*"):
  
                  # skip compiled files
                  if child.suffix == '.pyc':
                      continue
  
                  arcname = child.relative_to(source)
                  z.write(str(child), str(arcname))
  
              # write main
              z.writestr("__main__.py", main_py.encode("utf-8"))
  
      # make executable
      # NOTE on windows this is no-op
      target.chmod(target.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
docs: Create an application archive from SOURCE.
  
      A slightly modified version of stdlib's
      `zipapp.create_archive <https://docs.python.org/3/library/zipapp.html#zipapp.create_archive>`_