def get_package_name(filepath):
fullpath = filepath[:]<EOL>pkg_name = []<EOL>while '<STR_LIT>' in filepath or '<STR_LIT>' in filepath:<EOL><INDENT>filepath, p2 = os.path.split(filepath)<EOL>if p2 in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>break<EOL><DEDENT>pkg_name.append(p2)<EOL><DEDENT>if not pkg_name:<EOL><INDENT>if '<STR_LIT>' in fullpath:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT><DEDENT>pkg_name.reverse()<EOL>if pkg_name[<NUM_LIT:0>].endswith('<STR_LIT>'):<EOL><INDENT>pkg_name.pop(<NUM_LIT:0>)<EOL><DEDENT>return '<STR_LIT:.>'.join(pkg_name)<EOL>
Given a path where a package is installed, determine its name.

Parameters
----------
filepath : str
    Path to a file. If the determination fails, "numpy" is returned.

Examples
--------
>>> np.testing.nosetester.get_package_name('nonsense')
'numpy'