docs: def get_distribution(cls, ctx, name=None, recipes=[],
                           ndk_api=None,
                           force_build=False,
                           extra_dist_dirs=[],
                           require_perfect_match=False,
                           allow_replace_dist=True):
          '''Takes information about the distribution, and decides what kind of
          distribution it will be.
  
          If parameters conflict (e.g. a dist with that name already
          exists, but doesn't have the right set of recipes),
          an error is thrown.
  
          Parameters
          ----------
          name : str
              The name of the distribution. If a dist with this name already '
              exists, it will be used.
          recipes : list
              The recipes that the distribution must contain.
          force_download: bool
              If True, only downloaded dists are considered.
          force_build : bool
              If True, the dist is forced to be built locally.
          extra_dist_dirs : list
              Any extra directories in which to search for dists.
          require_perfect_match : bool
              If True, will only match distributions with precisely the
              correct set of recipes.
          allow_replace_dist : bool
              If True, will allow an existing dist with the specified
              name but incompatible requirements to be overwritten by
              a new one with the current requirements.
          '''
  
          existing_dists = Distribution.get_distributions(ctx)
  
          possible_dists = existing_dists
  
          name_match_dist = None
  
          # 0) Check if a dist with that name already exists
          if name is not None and name:
              possible_dists = [d for d in possible_dists if d.name == name]
              if possible_dists:
                  name_match_dist = possible_dists[0]
  
          # 1) Check if any existing dists meet the requirements
          _possible_dists = []
          for dist in possible_dists:
              if (
                  ndk_api is not None and dist.ndk_api != ndk_api
              ) or dist.ndk_api is None:
                  continue
              for recipe in recipes:
                  if recipe not in dist.recipes:
                      break
              else:
                  _possible_dists.append(dist)
          possible_dists = _possible_dists
  
          if possible_dists:
              info('Of the existing distributions, the following meet '
                   'the given requirements:')
              pretty_log_dists(possible_dists)
          else:
              info('No existing dists meet the given requirements!')
  
          # If any dist has perfect recipes and ndk API, return it
          for dist in possible_dists:
              if force_build:
                  continue
              if ndk_api is not None and dist.ndk_api != ndk_api:
                  continue
              if (set(dist.recipes) == set(recipes) or
                  (set(recipes).issubset(set(dist.recipes)) and
                   not require_perfect_match)):
                  info_notify('{} has compatible recipes, using this one'
                              .format(dist.name))
                  return dist
  
          assert len(possible_dists) < 2
  
          # If there was a name match but we didn't already choose it,
          # then the existing dist is incompatible with the requested
          # configuration and the build cannot continue
          if name_match_dist is not None and not allow_replace_dist:
              raise BuildInterruptingException(
                  'Asked for dist with name {name} with recipes ({req_recipes}) and '
                  'NDK API {req_ndk_api}, but a dist '
                  'with this name already exists and has either incompatible recipes '
                  '({dist_recipes}) or NDK API {dist_ndk_api}'.format(
                      name=name,
                      req_ndk_api=ndk_api,
                      dist_ndk_api=name_match_dist.ndk_api,
                      req_recipes=', '.join(recipes),
                      dist_recipes=', '.join(name_match_dist.recipes)))
  
          # If we got this far, we need to build a new dist
          dist = Distribution(ctx)
          dist.needs_build = True
  
          if not name:
              filen = 'unnamed_dist_{}'
              i = 1
              while exists(join(ctx.dist_dir, filen.format(i))):
                  i += 1
              name = filen.format(i)
  
          dist.name = name
          dist.dist_dir = join(ctx.dist_dir, dist.name)
          dist.recipes = recipes
          dist.ndk_api = ctx.ndk_api
  
          return dist