import site
import os
import sys

if not any("calculate/contrib" in x for x in sys.path):
    for sitedir in site.getsitepackages():
        if sitedir.endswith("python3.10/site-packages"):
            for i, syspathdir in enumerate(sys.path):
                if syspathdir.endswith("python3.10/site-packages"):
                    contribpath = "%s/calculate/contrib" % syspathdir
                    if os.path.exists(contribpath):
                        sys.path.insert(i, contribpath)
                        break
    if not any("calculate/contrib" in x for x in sys.path):
        raise ImportError("Failed to install calculate contribution directory")
