Try to find a module name for a file path
        by stripping off a prefix found in sys.modules.

def _module_name(filename):
        """
        Try to find a module name for a file path
        by stripping off a prefix found in sys.modules.
        """

        absfile = os.path.abspath(filename)
        match = filename

        for base in [''] + sys.path:
            base = os.path.abspath(base)
            if absfile.startswith(base):
                match = absfile[len(base):]
                break

        return SUFFIX_RE.sub('', match).lstrip('/').replace('/', '.')