# Part of ozi-core.
# See LICENSE.txt in the project root for details.
[build-system]
requires = [
    'OZI.build[core,pip,uv]>=2.0.6,<2.3.0',
    'PyYAML~=6.0',
]
build-backend = "ozi_build.buildapi"

[project]
version = "1.19.5"
name = "ozi-core"
authors=[{name="Eden Ross Duff MSc", email="help@oziproject.dev"}]
classifiers=[
    "Development Status :: 4 - Beta",
    "Programming Language :: Python :: 3 :: Only",
    "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",
    "Programming Language :: Python :: Implementation :: CPython",
    "Intended Audience :: Other Audience",
    "Natural Language :: English",
    "Typing :: Typed",
    "Environment :: Other Environment",
]
readme="README.rst"
keywords="OZI,mesonbuild"
requires-python=">=3.9, <3.14"
license="Apache-2.0 with LLVM-exception"
description="The OZI Project packaging core library."
dependencies = [
    'GitPython~=3.1',
    'TAP-Producer~=1.5.17',
    'dnspython~=2.7.0',
    'idna~=3.10',
    'meson[ninja]~=1.1,<1.9',
    'ozi-templates==2.24.10',
    'ozi-spec==0.28.4',
    'packaging>=24.1,<26.0',
    'platformdirs~=4.3',
    'prompt-toolkit~=3.0.48',
    'pyparsing~=3.1',
    'reverse-argparse~=2.0',
    'niquests~=3.14.0',
    'spdx-license-list==3.26.0',
    'trove-classifiers==2025.5.9.12',
    'typing-extensions;python_version<="3.11"',
    'types-PyYAML~=6.0',
    'pathvalidate~=3.2.1',
    'webui2==2.5.6',
]


[project.optional-dependencies] # also meson test suite names
# OZI Packaging Dependencies
# continuous integration
generate-locales = ["PyYAML"]
ci   = [
    "tox>4",
    "tox-gh>1.2",
]
# tox -e fix
fix  = ["black>=24.3", "autoflake", "isort"]
# Default meson test setup
dist = [
    "python-semantic-release",
    "sigstore",
    "cibuildwheel",
    "twine",
]
lint = [
    "bandit[toml]",
    "black>=24.3",
    "flake8",
    "isort",
    "mypy",
    "pyright",
    "readme-renderer[md]",
    "Flake8-pyproject",
    "flake8-annotations",
    "flake8-broken-line",
    "flake8-bugbear",
    "flake8-comprehensions",
    "flake8-datetimez",
    "flake8-docstring-checker",
    "flake8-eradicate",
    "flake8-fixme",
    "flake8-leading-blank-lines",
    "flake8-no-pep420",
    "flake8-pyi",
    "flake8-pytest-style",
    "flake8-quotes",
    "flake8-tidy-imports",
    "flake8-type-checking",
]
test = [
    "coverage[toml]",
    "pytest",
    "hypothesis[all]",
    "pytest-asyncio",
    "pytest-cov",
    "pytest-randomly",
    "pytest-tcpclient",
    "pytest-xdist",
]

[project.urls]
Download="https://github.com/OZI-Project/ozi-core/archive/refs/tags/{version}.tar.gz"
Homepage="https://www.oziproject.dev"

[tool.setuptools_scm]
fallback_version = "@VCS_TAG@"
parentdir_prefix_version = "ozi-core-"
tag_regex = "^(?P<prefix>v)?(?P<version>[^\\+]+)(?P<suffix>.*)?$"

[tool.cibuildwheel]
build-frontend = "build[uv]"

[tool.bandit]
exclude_dirs = [
    "venv",
    "meson-private",
    "subprojects",
    "tests",
]
format = "txt"
ignore_nosec = true
verbose = true

[tool.black]
extend-exclude = "(\\.pyi|venv|meson-private|subprojects|_locales.py|web.py)"
line-length = 93

[tool.coverage.report]
exclude_lines = [
    "^.*#\\s*(pragma|PRAGMA)[:\\s]?\\s*(no|NO)\\s*(cover|COVER)",
    "^.*#\\s*(pragma|PRAGMA)[:\\s]?\\s*(defer|DEFER)\\s*(to|TO)\\s*[a-zA-Z0-9_-]*",
    "def __repr__",
    "def __wrapper", # functools.wraps decorated functions
    "(\\.\\.\\.)",
    "@(abc\\.)?abstractmethod",
    "class .*\\bProtocol\\):",
    "if __name__ == .__main__.:",
    "if TYPE_CHECKING:",
    ]
fail_under    = 100.0
show_missing  = true
skip_covered  = true
skip_empty    = true

[tool.coverage.run]
branch         = true
relative_files = true
omit = [
     '*/vendor/*',
     'ozi_core/new/parser.py',
     'ozi_core/new/interactive/__init__.py',
     'ozi_core/new/interactive/validator.py',
     'ozi_core/new/interactive/dialog.py',
     'ozi_core/fix/parser.py',
     'ozi_core/ui/web.py',
]

[tool.flake8]
ban-relative-imports = "parents"
max-line-length = 93
extend-exclude  = [
    "venv",
    "meson-private",
    "vendor",
    "subprojects",
    "build-env-*",
    "build*",
    "*.pyi",
    "_locales.py",
    "web.py",
]
extend-ignore   = "E203,E501,TC007,TC008"
extend-select   = "B950"

[tool.isort]
line_length = 93
profile = "black"
force_single_line = true
skip_glob = ['subprojects/*',]

