code: def create_fileset_with_spec(cls, rel_path, *patterns, **kwargs):
      
      for pattern in patterns:
        if not isinstance(pattern, string_types):
          raise ValueError("Expected string patterns for {}: got {}".format(cls.__name__, patterns))
  
      raw_exclude = kwargs.pop('exclude', [])
      buildroot = get_buildroot()
      root = os.path.normpath(os.path.join(buildroot, rel_path))
  
      # making sure there are no unknown arguments.
      unknown_args = set(kwargs.keys()) - cls.KNOWN_PARAMETERS
  
      if unknown_args:
        raise ValueError('Unexpected arguments while parsing globs: {}'.format(
          ', '.join(unknown_args)))
  
      for glob in patterns:
        if cls._is_glob_dir_outside_root(glob, root):
          raise ValueError('Invalid glob {}, points outside BUILD file root {}'.format(glob, root))
  
      exclude = cls.process_raw_exclude(raw_exclude)
  
      files_calculator = cls._file_calculator(root, patterns, kwargs, exclude)
  
      rel_root = fast_relpath(root, buildroot)
      if rel_root == '.':
        rel_root = ''
      filespec = cls.to_filespec(patterns, root=rel_root, exclude=exclude)
  
      return LazyFilesetWithSpec(rel_root, filespec, files_calculator)
docs: :param rel_path: The relative path to create a FilesetWithSpec for.
      :param patterns: glob patterns to apply.
      :param exclude: A list of {,r,z}globs objects, strings, or lists of strings to exclude.
                      NB: this argument is contained within **kwargs!