
'''Add locally installed packages that are described by pth files.'''


try:
    import sys
    from site import addsitedir
    from copy import deepcopy

    sitedirs = deepcopy(sys.path)

    # Add locally installed packages:
    for sitedir in sitedirs:
        addsitedir(sitedir)

    # Remove double entries from path:
    sitedirs = deepcopy(sys.path)
    for i in xrange(len(sitedirs)-1,0,-1):
        if sitedirs.count(sitedirs[i])>1:
            del(sitedirs[i])

    sys.path = sitedirs

except Exception,e:
    print e
