################################################################################
#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you under the Apache License, Version 2.0 (the
#  "License"); you may not use this file except in compliance
#  with the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
[build-system]
# Minimum requirements for the build system to execute.
requires = [
    "setuptools>=75.3,<82",
]
build-backend = "backend"
backend-path = ["_build_backend"]

[project]
name = "flink-agents"
version = "0.3.0"

description = "Flink Agents Python API"
license-files = ["LICENSE"]
requires-python = ">=3.10,<3.13"
authors = [
    { name = "Apache Software Foundation", email = "dev@flink.apache.org" },
]

readme = "README.md"
classifiers = [
    'Development Status :: 5 - Production/Stable',
    'Programming Language :: Python :: 3.10',
    'Programming Language :: Python :: 3.11',
    'Programming Language :: Python :: 3.12',
]

dependencies = [
    "pydantic==2.11.4",
    "docstring-parser==0.16",
    "pyyaml==6.0.2",
    "mcp>=1.8.0",
    "setuptools>=75.3,<82",
    "find_libpython",
    "tree-sitter>=0.24,<0.26",
    "tree-sitter-bash>=0.23,<0.26",
    #TODO: Seperate integration dependencies from project
    "ollama==0.6.1",
    "dashscope~=1.24.2",
    "openai>=1.66.3",
    "anthropic>=0.64.0",
    "chromadb==1.0.21",
    "mem0ai>=0.1.43,<2.0.0",
    "onnxruntime<1.24.1;python_version<'3.11'",
]

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
where = [""]
exclude = ["_build_backend*"]

[tool.setuptools.package-data]
"flink_agents.lib" = ["**/*.jar"]
"flink_agents.examples.quickstart" = ["**/*.yaml"]
"flink_agents.examples.quickstart.resources" = ["**/*.txt", "**/*.md"]

# Optional dependencies (dependency groups)
[project.optional-dependencies]
# Development dependencies - includes all tools needed for development
dev = [
    "flink-agents[build]",
    "flink-agents[lint]",
    "flink-agents[test]",
]

# Build dependencies - tools needed for building the package
build = [
    "build",
]

# Test dependencies
test = [
    "pytest==9.0.3",
    "pytest-rerunfailures==16.3",
]

# Lint dependencies
lint = [
    "ruff==0.11.13",
]

[tool.cibuildwheel]
build = ["cp310-*", "cp311-*"]

[tool.cibuildwheel.macos]
archs = ["x86_64", "arm64"]

[tool.cibuildwheel.linux]
archs = ["x86_64"]

# Configure uv workspace (if needed for multi-package projects)
[tool.uv.workspace]
# Currently a single package project, but ready for workspace expansion
members = ["."]

# Configure platform-specific dependency resolution
[tool.uv]
# Configure required environments for platform compatibility
required-environments = [
    "sys_platform == 'darwin'",
    "sys_platform == 'linux'",
    "sys_platform == 'win32'",
]

# setuptools 82.0.0 removed pkg_resources, which breaks apache-beam<2.66.0 build
[tool.uv.extra-build-dependencies]
apache-beam = ["setuptools<82"]

[tool.ruff]
line-length = 88
fix = true

[tool.ruff.lint]
select = [
    "ANN", # flake8-annotations
    "B", # flake8-bugbear
    "C4", # flake8-comprehensions
    "D", # flake8-docstrings
    "E", # pycodestyle
    "EM", # flake8-errmsg
    "F", # pyflakes
    "FA", # flake8-future-annotations
    "FBT001", # flake8-boolean-trap
    "I", # isort
    "ICN", # flake8-import-conventions
    "INT", # flake8-gettext
    "PERF", # perflint
    "PIE", # flake8-pie
    "PT", # flake8-pytest-style
    "PTH", # flake8-use-pathlib
    "PYI", # flake8-pyi
    "RUF", # ruff-specific rules
    "SIM", # flake8-simplify
    "TCH", # flake8-type-checking
    "TD", # flake8-todos
    "TID", # flake8-tidy-imports
    "TRY", # tryceratops
    "UP", # pyupgrade
    "W", # pycodestyle
]

ignore = [
    "D100", # Missing docstring in public module
    "D104", # Missing docstring in public package
    "D105", # Missing docstring in magic method
    "D205", # Missing-blank-line-after-summary
    # ------------------------------------------------------------------
    "ANN401", # Dynamically typed expressions (Any) are disallowed
    "D401", # Relax NumPy docstring convention: first line should be imperative
    "E501", # Line length regulated by formatter
    "FA100", # Future-rewritable-type-annotation, unsafe for Pydantic
    "PT011", # pytest.raises is too broad, set match or use a more specific exception
    "PYI041", # Use float instead of int | float
    "RUF022", # `__all__` is not sorted
    "RUF005", # Consider expression instead of concatenation
    "SIM102", # Use a single `if` statement instead of nested `if` statements
    "SIM108", # Use ternary operator
    "SIM114", # Combine `if` branches
    "TD002", # Missing author in TODO
    "TD003", # Missing issue link on the line following this TODO
    "TID252", # Prefer absolute imports over relative imports
    "TRY003", # Avoid specifying long messages outside the exception class
    "UP006", # Non-pep585-annotation, unsafe for Pydantic
    "UP035", # Deprecated-import, unsafe for Pydantic
]

[tool.ruff.lint.per-file-ignores]
"dependencies.py" = ["ICN001"]
"**/tests/**/*.py" = ["ANN001", "ANN201", "D100", "D101", "D102", "D103", "D107", "B018", "FBT001", "W505"]
"**/e2e_tests/**/*.py" = ["ANN001", "ANN201", "D100", "D101", "D102", "D103", "D107", "B018", "FBT001", "W505"]

[tool.ruff.lint.pycodestyle]
max-doc-length = 88

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

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

[tool.ruff.format]
docstring-code-format = true

[tool.pytest.ini_options]
markers = [
    "integration: tests that require live external services (Ollama, DashScope, OpenAI, Azure, Anthropic, Chroma, mem0). Deselect with -m 'not integration'.",
]
strict_markers = true
