[metadata]
name = comictagger
description = A cross-platform GUI/CLI app for writing metadata to comic archives
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/comictagger/comictagger
author = ComicTagger team
author_email = comictagger@gmail.com
license = Apache-2.0
license_files = LICENSE
classifiers =
    Development Status :: 4 - Beta
    Environment :: Console
    Environment :: MacOS X
    Environment :: Win32 (MS Windows)
    Environment :: X11 Applications :: Qt
    Intended Audience :: End Users/Desktop
    License :: OSI Approved :: Apache Software License
    Natural Language :: English
    Operating System :: OS Independent
    Programming Language :: Python :: 3
    Programming Language :: Python :: 3 :: Only
    Topic :: Multimedia :: Graphics
    Topic :: Other/Nonlisted Topic
    Topic :: Utilities
keywords =
    comictagger
    comics
    comic
    metadata
    tagging
    tagger

[options]
packages = find:
install_requires =
    appdirs==1.4.4
    beautifulsoup4>=4.1
    chardet>=5.1.0,<6
    comicfn2dict>=0.2.1
    importlib-metadata>=3.3.0
    isocodes>=2023.11.26
    natsort>=8.1.0
    packaging>=20
    pathvalidate
    pillow>=9.1.0
    pyrate-limiter>=2.6,<3
    pyyaml
    rapidfuzz>=2.12.0
    requests==2.*
    settngs==0.10.4
    text2digits
    typing-extensions>=4.3.0
    wordninja
python_requires = >=3.9

[options.packages.find]
exclude =
    tests*
    testing*

[options.entry_points]
console_scripts = comictagger=comictaggerlib.main:main
comicapi.archiver =
    zip = comicapi.archivers.zip:ZipArchiver
    sevenzip = comicapi.archivers.sevenzip:SevenZipArchiver
    rar = comicapi.archivers.rar:RarArchiver
    folder = comicapi.archivers.folder:FolderArchiver
comicapi.tags =
    cr = comicapi.tags.comicrack:ComicRack
comictagger.talker =
    comicvine = comictalker.talkers.comicvine:ComicVineTalker
pyinstaller40 =
    hook-dirs = comictaggerlib.__pyinstaller:get_hook_dirs

[options.extras_require]
7z =
    py7zr
all =
    PyQt5
    PyQtWebEngine
    comicinfoxml==0.4.*
    gcd-talker>0.1.0
    metron-talker>0.1.5
    pillow-avif-plugin>=1.4.1
    pillow-jxl-plugin>=1.2.5
    py7zr
    rarfile>=4.0
    pyicu;sys_platform == 'linux' or sys_platform == 'darwin'
archived_tags =
    ct-archived-tags
avif =
    pillow-avif-plugin>=1.4.1
cbr =
    rarfile>=4.0
cix =
    comicinfoxml==0.4.*
gcd =
    gcd-talker>0.1.0
gui =
    PyQt5
icu =
    pyicu;sys_platform == 'linux' or sys_platform == 'darwin'
jxl =
    pillow-jxl-plugin>=1.2.5
metron =
    metron-talker>0.1.5
pyinstaller =
    PyQt5
    PyQtWebEngine
    comicinfoxml==0.4.*
    pillow-avif-plugin>=1.4.1
    pillow-jxl-plugin>=1.2.5
    py7zr
    rarfile>=4.0
    pyicu;sys_platform == 'linux' or sys_platform == 'darwin'
qtw =
    PyQt5
    PyQtWebEngine

