code: def _prepare_lightning_wheels_and_requirements(
      root: Path, package_name: str = "lightning"
  ) -> Optional[Callable]:
      """This function determines if lightning is installed in editable mode (for developers) and packages the current
      lightning source along with the app.
  
      For normal users who install via PyPi or Conda, then this function does not do anything.
  
      """
      if not get_dist_path_if_editable_install(package_name):
          return None
  
      os.environ["PACKAGE_NAME"] = (
          "app" if package_name == "lightning" + "_app" else "lightning"
      )
  
      # Packaging the Lightning codebase happens only inside the `lightning` repo.
      git_dir_name = (
          get_dir_name() if check_github_repository() else None
      )
  
      is_lightning = git_dir_name and git_dir_name == package_name
  
      if (
          PACKAGE_LIGHTNING is None and not is_lightning
      ) or PACKAGE_LIGHTNING == "0":
          return None
  
      download_frontend(_PROJECT_ROOT)
      _prepare_wheel(_PROJECT_ROOT)
  
      # todo: check why logging.info is missing in outputs
      print(
          f"Packaged Lightning with your application. Version: {version}"
      )
  
      tar_name = _copy_tar(_PROJECT_ROOT, root)
  
      tar_files = [os.path.join(root, tar_name)]
  
      # Don't skip by default
      if (PACKAGE_LIGHTNING or is_lightning) and not bool(
          int(os.getenv("SKIP_LIGHTING_UTILITY_WHEELS_BUILD", "0"))
      ):
          # building and copying lightning-cloud wheel if installed in editable mode
          lightning_cloud_project_path = (
              get_dist_path_if_editable_install("lightning_cloud")
          )
          if lightning_cloud_project_path:
              from lightning_cloud.__version__ import (
                  __version__ as cloud_version,
              )
  
              # todo: check why logging.info is missing in outputs
              print(
                  f"Packaged Lightning Cloud with your application. Version: {cloud_version}"
              )
              _prepare_wheel(lightning_cloud_project_path)
              tar_name = _copy_tar(lightning_cloud_project_path, root)
              tar_files.append(os.path.join(root, tar_name))
  
          lightning_launcher_project_path = (
              get_dist_path_if_editable_install("lightning_launcher")
          )
          if lightning_launcher_project_path:
              from lightning_launcher.__version__ import (
                  __version__ as cloud_version,
              )
  
              # todo: check why logging.info is missing in outputs
              print(
                  f"Packaged Lightning Launcher with your application. Version: {cloud_version}"
              )
              _prepare_wheel(lightning_launcher_project_path)
              tar_name = _copy_tar(
                  lightning_launcher_project_path, root
              )
              tar_files.append(os.path.join(root, tar_name))
  
      return functools.partial(_cleanup, *tar_files)
  
imports: import functools
  import logging
  import os
  import pathlib
  import shutil
  import subprocess
  import sys
  import tarfile
  import tempfile
  import urllib.request
  from pathlib import Path
  from typing import Any, Callable, Optional
  from packaging.version import Version
  from lightning.app import _PROJECT_ROOT, _logger, _root_logger
  from lightning.app import __version__
  from lightning.app.core.constants import FRONTEND_DIR, PACKAGE_LIGHTNING
  from lightning.app.utilities.app_helpers import Logger
  from lightning.app.utilities.git import check_github_repository, get_dir_name
label_desc: Use image node_id 6 for calling a global function with example usage: _prepare_lightning_wheels_and_requirements(root, package_name) and returns: functools, None, None