import os
import sys

prefix_xml_pth = os.path.join(sys.prefix, "share", "udunits", "udunits2.xml")
wheel_xml_pth = os.path.join(os.path.dirname(__file__), "data", "udunits2.xml")

if not os.environ.get("UDUNITS2_XML_PATH"):
    if os.path.exists(wheel_xml_pth):
        os.environ["UDUNITS2_XML_PATH"] = wheel_xml_pth
    elif os.path.exists(prefix_xml_pth):
        os.environ["UDUNITS2_XML_PATH"] = prefix_xml_pth

from cmor.cmor_const import *

from cmor.pywrapper import (
    CMORError, axis, variable, write, setup, load_table, set_table, zfactor,
    close, grid, set_grid_mapping, set_crs,
    dataset_json, set_cur_dataset_attribute, get_cur_dataset_attribute,
    has_cur_dataset_attribute, set_variable_attribute, get_variable_attribute,
    has_variable_attribute, get_final_filename, set_deflate, set_zstandard,
    set_quantize, set_furtherinfourl, set_climatology, get_climatology,
    set_terminate_signal, get_terminate_signal, set_chunking)

try:
    from check_CMOR_compliant import checkCMOR
except ImportError:
    pass