[options.package_data]
comicapi =
    data/*
comictaggerlib =
    ui/*
    graphics/*

[tox:tox]
env_list =
    format
    py3.9-{none,gui,7z,cbr,icu,all}
minversion = 4.4.12
basepython = {env:tox_python:python3.9}

[testenv]
description = run the tests with pytest
package = wheel
deps =
    pytest>=7
extras =
    7z: 7Z
    cbr: CBR
    gui: GUI
    icu: ICU
    all: all
commands =
    python -m pytest {tty:--color=yes} {posargs}
    icu,all: python -c 'import importlib,platform; importlib.import_module("icu") if platform.system() != "Windows" else ...' # Sanity check for icu

[m1env]
description = run the tests with pytest
package = wheel
deps =
    pytest>=7
    icu,all: pyicu-binary
extras =
    7z: 7Z
    cbr: CBR
    gui: GUI
    all: 7Z,CBR,GUI
commands =
    python -m pytest {tty:--color=yes} {posargs}

[testenv:py3.9-{icu,all}]
base = {env:tox_env:testenv}

[testenv:format]
labels =
    build
deps =
    black>=22
    isort>=5.10
    setup-cfg-fmt
    autoflake
    pyupgrade
commands =
    -python ./build-tools/generate_settngs.py
    -setup-cfg-fmt setup.cfg
    -python -m autoflake -i --remove-all-unused-imports --ignore-init-module-imports -r comictaggerlib comicapi comictalker testing tests build-tools
    -python -m isort --af --add-import 'from __future__ import annotations' .
    -python -m black .

[testenv:lint]
skip_install = true
depends = format
deps =
    flake8
    flake8-black
    flake8-encodings
    flake8-isort
    mypy
    types-setuptools
    types-requests
commands =
    python -m flake8 .
    -python -m mypy --ignore-missing-imports comicapi comictaggerlib comictalker

[testenv:clean]
description = Clean development outputs
labels =
    release
    build
depends =
    format
    lint
skip_install = true
commands =
    -python -c 'import shutil,pathlib; \
    shutil.rmtree("./build/", ignore_errors=True); \
    shutil.rmtree("./dist/", ignore_errors=True); \
    pathlib.Path("./comictaggerlib/ctversion.py").unlink(missing_ok=True); \
    pathlib.Path("comictagger.spec").unlink(missing_ok=True)'

[testenv:wheel]
description = Generate wheel and tar.gz
labels =
    release
    build
depends = clean
skip_install = true
deps =
    build
commands =
    python -m build

[testenv:pypi-upload]
description = Upload wheel to PyPi
platform = linux
labels =
    release
skip_install = true
depends = wheel
deps =
    twine
    id~=1.0
    keyrings.alt
passenv =
    GITHUB_*
    ACTIONS_*
    CI
setenv =
    TWINE_NON_INTERACTIVE=true
commands =
    python {tox_root}/build-tools/oidc-exchange.py
    python -m twine upload dist/*.whl dist/*.tar.gz

[testenv:pyinstaller]
description = Generate pyinstaller executable
labels =
    build
    release
base = {env:tox_env:testenv}
depends =
    clean
deps =
    pyinstaller>=5.6.2,!=6.0.0
extras =
    pyinstaller
commands =
    pyrcc5 comictaggerlib/graphics/graphics.qrc -o comictaggerlib/graphics/resources.py
    pyinstaller -y build-tools/comictagger.spec
    python -c 'import importlib,platform; importlib.import_module("icu") if platform.system() != "Windows" else ...' # Sanity check for icu

[testenv:appimage]
description = Generate appimage executable
skip_install = true
platform = linux
base = {env:tox_env:testenv}
labels =
    release
    build
depends =
    clean
    pyinstaller
deps =
    requests
allowlist_externals =
    {tox_root}/build/appimagetool-x86_64.AppImage
change_dir = {tox_root}/dist/binary
commands_pre =
    -python -c 'import shutil; shutil.rmtree("{tox_root}/build/", ignore_errors=True)'
    python {tox_root}/build-tools/get_appimage.py {tox_root}/build/appimagetool-x86_64.AppImage
commands =
    python -c 'import shutil,pathlib; shutil.copytree("{tox_root}/dist/comictagger/", "{tox_root}/build/appimage", dirs_exist_ok=True); \
    shutil.copy("{tox_root}/comictaggerlib/graphics/app.png", "{tox_root}/build/appimage/app.png"); \
    pathlib.Path("{tox_root}/build/appimage/AppRun").symlink_to("comictagger"); \
    pathlib.Path("{tox_root}/build/appimage/AppRun.desktop").write_text( \
    pathlib.Path("{tox_root}/build-tools/ComicTagger.desktop").read_text() \
    .replace("/usr/local/share/comictagger/app.png", "app"))'
    {tox_root}/build/appimagetool-x86_64.AppImage {tox_root}/build/appimage

[testenv:zip_artifacts]
description = Zip release artifacts
labels =
    release
    build
depends =
    wheel
    pyinstaller
    appimage
deps =
    dmgbuild
commands =
    python ./build-tools/zip_artifacts.py

[testenv:venv]
envdir = venv
deps =
    flake8
    flake8-black
    flake8-encodings
    flake8-isort
    mypy
    types-setuptools
    types-requests
    build
    pyinstaller>=5.6.2,!=6.0.0

[flake8]
max-line-length = 120
extend-ignore = E203, E501, A003, A005, T202, E701
extend-exclude = venv, scripts, build, dist, comictaggerlib/ctversion.py, comictaggerlib/graphics/resources.py
per-file-ignores =
    comictaggerlib/cli.py: T20
    build-tools/generate_settngs.py: T20
    build-tools/oidc-exchange.py: T20
    tests/*: L

[mypy]
exclude = comictaggerlib/graphics/resources.py
check_untyped_defs = true
disallow_any_generics = true
disallow_incomplete_defs = true
disallow_untyped_defs = true
warn_redundant_casts = true
warn_unused_ignores = true
disable_error_code = import-untyped

[mypy-testing.*]
disallow_untyped_defs = false
disallow_incomplete_defs = false
check_untyped_defs = false

[mypy-tests.*]
disallow_untyped_defs = false
disallow_incomplete_defs = false
check_untyped_defs = false

[mypy-comictaggerlib.graphics.resources]
ignore_errors = True