import os
import sys
import site
from sysconfig import get_path

if __name__ == '__main__':
    prefix = sys.argv[1]

    #ask sysconfig where to install the python module
    install_dir = get_path('platlib', 'posix_user', {'userbase': prefix})

    #use sites when the prefix is already recognized
    try:
        paths = [p for p in site.getsitepackages() if p.startswith(prefix)]
        if len(paths) == 1: install_dir = paths[0]
    except AttributeError: pass

    #strip the prefix to return a relative path
    print(os.path.relpath(install_dir, prefix))
