from pathlib import Path

from osgeo import gdal
import tomli as tomllib

try:
    from importlib import metadata
    __version__: str = metadata.version(__name__)
except ModuleNotFoundError:
    pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
    with open(pyproject_path, "rb") as f:
        pyproject_data = tomllib.load(f)
    __version__ = pyproject_data["project"]["version"]

from .layers import YirgacheffeLayer, ResamplingMethod
from ._core import read_raster, read_rasters, read_shape, read_raster_like, read_shape_like, constant, \
    read_narrow_raster, from_array, area_raster, to_geotiff
from .constants import WGS_84_PROJECTION
from ._datatypes.area import Area
from ._datatypes.mapprojection import MapProjection
from ._datatypes.pixelscale import PixelScale
from ._datatypes.window import Window
from ._backends.enumeration import dtype as DataType

from ._operators.functions import where, minimum, maximum, clip, log, log2, log10, exp, exp2, nan_to_num, isin, \
    floor, ceil # pylint: disable=W0611
from ._operators.functions import abs, all, any, round, sum # pylint: disable=W0611,W0622

gdal.UseExceptions()
