[tox]
envlist =
    py{35,36,37,38}
    build
    clean
    docs
    fmt
    lint
    readme
    release

[testenv]
deps =
    .[test]
commands =
    pytest

[testenv:build]
basepython = python3.8
deps =
    twine
    wheel
commands =
    python setup.py sdist bdist_wheel
    twine check dist/*.whl
    twine check dist/*.tar.gz
    python setup.py clean --all

[testenv:clean]
deps =
    cleanpy
commands =
    cleanpy --all --exclude-envs .

[testenv:docs]
basepython = python3.8
deps =
    -r{toxinidir}/requirements/docs_requirements.txt
commands =
    python setup.py build_sphinx --source-dir=docs/ --build-dir=docs/_build --all-files

[testenv:fmt]
basepython = python3.8
deps =
    autoflake
    black
    isort[pyproject]
commands =
    black setup.py test ghscard
    autoflake --in-place --recursive --remove-all-unused-imports --ignore-init-module-imports .
    isort --apply --recursive

[testenv:lint]
basepython = python3.7
deps =
    codespell
    mypy>=0.761
    pylama
    pytype
commands =
    python setup.py check
    mypy ghscard setup.py --ignore-missing-imports --show-error-context --show-error-codes --python-version 3.5
    pytype --keep-going --jobs 2 --disable import-error ghscard
    codespell ghscard src docs examples test -q2 --check-filenames --skip "test/html/*"
    pylama

[testenv:readme]
changedir = docs
deps =
    readmemaker>=1.0.0
commands =
    python make_readme.py

[testenv:release]
deps =
    releasecmd>=0.3.1,<1
commands =
    python setup.py release --sign {posargs}
