[build-system]
requires = ["scikit-build-core"]
build-backend = "scikit_build_core.build"

[project]
name = "lanelet2x"
dynamic = ["version"]
authors = [
    { name = "Fabian Poggenhans", email = "fabian.poggenhans@kit.edu" },
    { name = "Fabian Immel", email = "fabian.immel@kit.edu" },
]
maintainers = [
    { name = "Vincent Wu", email = "zhengyu.wu21@imperial.ac.uk" }
]
description = "Your favorite map handling framework for automated driving, now standalone and with cross-platform support."
readme = "README.md"
requires-python = ">=3.9"
keywords = ["python", "lanelet2"]
license = { file = "LICENSE" }
classifiers = [
    "Programming Language :: Python",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.9",
    "Programming Language :: Python :: 3.10",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: 3.12",
    "License :: OSI Approved :: BSD License",
    "Operating System :: MacOS",
    "Operating System :: Microsoft :: Windows",
    "Operating System :: POSIX :: Linux",
]

[project.optional-dependencies]
pytest = ["pytest"]

[tool.scikit-build]
build-dir = "build/{wheel_tag}"
cmake.args = ["-G Ninja", "--preset conan-release"]
cmake.define = { BUILD_TESTING = "OFF" }
cmake.build-type = "Release"
wheel.packages = ["lanelet2_python/src/lanelet2"]
wheel.license-files = ["LICENSE", "CODEOWNERS"]
logging.level = "DEBUG"
cmake.verbose = true

[tool.scikit-build.metadata.version]
provider = "scikit_build_core.metadata.regex"
input = "conanfile.py"

[[tool.scikit-build.overrides]]
if.platform-system = "win32"
cmake.args = ["--preset conan-default"] # override for multi-configuration generator (i.e. MSVC) on Windows

[tool.cibuildwheel]
skip = ["*-win32", "*-musllinux_x86_64", "*_i686"]
test-requires = "pytest"
test-command = [
    "pytest {project}/lanelet2_python/test",
    "pytest {project}/lanelet2_examples/test"
]

[tool.cibuildwheel.windows]
before-build = [
    "python -m pip install --upgrade pip",
    "pip install -r requirements.txt",
    "conan profile detect --force",
    "conan install . --output-folder=build --build=missing"
]

[tool.cibuildwheel.linux]
before-build = [
    # here, we restore libpython*.a - otherwise conan will fail when adding boost::python
    # see https://github.com/pypa/manylinux/blob/main/docker/build_scripts/finalize-python.sh
    "pushd /opt/_internal",
    "tar -xJf static-libs-for-embedding-only.tar.xz",
    "popd",
    "python -m pip install --upgrade pip",
    "pip install -r requirements.txt",
    "conan profile detect --force",
    # we force the build of everything from source - prebuilt b2 does not work in manylinux
    # also set the generator to use ninja because scikit-build-core will default to ninja
    "conan install . --output-folder=build --build=* -c tools.cmake.cmaketoolchain:generator=Ninja"
]

[tool.cibuildwheel.macos]
before-build = [
    "python -m pip install --upgrade pip",
    "pip install -r requirements.txt",
    "conan profile detect --force",
    # set the generator to use ninja because scikit-build-core will default to ninja
    "conan install . --output-folder=build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja"
]