[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "nibabel"
description = "Access a multitude of neuroimaging data formats"
authors = [{ name = "NiBabel developers", email = "neuroimaging@python.org" }]
maintainers = [{ name = "Christopher Markiewicz" }]
readme = "README.rst"
license = { text = "MIT License" }
requires-python = ">=3.9"
dependencies = [
  "numpy >=1.22",
  "packaging >=20",
  "importlib_resources >=5.12; python_version < '3.12'",
  "typing_extensions >=4.6; python_version < '3.13'",
]
classifiers = [
  "Development Status :: 5 - Production/Stable",
  "Environment :: Console",
  "Intended Audience :: Science/Research",
  "License :: OSI Approved :: MIT License",
  "Operating System :: OS Independent",
  "Programming Language :: Python",
  "Programming Language :: Python :: 3.9",
  "Programming Language :: Python :: 3.10",
  "Programming Language :: Python :: 3.11",
  "Programming Language :: Python :: 3.12",
  "Programming Language :: Python :: 3.13",
  "Topic :: Scientific/Engineering",
]
# Version from setuptools_scm
dynamic = ["version"]

[project.urls]
"Homepage" = "https://nipy.org/nibabel"
"Development" = "https://github.com/nipy/nibabel"

[project.scripts]
nib-conform = "nibabel.cmdline.conform:main"
nib-convert = "nibabel.cmdline.convert:main"
nib-ls = "nibabel.cmdline.ls:main"
nib-dicomfs = "nibabel.cmdline.dicomfs:main"
nib-diff = "nibabel.cmdline.diff:main"
nib-stats = "nibabel.cmdline.stats:main"
nib-nifti-dx = "nibabel.cmdline.nifti_dx:main"
nib-tck2trk = "nibabel.cmdline.tck2trk:main"
nib-trk2tck = "nibabel.cmdline.trk2tck:main"
nib-roi = "nibabel.cmdline.roi:main"
parrec2nii = "nibabel.cmdline.parrec2nii:main"

[project.optional-dependencies]
all = ["nibabel[dicomfs,minc2,spm,zstd]"]
# Features
dicom = ["pydicom >=2.3"]
dicomfs = ["nibabel[dicom]", "pillow"]
minc2 = ["h5py"]
spm = ["scipy"]
zstd = ["pyzstd >= 0.14.3"]
# For doc and test, make easy to use outside of tox
# tox should use these with extras instead of duplicating
doc = [
  "sphinx",
  "matplotlib>=3.5",
  "numpydoc",
  "texext",
  "tomli; python_version < '3.11'",
]
test = [
  "pytest",
  "pytest-doctestplus",
  "pytest-cov",
  "pytest-httpserver",
  "pytest-xdist",
  "coverage>=7.2",
]
# Remaining: Simpler to centralize in tox
dev = ["tox"]
doctest = ["tox"]
style = ["tox"]
typing = ["tox"]

[tool.hatch.build.targets.sdist]
exclude = [
  ".git_archival.txt",
  # Submodules with large files; if we don't want them in the repo...
  "nibabel-data/",
]

[tool.hatch.build.targets.wheel]
packages = ["nibabel"]
exclude = [
  # 56MB test file does not need to be installed everywhere
  "nibabel/nicom/tests/data/4d_multiframe_test.dcm",
]

[tool.hatch.version]
source = "vcs"
tag-pattern = '(?P<version>\d+(?:\.\d+){0,2}[^+]*)(?:\+.*)?$'
raw-options = { version_scheme = "release-branch-semver" }

[tool.hatch.build.hooks.vcs]
version-file = "nibabel/_version.py"
# Old default setuptools_scm template; hatch-vcs currently causes
# a noisy warning if template is missing.
template = '''
# file generated by setuptools_scm
# don't change, don't track in version control
__version__ = version = {version!r}
__version_tuple__ = version_tuple = {version_tuple!r}
'''

[tool.ruff]
line-length = 99
exclude = ["doc", "nibabel/externals", "tools", "version.py", "versioneer.py"]

[tool.ruff.lint]
select = [
    "B",
    "C4",
    "F",
    "FLY",
    "FURB",
    "I",
    "PERF",
    "PGH",
    "PIE",
    "PLE",
    "PT",
    "PYI",
    "Q",
    "RSE",
    "RUF",
    "TCH",
    "UP",
]
ignore = [
    "B006",   # TODO: enable
    "B008",   # TODO: enable
    "B007",
    "B011",
    "B017",   # TODO: enable
    "B018",
    "B020",
    "B023",   # TODO: enable
    "B028",
    "B904",
    "C401",
    "C408",
    "C416",
    "PERF203",
    "PIE790",
    "PT004",  # deprecated
    "PT005",  # deprecated
    "PT007",
    "PT011",
    "PT012",
    "PT017",
    "PT018",
    "PYI024",
    "RUF005",
    "RUF012", # TODO: enable
    "RUF015",
    "RUF017", # TODO: enable
    "UP027",  # deprecated
    "UP038",  # https://github.com/astral-sh/ruff/issues/7871
    # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
    "W191",
    "E111",
    "E114",
    "E117",
    "D206",
    "D300",
    "Q000",
    "Q001",
    "Q002",
    "Q003",
    "COM812",
    "COM819",
    "ISC001",
    "ISC002",
]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
"doc/source/conf.py" = ["F401"]

[tool.ruff.format]
quote-style = "single"

[tool.mypy]
python_version = "3.11"
exclude = [
  "/tests",
]
warn_unreachable = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]

[tool.codespell]
skip = "*/data/*,./nibabel-data"
ignore-words-list = "ans,te,ue,ist,nin,nd,ccompiler,ser"
