[build-system]
requires = ["setuptools>=61.2", "setuptools_scm[toml]>=7.0"]
build-backend = "setuptools.build_meta"

[project]
name = "pyproject2conda"
authors = [{ name = "William P. Krekelberg", email = "wpk@nist.gov" }]
license = { text = "NIST-PD" }
description = "A script to convert a Python project declared on a pyproject.toml to a conda environment."
# if using markdown
# long_description_content_type = text/markdown
keywords = ["pyproject2conda"]
classifiers = [
    "Development Status :: 2 - Pre-Alpha",
    "License :: Public Domain",
    "Operating System :: OS Independent",
    "Intended Audience :: Science/Research",
    "Programming Language :: Python",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.8",
    "Programming Language :: Python :: 3.9",
    "Programming Language :: Python :: 3.10",
    "Topic :: Scientific/Engineering",
]
dynamic = ["readme", "version"]
requires-python = ">=3.8"
dependencies = [
    "tomli",
    "ruamel.yaml",
    "tomlkit",
    "typer",
    # "rich-click",
    "packaging",
    "typing-extensions; python_version<'3.9'",
] # additional packages

[project.urls]
homepage = "https://github.com/usnistgov/pyproject2conda"
documentation = "https://pages.nist.gov/pyproject2conda/"

[project.optional-dependencies]
all = [
    "rich", #
    "shellingham",
]
test = [
    "pytest", #
    "pytest-xdist",
    "pytest-cov",
    "pytest-sugar",
]
dev-extras = [
    "setuptools-scm", #
    "pytest-accept", # p2c: -p
    "ipython",
    "ipykernel",
    # "nbval",

]
typing-extras = [
    "pytype; python_version < '3.11'", #
    "mypy >= 1.4.1",
    "types-click",
]
typing = [
    "pyproject2conda[typing-extras]", #
    "pyproject2conda[test]",
]
nox = [
    "nox",
    "noxopt", # p2c: -p
    "ruamel.yaml",
]
dev = [
    "pyproject2conda[test]", #
    "pyproject2conda[typing-extras]",
    "pyproject2conda[dev-extras]",
]
tools = [
    "pre-commit", #
    # "cruft",
    "scriv", # p2c: -p
    "nbqa",
    "pyright",
]
dev-complete = [
    "pyproject2conda[dev]", #
    "pyproject2conda[tools]",
    "pyproject2conda[nox]",
]
docs = [
    "ipython", #
    "pyenchant",
    "ghp-import",
    "sphinx >= 5.3.0",
    "sphinx-copybutton",
    "sphinxcontrib-spelling",
    "sphinx-autobuild",
    "myst-nb",
    "sphinx-book-theme",
    "autodocsumm",
    # project specific
    "sphinx-click",
]
# to be parsed with pyproject2conda with --no-base option
dist-pypi = ["twine", "build"]
dist-conda = [
    "anaconda-client", #
    "grayskull",
    "conda-build",
    "conda-verify",
    "boa",
]

[tool.pyproject2conda]
user_config = "config/userconfig.toml"
template_python = "requirements/py{py}-{env}"
template = "requirements/{env}"
# defaults
python = ["3.10"]
channels = ["conda-forge"]
style = ["yaml", "requirements"]
default_envs = [
    "test",
    "typing",
    "docs",
    "dev",
    "dev-complete",
    "dist-conda",
    "dist-pypi"
]

[tool.pyproject2conda.envs.test-extras]
extras = ["test"]

[tool.pyproject2conda.envs.dev-base]
extras = ["dev"]

[[tool.pyproject2conda.overrides]]
envs = ["test-extras", "dist-conda", "dist-pypi"]
base = false

[[tool.pyproject2conda.overrides]]
envs = ["test", "typing", "test-extras"]
python = ["3.8", "3.9", "3.10", "3.11"]

[[tool.pyproject2conda.overrides]]
envs = ["dist-conda"]
style = ["yaml"]

[project.scripts]
pyproject2conda = "pyproject2conda.cli:app"
p2c = "pyproject2conda.cli:app"

## grayskull still messes some things up, but use scripts/recipe-append.sh for this
[tool.setuptools]
zip-safe = true # if using mypy, must be False
include-package-data = true
license-files = ["LICENSE"]

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

## include = []
## exclude = []
[tool.setuptools.dynamic]
readme = { file = [
    "README.md",
    "CHANGELOG.md",
    "LICENSE"
], content-type = "text/markdown" }

[tool.setuptools_scm]
fallback_version = "999"
write_to = "src/pyproject2conda/_version.py"

[tool.aliases]
test = "pytest"

