code: def find_installation_spec(
      airflow_constraints_mode: str,
      airflow_constraints_location: str | None,
      airflow_constraints_reference: str,
      airflow_extras: str,
      airflow_skip_constraints: bool,
      default_constraints_branch: str,
      github_repository: str,
      install_selected_providers: str,
      package_format: str,
      providers_constraints_mode: str,
      providers_constraints_location: str | None,
      providers_constraints_reference: str,
      providers_skip_constraints: bool,
      python_version: str,
      use_airflow_version: str,
      use_packages_from_dist: bool,
  ) -> InstallationSpec:
      if use_packages_from_dist:
          console.print("[bright_blue]Using packages from dist folder")
      else:
          console.print(
              "[bright_blue]Not using packages from dist folder - only install from remote sources"
          )
      if use_packages_from_dist and package_format not in [
          "wheel",
          "sdist",
      ]:
          console.print(
              f"[red]PACKAGE_FORMAT must be one of 'wheel' or 'sdist' and not {package_format}"
          )
          sys.exit(1)
      extension = "whl" if package_format == "wheel" else "tar.gz"
      if airflow_extras:
          console.print(
              f"[bright_blue]Using airflow extras: {airflow_extras}"
          )
          airflow_extras = f"[{airflow_extras}]"
      else:
          console.print("[bright_blue]No airflow extras specified.")
      if (
          use_airflow_version
          and (AIRFLOW_SOURCE_DIR / "airflow").exists()
      ):
          console.print(
              f"[red]The airflow source folder exists in {AIRFLOW_SOURCE_DIR}, but you are "
              f"removing it and installing airflow from {use_airflow_version}."
          )
          console.print(
              "[red]This is not supported. Please use --mount-sources=remove flag in breeze."
          )
          sys.exit(1)
      if (
          use_airflow_version in ["wheel", "sdist"]
          and use_packages_from_dist
      ):
          airflow_package_spec = find_airflow_package(extension)
          if use_airflow_version != package_format:
              console.print(
                  "[red]USE_AIRFLOW_VERSION must be the same as PACKAGE_FORMAT cannot have "
                  "wheel and sdist values set at the same time"
              )
              sys.exit(1)
          if airflow_package_spec:
              airflow_version = get_airflow_version_from_package(
                  airflow_package_spec
              )
              if airflow_version:
                  airflow_constraints_location = get_airflow_constraints_location(
                      airflow_skip_constraints=airflow_skip_constraints,
                      airflow_constraints_mode=airflow_constraints_mode,
                      airflow_constraints_location=airflow_constraints_location,
                      airflow_constraints_reference=airflow_constraints_reference,
                      airflow_package_version=airflow_version,
                      default_constraints_branch=default_constraints_branch,
                      github_repository=github_repository,
                      python_version=python_version,
                  )
              if airflow_extras:
                  airflow_package_spec += airflow_extras
      elif use_airflow_version == "none" or use_airflow_version == "":
          console.print(
              "\n[bright_blue]Skipping airflow package installation\n"
          )
          airflow_package_spec = None
          airflow_constraints_location = None
      elif use_airflow_version.startswith(ALLOWED_VCS_PROTOCOLS):
          console.print(
              f"\nInstalling airflow from remote spec {use_airflow_version}\n"
          )
          if airflow_extras:
              airflow_package_spec = f"apache-airflow{airflow_extras} @ {use_airflow_version}"
          else:
              airflow_package_spec = use_airflow_version
          airflow_constraints_location = get_airflow_constraints_location(
              airflow_skip_constraints=airflow_skip_constraints,
              airflow_constraints_mode=airflow_constraints_mode,
              airflow_constraints_location=airflow_constraints_location,
              airflow_constraints_reference=airflow_constraints_reference,
              airflow_package_version=use_airflow_version,
              default_constraints_branch=default_constraints_branch,
              github_repository=github_repository,
              python_version=python_version,
          )
      else:
          console.print(
              f"\nInstalling airflow via apache-airflow=={use_airflow_version}"
          )
          airflow_package_spec = (
              f"apache-airflow{airflow_extras}=={use_airflow_version}"
          )
          airflow_constraints_location = get_airflow_constraints_location(
              airflow_skip_constraints=airflow_skip_constraints,
              airflow_constraints_mode=airflow_constraints_mode,
              airflow_constraints_location=airflow_constraints_location,
              airflow_constraints_reference=airflow_constraints_reference,
              airflow_package_version=use_airflow_version,
              default_constraints_branch=default_constraints_branch,
              github_repository=github_repository,
              python_version=python_version,
          )
      provider_package_list = []
      if use_packages_from_dist:
          selected_providers_list = (
              install_selected_providers.split(",")
              if install_selected_providers
              else []
          )
          if selected_providers_list:
              console.print(
                  f"\n[bright_blue]Selected providers: {selected_providers_list}\n"
              )
          else:
              console.print("\n[bright_blue]No preselected providers\n")
          provider_package_list = find_provider_packages(
              extension, selected_providers_list
          )
      return InstallationSpec(
          airflow_package=airflow_package_spec,
          airflow_constraints_location=airflow_constraints_location,
          provider_packages=provider_package_list,
          provider_constraints_location=get_providers_constraints_location(
              providers_constraints_mode=providers_constraints_mode,
              providers_constraints_location=providers_constraints_location,
              providers_constraints_reference=providers_constraints_reference,
              providers_skip_constraints=providers_skip_constraints,
              default_constraints_branch=default_constraints_branch,
              github_repository=github_repository,
              python_version=python_version,
          ),
      )
  
file_path: airflow/scripts/in_container/install_airflow_and_providers.py
imports: from __future__ import annotations
  import re
  import sys
  from pathlib import Path
  from typing import NamedTuple
  from in_container_utils import click, console, run_command
label_desc: Use image node_id 8 for calling a global function with example usage: find_installation_spec(airflow_constraints_mode, airflow_constraints_location, airflow_constraints_reference, airflow_extras, airflow_skip_constraints, default_constraints_branch, github_repository, install_selected_providers, package_format, providers_constraints_mode, providers_constraints_location, providers_constraints_reference, providers_skip_constraints, python_version, use_airflow_version, use_packages_from_dist) and returns: InstallationSpec