def is_parent_path(parent: str, trial: str) -> bool:
    '''Checks if @trial is a file under the directory @parent. Both @trial and @parent should be
       adequately normalized, though empty and '.' segments in @parent and @trial are accepted
       and discarded, matching the behavior of os.path.commonpath.  Either both or none should
       be absolute.'''
    assert os.path.isabs(parent) == os.path.isabs(trial)
    if is_windows():
        parent = parent.replace('\\', '/')
        trial = trial.replace('\\', '/')

    split_parent = parent.split('/')
    split_trial = trial.split('/')

    split_parent = [c for c in split_parent if c and c != '.']
    split_trial = [c for c in split_trial if c and c != '.']

    components = len(split_parent)
    return len(split_trial) >= components and split_trial[:components] == split_parent
Checks if @trial is a file under the directory @parent. Both @trial and @parent should be
       adequately normalized, though empty and '.' segments in @parent and @trial are accepted
       and discarded, matching the behavior of os.path.commonpath.  Either both or none should
       be absolute.
mesonbuild/utils/universal.py