[tool.pytest.ini_options]
addopts = "--doctest-modules --doctest-glob='*.md'"
testpaths = ["tests", "README.md"]

[tool.coverage.report]
exclude_also = ["if TYPE_CHECKING:", "@overload"]
omit = ["*/vendored/*"]
include = ["src/*"]

[tool.isort]
profile = "black"
skip_gitignore = true
known_first_party = ["pyproject2conda"]

[tool.ruff]
fix = true
line-length = 88
target-version = "py38"
select = [
    # pyflakes
    "F",
    # pycodestyle
    "E",
    "W",
    # isort
    "I",
    # pyupgrade
    "UP",
    # pydocstyle
    "D",
    # # flake8-2020
    "YTT",
    # # flake8-bugbear
    # "B",
    # flake8-quotes
    "Q",
    # # pylint
    # "PLE", "PLR", "PLW",
    # # misc lints
    "PIE",
    # # tidy imports
    "TID",
    # # implicit string concatenation
    # "ISC",
    # # type-checking imports
    "TCH",
]
# Allow autofix for all enabled rules (when `--fix`) is provided.
# fixable = ["A", "B", "C", "D", "E", "F", "..."]
unfixable = []
# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".hg",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".pytype",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "venv",
    "tests/",
    "src/pyproject2conda/tests",
]
ignore = [
    # # whitespace before ':' - doesn't work well with black
    # "E203",
    # module level import not at top of file
    "E402",
    # line too long - let black worry about that
    "E501",
    # do not assign a lambda expression, use a def
    "E731",
    # # line break before binary operator
    # "W503",
    # allow black line after docstring
    "D202",
    "D105",
    "D205",
    # this leads to errors with placing titles in module
    # docstrings
    "D400",
    "D401",
    "D415",
    "D102",
    "D103",
    # these are useful, but too many errors
    # due to use of docfiller
    "D417",
    "D107",
    "D203",
    "D212",
    # Allow relative imports
    "TID252",
]
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.per-file-ignores]
"src/pyproject2conda.py" = ["UP006", "UP007"]

[tool.ruff.isort]
known-first-party = ["pyproject2conda"]

[tool.ruff.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

[tool.nbqa.addopts]
ruff = ["--fix", "--extend-ignore=D100,B018"]

[tool.flake8]
docstring-convention = "numpy"
ignore = [
    # # whitespace before ':' - doesn't work well with black
    "E203",
    # module level import not at top of file
    "E402",
    # line too long - let black worry about that
    "E501",
    # do not assign a lambda expression, use a def
    "E731",
    # # line break before binary operator
    "W503",
    # allow black line after docstring
    "D202",
    "D105",
    "D205",
    # this leads to errors with placing titles in module
    # docstrings
    "D400",
    "D401",
    "D415",
    "D102",
    "D103",
    # these are useful, but too many errors
    # due to use of docfiller
    "D417",
    "D107",
    "D203",
    "D212",
]

[tool.scriv]
format = "md"
md_header_level = "2"
new_fragment_template = "file: changelog.d/templates/new_fragment.md.j2"

[tool.commitizen]
use_shortcuts = true

[tool.cruft]

[tool.mypy]
files = ["src/pyproject2conda", "tests"]
show_error_codes = true
warn_unused_ignores = true
warn_return_any = true
warn_unused_configs = true
exclude = [".eggs", ".tox", "doc", "docs", ".nox"]
check_untyped_defs = true
strict = true

[[tool.mypy.overrides]]
ignore_missing_imports = true
module = []

[[tool.mypy.overrides]]
ignore_errors = true
module = []

[tool.pyright]
include = ["src", "tests"]
exclude = [
    "**/__pycache__",
    ".tox/**",
    ".nox/**",
    "**/.mypy_cache",
    "**/_version.py"
]
# extraPaths = ["."]
# TODO: add strict to pyright
# strict = ["src"]
pythonVersion = "3.10"
typeCheckingMode = "basic"
# enable subset of "strict"
reportDuplicateImport = true
reportInvalidStubStatement = true
reportOverlappingOverload = true
reportPropertyTypeMismatch = true
reportUntypedClassDecorator = true
reportUntypedFunctionDecorator = true
reportUntypedNamedTuple = true
reportUnusedImport = true
# disable subset of "basic"
reportGeneralTypeIssues = false
reportMissingModuleSource = false
reportOptionalCall = false
reportOptionalIterable = false
reportOptionalMemberAccess = false
reportOptionalOperand = false
reportOptionalSubscript = false
reportPrivateImportUsage = false
reportUnboundVariable = false

[tool.pytype]
inputs = ["src", "tests"]
