<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse(packages, static=False):
 """ Parse the output from pkg-config about the passed package or packages. Builds a dictionary containing the 'libraries', the 'library_dirs', the 'include_dirs', and the 'define_macros' that are presented by pkg-config. *package* is a string with space-delimited package names. The static specifier will also include libraries for static linking (i.e., includes any private libraries). If ``pkg-config`` is not on path, raises ``EnvironmentError``. """

    for package in packages.split():
        _raise_if_not_exists(package)

    out = _query(packages, *_build_options('--cflags --libs', static=static))
    out = out.replace('\\"', '')
    result = collections.defaultdict(list)

    for token in re.split(r'(?<!\\) ', out):
        key = _PARSE_MAP.get(token[:2])
        if key:
            result[key].append(token[2:].strip())

    def split(m):
        t = tuple(m.split('='))
        return t if len(t) > 1 else (t[0], None)

    result['define_macros'] = [split(m) for m in result['define_macros']]

    # only have members with values not being the empty list (which is default
    # anyway):
    return collections.defaultdict(list, ((k, v) for k, v in result.items() if v))