[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
package-dir = {"" = "src"}
include-package-data = true

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.dynamic]
version = {attr = "snagrecover.__version__"}
optional-dependencies.gui = {file = ["src/snagfactory/gui-requirements.txt"]}

[project]
name = "snagboot"
dynamic = ["version", "optional-dependencies"]
authors = [
  { name="Romain Gantois", email="romain.gantois@bootlin.com" },
]
description = "Generic recovery and reflashing tool for embedded platforms"
readme = "README.md"
requires-python = ">=3.10"
license = "GPL-2.0-only"
classifiers = [
    "Programming Language :: Python :: 3",
    "Operating System :: POSIX :: Linux",
    "Operating System :: Microsoft :: Windows :: Windows 10",
    "Operating System :: Microsoft :: Windows :: Windows 11"
]
dependencies = [
	"pyyaml >= 6.0",
	"pyusb >= 1.2.1",
	"pyserial >= 3.5",
	"xmodem >= 0.4.6",
	"tftpy >= 0.8.2",
	"crccheck >= 1.3.0",
	"pylibfdt >= 1.7.2.post1",
	"packaging >= 24.2",
	"pyfatfs >= 1.1.0",
]

[project.urls]
"Source Code" = "https://github.com/bootlin/snagboot"

[project.scripts]
snagrecover = "snagrecover.cli:cli"
snagflash = "snagflash.cli:cli"
snagfactory = "snagfactory.gui:gui"

[tool.ruff]
# Enable pycodestyle (`E`), Pyflakes (`F`) codes and flake8-bugbear (`B`) rules
# by default.
# Never enforce: `E501` (line length violations),
#                `E402` (Module level import not at top of file).
# Allow autofix for all enabled rules (when `--fix`) is provided.
# Avoid trying to fix flake8-bugbear (`B`) violations.
# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".git-rewrite",
    ".hg",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".pytype",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "venv",
    "src/snagflash/bmaptools"
]
# Same as Black.
line-length = 88

# Assume Python 3.11.
target-version = "py311"

[tool.ruff.lint]
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W",
	   "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT",
	   "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH",
	   "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP",
	   "YTT"]
ignore = ["E501","E402"]
select = ["E", "F", "B"]
unfixable = ["B"]
mccabe.max-complexity = 10
flake8-quotes.docstring-quotes = "double"
per-file-ignores = {}

[tool.ruff.format]
quote-style = "double"
indent-style = "tab"
skip-magic-trailing-comma = false
