code: def check_dist_restriction(options, check_target=False):
      # type: (Values, bool) -> None
      
      dist_restriction_set = any([
          options.python_version,
          options.platform,
          options.abi,
          options.implementation,
      ])
  
      binary_only = FormatControl(set(), {':all:'})
      sdist_dependencies_allowed = (
          options.format_control != binary_only and
          not options.ignore_dependencies
      )
  
      # Installations or downloads using dist restrictions must not combine
      # source distributions and dist-specific wheels, as they are not
      # gauranteed to be locally compatible.
      if dist_restriction_set and sdist_dependencies_allowed:
          raise CommandError(
              "When restricting platform and interpreter constraints using "
              "--python-version, --platform, --abi, or --implementation, "
              "either --no-deps must be set, or --only-binary=:all: must be "
              "set and --no-binary must not be set (or must be set to "
              ":none:)."
          )
  
      if check_target:
          if dist_restriction_set and not options.target_dir:
              raise CommandError(
                  "Can not use any platform or abi specific options unless "
                  "installing via '--target'"
              )
docs: Function for determining if custom platform options are allowed.
  
      :param options: The OptionParser options.
      :param check_target: Whether or not to check if --target is being used.