[project]
name = "django-otp"
version = "1.6.1"
description = "A pluggable framework for adding two-factor authentication to Django using one-time passwords."
readme = "README.rst"
requires-python = ">=3.7"
license = "Unlicense"
authors = [
    { name = "Peter Sagerson", email = "psagers@ignorare.net" },
]
classifiers = [
    "Development Status :: 5 - Production/Stable",
    "Framework :: Django",
    "Framework :: Django :: 4.2",
    "Framework :: Django :: 5.1",
    "Framework :: Django :: 5.2",
    "Intended Audience :: Developers",
    "License :: OSI Approved :: The Unlicense (Unlicense)",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3 :: Only",
    "Topic :: Security",
    "Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
    "django >= 4.2",
]

[project.optional-dependencies]
segno = [
    "segno",
]
qrcode = [
    "qrcode",
]

[project.urls]
Homepage = "https://github.com/django-otp/django-otp"
Documentation = "https://django-otp-official.readthedocs.io/"


#
# Development
#

[tool.hatch.envs.default]
features = [
    "segno",
    "qrcode",
]
dependencies = [
    "black ~= 25.1",
    "bumpversion ~= 0.6.0",
    "coverage ~= 7.8.0",
    "flake8 ~= 7.2.0",
    "freezegun ~= 1.5.1",
    "isort ~= 6.0.1",
    "psycopg2",
    "tomli >= 2.2.1; python_version < '3.11'",
]

[tool.hatch.envs.default.env-vars]
PYTHONPATH = "test"
DJANGO_SETTINGS_MODULE = "test_project.settings"

[tool.hatch.envs.default.scripts]
manage = "python -m django {args}"

lint = [
    "flake8 src",
    "isort --check src",
    "black --check src",
]
fix = [
    "isort src",
    "black src",
]

test = "python -s -m django test {args:django_otp}"
check = ["lint", "test"]

warn = "python -Wd -s -m django test {args:django_otp}"
cov = [
    "coverage run -m django test {args:django_otp}",
    "coverage report",
]


[tool.hatch.envs.test.scripts]
run = "test"

[tool.hatch.envs.test.overrides]
matrix.django.dependencies = [
    { value = "django ~= 4.2.0", if = ["4.2"] },
    { value = "django ~= 5.1.0", if = ["5.1"] },
    { value = "django ~= 5.2.0", if = ["5.2"] },
]
matrix.mode.scripts = [
    { key = "run", value = "lint", if = ["lint"] },
    { key = "run", value = "cov", if = ["coverage"] },
]

[[tool.hatch.envs.test.matrix]]
mode = ["lint"]

# WARNING: When you update the Python versions, make sure to update
# .github/workflows/* as well.
[[tool.hatch.envs.test.matrix]]
python = ["3.9"]
django = ["4.2"]

[[tool.hatch.envs.test.matrix]]
python = ["3.11"]
django = ["5.1"]

[[tool.hatch.envs.test.matrix]]
python = ["3.13"]
django = ["5.2"]

[[tool.hatch.envs.test.matrix]]
mode = ["coverage"]


[tool.hatch.envs.docs]
template = "docs"
dependencies = [
    "sphinx"
]

[tool.hatch.envs.docs.scripts]
make = "command make -C docs {args:html}"
open = "command xdg-open docs/build/html/index.html"


#
# Build
#

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["src/django_otp"]

[tool.hatch.build.targets.sdist]
include = [
    "/src",
    "/docs",
    "/test",
    "/CHANGES.rst",
    "/CONTRIBUTING.rst",
]


#
# Other tools
#

[tool.isort]
profile = "black"
force_sort_within_sections = true

sections = ["FUTURE", "STDLIB", "THIRDPARTY", "DJANGO", "FIRSTPARTY", "LOCALFOLDER"]
known_django = ["django"]
skip_glob = ["**/migrations/*.py"]

[tool.black]
skip-string-normalization = true
exclude = 'migrations/.*\.py'