[tool.mypy]
strict = true
implicit_reexport = true
exclude = [
    "venv",
    "meson-private",
    "subprojects",
    "tests",
    "vendor",
    "web.py",
]

[[tool.mypy.overrides]]
module = ["ozi_core.vendor.*"]
ignore_errors = true

[[tool.mypy.overrides]]
module = ["spdx_license_list.*"]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = ["mesonbuild.*"]
ignore_missing_imports = true

[tool.pyright]
reportMissingTypeStubs = false
exclude = [
    "venv",
    "vendor",
    "meson-private",
    "subprojects",
    "tests",
    "ozi_core/ui/web.py",
]

[tool.pytest.ini_options]
filterwarnings = ["error","ignore:The --rsyncdir command line argument and rsyncdirs config variable are deprecated.:DeprecationWarning"]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
log_cli = true
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
log_cli_format = "%(asctime)s [%(levelname)8s] %(name)s: %(message)s (%(filename)s:%(lineno)s)"
log_cli_level = "INFO"

[tool.ruff]
line-length = 93
extend-exclude = [
    "venv",
    "meson-private",
    "subprojects",
]
select = ["ALL"]
ignore = [
    "A003",
    "ARG",
    "ANN401",
    "TRY003",
    "B028",
    "B905",
    "D1",
    "D2",
    "D101",
    "D4",
    "FLY",
    "FBT",
    "PGH003",
    "PLR",
    "RET",
    "EM",
    "PLW",
    "PTH",
    "RUF009",
    "RUF012",
    "RUF015",
    "RUF200",
    "SIM",
    "T201",
    "TCH002",
    "TCH004",
    "UP",
    "PERF203",
]
# target-version = "@PYTHON_VERSION_DIST@"

[tool.ruff.lint.mccabe]
max-complexity = 6

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

[tool.ruff.isort]
force-single-line = true

[tool.ruff.lint.pycodestyle]
max-line-length = 102

[tool.ruff.lint.flake8-copyright]
author="Eden Ross Duff MSc,"

[tool.ruff.lint.flake8-quotes]
inline-quotes = "single"

[tool.ruff.lint.flake8-type-checking]
strict = true

[tool.semantic_release]
commit_parser                  = "conventional"
major_on_zero                  = true
tag_format                     = "{version}"

[tool.semantic_release.branches."0.x"]
match = "\\A0\\.\\d+\\Z"
prerelease_token = "alpha"
prerelease = false

[tool.semantic_release.branches."1.x"]
match = "\\A1\\.\\d+\\Z"
prerelease_token = "rc"
prerelease = false

[tool.semantic_release.commit_parser_options]
allowed_tags = [
    "build",
    "chore",
    "ci",
    "docs",
    "feat",
    "fix",
    "perf",
    "style",
    "refactor",
    "test",
]
minor_tags = ["feat"]
patch_tags = ["fix", "perf", "build"]

[tool.semantic_release.changelog.default_templates]
changelog_file = "CHANGELOG.md"

[tool.semantic_release.changelog]
exclude_commit_patterns = ["Merge.*"]

[tool.semantic_release.remote]
type = "github"

[tool.semantic_release.publish]
dist_glob_patterns = [
    "*.tar.gz",
    "*.whl",
    "sig/*",
]
upload_to_vcs_release = true

[tool.tox]
legacy_tox_ini = """
[tox]
skipsdist = True
envlist = dist,lint,test,

[gh]
python =
   3.12 = dist,lint,test,
   3.11 = dist,lint,test,
   3.10 = dist,lint,test,

[testenv]
allowlist_externals =
   rm
   pipx
   python
   meson
package = wheel
deps =
     uv
commands_pre =
     python -m uv pip install OZI.build[core,pip,uv]>=2.0.6,<2.3.0
     pipx install --python=python meson
commands =
     meson setup {env_tmp_dir} -Dozi:{env_name}=enabled -Dozi:tox-env-dir={env_dir}
     meson compile -C {env_tmp_dir}
     rm -rf {env_tmp_dir}{/}.gitignore
commands_post =
     {env_python} -m invoke --search-root={env_tmp_dir}{/}subprojects{/}ozi{/}ozi checkpoint --suite={env_name} {posargs}

[testenv:dist]
description = OZI distribution checkpoint

[testenv:lint]
description = OZI format/lint checkpoint

[testenv:test]
description = OZI unit tests checkpoint
commands =
     meson setup {env_tmp_dir} -Dozi:ozi-blastpipe=disabled -Dozi:{env_name}=enabled -Dozi:tox-env-dir={env_dir}
     meson compile -C {env_tmp_dir}
     rm -rf {env_tmp_dir}{/}.gitignore

[testenv:fix]
description = quickly fix minor source issues 
deps = pipx
skip_install = true
commands_pre =
commands =
     pipx run --python {env_python} black -S .
     pipx run --python {env_python} isort .
     pipx run --python {env_python} autoflake -i -r .
     pipx run --python {env_python} ruff check . --fix
commands_post =

[testenv:scm]
description = OZI supply chain management (setuptools_scm)
deps = setuptools_scm[toml]>=8
commands =
     {env_python} -m setuptools_scm {posargs}

[testenv:invoke]
description = OZI invoke task entrypoint, for more info use "tox -e invoke -- --list"
no_package = true
commands_post =
     {env_python} -m invoke --search-root={env_tmp_dir}{/}subprojects{/}ozi{/}ozi {posargs}

"""
