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

[project]
name = "pytetwild"
version = "0.1.0"
description = "Python wrapper of fTetWild"
readme = { file = "README.rst", content-type = "text/x-rst" }
authors = [{ name = "Alex Kaszynski", email = "akascap@gmail.com" }]
dependencies = ["numpy"]
classifiers = [
    'Development Status :: 3 - Alpha',
    'Intended Audience :: Science/Research',
    'Topic :: Scientific/Engineering :: Information Analysis',
    'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
    'Operating System :: Microsoft :: Windows',
    'Operating System :: POSIX',
    'Operating System :: MacOS',
    'Programming Language :: Python :: 3.8',
    'Programming Language :: Python :: 3.9',
    'Programming Language :: Python :: 3.10',
    'Programming Language :: Python :: 3.11',
    'Programming Language :: Python :: 3.12',
]

[tool.setuptools.packages.find]
where = ["src"]
include = ["pytetwild*"]

[tool.setuptools.package-data]
pytetwild = ["py.typed"]

[project.optional-dependencies]
all = ['pyvista']
dev = ["pytest", "pre-commit", "pyvista", "scipy", "meshio"]

[tool.scikit-build]
build-dir = "./build"
editable.mode = "inplace"

[tool.scikit-build.cmake]
args = [
    "-DCMAKE_BUILD_TYPE=Release",
    "-DCMAKE_CXX_STANDARD=17",
    "-DBUILD_SHARED_LIBS=OFF",
]

[tool.pytest.ini_options]
testpaths = 'tests'

[tool.cibuildwheel]
archs = ["auto64"]  # 64-bit only
build = "cp310-* cp311-* cp312-*"  # Only build Python 3.10-3.12 wheels
skip = ["pp*", "*musllinux*"]  # disable PyPy and musl-based wheels
test-requires = "pytest pyvista scipy meshio"
test-command = "pytest {project}/tests -v"

[tool.cibuildwheel.linux]
manylinux-x86_64-image = "manylinux_2_28"
before-all = "dnf install -y gmp-devel libXi-devel libXcursor-devel libXinerama-devel libXrandr-devel"
before-build = "pip install cmake==3.29.0"
environment = "USE_MAVX='true'"
environment-pass = ["USE_MAVX"]

[tool.cibuildwheel.macos]
before-build = "pip install cmake==3.29.0"

# pip install delvewheel &&
[tool.cibuildwheel.windows]
before-build = "pip install cmake==3.29.0 delvewheel && python -c \"import os; file_path = 'build/CMakeCache.txt'; os.remove(file_path) if os.path.exists(file_path) else None\""
repair-wheel-command = "python -c \"import shutil, os; shutil.copy(os.path.join(os.getenv('GMP_LIB'), '..', 'bin', 'mpir.dll'), '.')\" && delvewheel repair -w {dest_dir} {wheel} --add-path ."


[tool.blackdoc]
# From https://numpydoc.readthedocs.io/en/latest/format.html
# Extended discussion: https://github.com/pyvista/pyvista/pull/4129
# The length of docstring lines should be kept to 75 characters to facilitate
# reading the docstrings in text terminals.
line-length = 75

[tool.pydocstyle]
match = '(?!coverage).*.py'
convention = "numpy"
add-ignore = ["D404"]

[tool.mypy]
ignore_missing_imports = true
disallow_any_generics = true
pretty = true
show_error_context = true
warn_unused_ignores = true
plugins = ['numpy.typing.mypy_plugin','npt_promote']

[tool.numpydoc_validation]
checks = [
    "all",  # all but the following:
    "GL01",  # Contradicts numpydoc examples
    "GL02",  # Permit a blank line after the end of our docstring
    "GL03",  # Considering enforcing
    "GL06",  # Found unknown section
    "GL07",  # "Sections are in the wrong order. Correct order is: {correct_sections}",
    "GL09",  # Deprecation warning should precede extended summary (check broken)
    "SA01",  # Not all docstrings need a see also
    "SA04",  # See also section does not need descriptions
    "SS05",  # Appears to be broken.
    "ES01",  # Not all docstrings need an extend summary.
    "EX01",  # Examples: Will eventually enforce
    "YD01",  # Yields: No plan to enforce
]

[tool.ruff]
exclude = [
    '.git',
    '__pycache__',
    'build',
    'dist',
]
line-length = 100
indent-width = 4
target-version = 'py38'

[tool.ruff.lint]
external = ["E131", "D102", "D105"]
ignore = [
    # whitespace before ':'
    "E203",
    # line break before binary operator
    # "W503",
    # line length too long
    "E501",
    # do not assign a lambda expression, use a def
    "E731",
    # too many leading '#' for block comment
    "E266",
    # ambiguous variable name
    "E741",
    # module level import not at top of file
    "E402",
    # Quotes (temporary)
    "Q0",
    # bare excepts (temporary)
    # "B001", "E722",
    "E722",
    # we already check black
    # "BLK100",
    # 'from module import *' used; unable to detect undefined names
    "F403",
]
fixable = ["ALL"]
unfixable = []
extend-select = [
    "B007",
    "B010",
    "C4",
    "F",
    "FLY",
    "NPY",
    "PGH004",
    "PIE",
    "PT",
    "RSE",
    "RUF005",
    "RUF010",
    "RUF100",
]
