# (C) Copyright 2024- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.

# to be source'd by wheelmaker's compile.sh *and* wheel-linux.sh
# NOTE replace the whole thing with pyproject.toml? Less powerful, and quaint to use for sourcing ecbuild invocation
# TODO we duplicate information -- pyproject.toml's `name` and `packages` are derivable from $NAME and must stay consistent

NAME="fdb"
# NOTE zarr interface is dependent on python 3.11+ -- but we dont activate the venv at the time this is sourced, that's why we rely on PYVERSION. Remove this whole part around October 2026 when 3.10 goes EoL
# if [ "True" = "$(python -c 'import sys; print(sys.version_info[0:2] >= (3, 11))')" ] ; then
if [ "3.10" != "$PYVERSION" ] ; then
    ZARR_IFACE="-DENABLE_PYTHON_ZARR_INTERFACE=ON"
else
    >&2 echo "Not enabling zarr interface because python version is $PYVERSION"
    ZARR_IFACE=""
fi

# NOTE pyfdb interface is dependent on python 3.11+ -- but we don't activate
# the venv at the time this is sourced, that's why we rely on PYVERSION. Remove
# this whole part around October 2026 when 3.10 goes EoL
# if [ "True" = "$(python -c 'import sys; print(sys.version_info[0:2] >= (3, 11))')" ] ; then
if [ "3.10" != "$PYVERSION" ] ; then
    PYFDB_IFACE="-DENABLE_PYTHON_FDB_INTERFACE=ON"
else
    >&2 echo "Not enabling pyfdb interface because python version is $PYVERSION"
    PYFDB_IFACE=""
fi

CMAKE_PARAMS="-Deckit_ROOT=/tmp/fdb/prereqs/eckitlib -Dmetkit_ROOT=/tmp/fdb/prereqs/metkitlib -Deccodes_ROOT=/tmp/fdb/prereqs/eccodeslib $ZARR_IFACE $PYFDB_IFACE"
PYPROJECT_DIR="python/fdb5lib"
DEPENDENCIES='["eckitlib", "eccodeslib", "metkitlib"]'
