def findPackagePath(modulePath):
    """
    Try to find the sys.path entry from a modulePath object, simultaneously
    computing the module name of the targetted file.
    """
    p = modulePath
    l = [p.basename().split('.')[0]]
    while p.parent() != p:
        for extension in ['py', 'pyc', 'pyo', 'pyd', 'dll']:
            sib = p.sibling('__init__.' + extension)
            if sib.exists():
                p = p.parent()
                l.insert(0, p.basename())
                break
        else:
            return p.parent(), '.'.join(l)
