diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 7a22dc75..62821d76 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -1,7 +1,5 @@ # This is a basic workflow to help you get started with Actions - name: Documentation build - # Controls when the action will run. Triggers the workflow on push or pull request # events but only for the master branch on: @@ -9,14 +7,12 @@ on: branches: [ master ] pull_request: branches: [ master ] - # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This workflow contains a single job called "docs" docs: # The type of runner that the job will run on runs-on: ubuntu-latest - # Steps represent a sequence of tasks that will be executed as part of the job steps: - uses: actions/checkout@v6 @@ -29,4 +25,4 @@ jobs: sudo apt-get install -y gcc libcups2-dev python3-dev python3-setuptools && sudo pip install --ignore-installed tox pycups - name: Test doc build - run: tox -e docs + run: tox --conf pyproject.toml -e docs diff --git a/.github/workflows/pythonpackage-windows.yml b/.github/workflows/pythonpackage-windows.yml index 36942ffc..8260373b 100644 --- a/.github/workflows/pythonpackage-windows.yml +++ b/.github/workflows/pythonpackage-windows.yml @@ -1,19 +1,15 @@ name: Python package on Windows - on: push: branches: [ master ] pull_request: branches: [ master ] - jobs: build: - runs-on: windows-latest strategy: matrix: python-version: ['3.11', '3.12', '3.13'] - steps: - uses: actions/checkout@v6 with: @@ -25,7 +21,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest tox tox-gh-actions + pip install flake8 pytest tox tox-gh If (Test-Path .\requirements.txt) { pip install -r .\requirements.txt } - name: Lint with flake8 run: | @@ -35,12 +31,12 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with tox run: | - tox + tox --conf pyproject.toml env: ESCPOS_CAPABILITIES_FILE: D:\a\python-escpos\python-escpos\capabilities-data\dist\capabilities.json - name: Test mypy with tox run: | - tox -e mypy + tox --conf pyproject.toml -e mypy env: ESCPOS_CAPABILITIES_FILE: D:\a\python-escpos\python-escpos\capabilities-data\dist\capabilities.json - name: Upload coverage to Codecov diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 7ce946b4..6632002b 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -1,21 +1,17 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - name: Python package - on: push: branches: [ master ] pull_request: branches: [ master ] - jobs: build: - runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] steps: - uses: actions/checkout@v6 @@ -30,7 +26,7 @@ jobs: sudo apt-get update sudo apt-get install -y graphviz libenchant-2-2 gcc libcups2-dev python3-dev xindy python -m pip install --upgrade pip - pip install flake8 pytest tox tox-gh-actions + pip install flake8 pytest tox tox-gh if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Check sorting of imports uses: isort/isort-action@master @@ -45,12 +41,12 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with tox run: | - tox + tox --conf pyproject.toml env: ESCPOS_CAPABILITIES_FILE: /home/runner/work/python-escpos/python-escpos/capabilities-data/dist/capabilities.json - name: Test mypy with tox run: | - tox -e mypy + tox --conf pyproject.toml -e mypy env: ESCPOS_CAPABILITIES_FILE: /home/runner/work/python-escpos/python-escpos/capabilities-data/dist/capabilities.json - name: Upload coverage to Codecov diff --git a/pyproject.toml b/pyproject.toml index 1eafdb73..88160421 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,30 +1,131 @@ [tool.black] extend-exclude = 'capabilities-data' + [tool.isort] profile = "black" + [tool.pytest.ini_options] minversion = "6.0" addopts = "--doctest-modules --cov escpos --cov-report=xml" -testpaths = [ - "test", - "src", - "src/escpos", - "escpos", -] +testpaths = ["test", "src", "src/escpos", "escpos"] + [[tool.mypy.overrides]] -module = ["pytest", - "jaconv", - "scripttest", - "barcode.*", - "qrcode", - "usb.*", - "cups", - "win32print" - ] +module = [ + "pytest", + "jaconv", + "scripttest", + "barcode.*", + "qrcode", + "usb.*", + "cups", + "win32print", +] ignore_missing_imports = true + +[tool.tox] +requires = ["tox>=4.11"] +envlist = ["3.9", "3.10", "3.11", "3.12", "3.13", "docs", "flake8", "mypy"] + + +[tool.tox.gh.python] +"3.13" = ["3.13"] +"3.12" = ["3.12"] +"3.11" = ["3.11"] +"3.10" = ["3.10"] +"3.9" = ["3.9"] + + +[tool.tox.env_run_base] +deps = [ + "jaconv", + "coverage", + "scripttest", + "mock", + "pytest>=7.4", + "pytest-cov", + "pytest-mock", + "hypothesis>=6.83", + "python-barcode>=0.15.0,<1", +] +extras = ["all"] +commands = [["pytest"]] +passenv = [ + "ESCPOS_CAPABILITIES_PICKLE_DIR", + "ESCPOS_CAPABILITIES_FILE", + "CI", + "TRAVIS", + "TRAVIS_*", + "APPVEYOR", + "APPVEYOR_*", + "CODECOV_*", +] +setenv = { PY_IGNORE_IMPORTMISMATCH = "1" } + + +[tool.tox.env.docs] +base_python = ["python"] +changedir = "doc" +deps = [ + "sphinx>=7.2.3", + "setuptools_scm", + "python-barcode>=0.15.0,<1", + "sphinx-argparse", + "sphinxcontrib-spelling>=8.0.0", + "sphinxcontrib.datatemplates", + "sphinx-autodoc-typehints", + "sphinx_rtd_theme", + "pycups", +] +commands = [ + [ + "sphinx-build", + "-W", + "-b", + "html", + "-d", + "{envtmpdir}/doctrees", + ".", + "{envtmpdir}/html", + ], + [ + "sphinx-build", + "-W", + "-b", + "spelling", + "-d", + "{envtmpdir}/doctrees", + ".", + "{envtmpdir}/spelling", + ], +] + + +[tool.tox.env.flake8] +base_python = ["python"] +deps = ["flake8", "flake8-docstrings"] +commands = [["flake8"]] + + +[tool.tox.env.mypy] +base_python = ["python"] +deps = [ + "mypy", + "types-six", + "types-mock", + "types-PyYAML", + "types-Pillow", + "types-pyserial", + "types-pywin32>=306.0.0.6", + "types-flask", + "hypothesis>=6.83", + "jaconv", +] +commands = [["mypy", "src", "test", "examples"]] + + [tool.coverage.run] branch = true diff --git a/setup.cfg b/setup.cfg index 5a20992e..10b1def9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -78,4 +78,4 @@ all = [flake8] exclude = .git,.venv,.tox,.github,.eggs,__pycache__,doc/conf.py,build,dist,capabilities-data,test,src/escpos/constants.py max-line-length = 120 -extend-ignore = E203, W503 +extend-ignore = E203, W503, D401 diff --git a/tox.ini b/tox.ini deleted file mode 100644 index fa48a3d4..00000000 --- a/tox.ini +++ /dev/null @@ -1,64 +0,0 @@ -[tox] -envlist = py38, py39, py310, py311, py312, py313, docs, flake8 - -[gh-actions] -python = - 2.7: py27 - 3.6: py36 - 3.7: py37 - 3.8: py38 - 3.9: py39 - 3.10: py310 - 3.11: py311 - 3.12: py312 - 3.13: py313 - -[testenv] -deps = jaconv - coverage - scripttest - mock - pytest>=7.4 - pytest-cov - pytest-mock - hypothesis>=6.83 - python-barcode>=0.15.0,<1 -extras = all -commands = pytest -passenv = ESCPOS_CAPABILITIES_PICKLE_DIR, ESCPOS_CAPABILITIES_FILE, CI, TRAVIS, TRAVIS_*, APPVEYOR, APPVEYOR_*, CODECOV_* -setenv = PY_IGNORE_IMPORTMISMATCH=1 - -[testenv:docs] -basepython = python -changedir = doc -deps = sphinx>=7.2.3 - setuptools_scm - python-barcode>=0.15.0,<1 - sphinx-argparse - sphinxcontrib-spelling>=8.0.0 - sphinxcontrib.datatemplates - sphinx-autodoc-typehints - sphinx_rtd_theme - pycups -commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html - sphinx-build -W -b spelling -d {envtmpdir}/doctrees . {envtmpdir}/spelling - -[testenv:flake8] -basepython = python -deps = flake8 - flake8-docstrings -commands = flake8 - -[testenv:mypy] -basepython = python -deps = mypy - types-six - types-mock - types-PyYAML - types-Pillow - types-pyserial - types-pywin32>=306.0.0.6 - types-flask - hypothesis>=6.83 - jaconv -commands = mypy src test examples