#
# Copyright (c) ZeroC, Inc. All rights reserved.
#

import os
import site
import sys

if len(sys.argv) != 2:
   print("Usage: {} [prefix]".format(sys.argv[0]))
   sys.exit(1)

prefix = sys.argv[1]
libdir = os.path.join(prefix, "lib", "python{}.{}".format(sys.version_info.major, sys.version_info.minor))

for dir in site.getsitepackages():
    if dir.startswith(libdir):
       print(dir)
       sys.exit(0)

libdir = os.path.join(prefix, "lib")

for dir in site.getsitepackages():
    if dir.startswith(libdir):
       print(dir)
       sys.exit(0)

for dir in site.getsitepackages():
    if dir.startswith(prefix):
       print(dir)
       sys.exit(0)

print(os.path.join(prefix, "python"))
