Skip to content

Commit

Permalink
Fix defaults and update build process
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-berchet committed Nov 14, 2024
1 parent 7df9bcc commit 5c69429
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 43 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/run-tox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Run all tox jobs using Python3

on:
pull_request:
push:
branches:
- main
workflow_dispatch:

jobs:
tests:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache APT Packages
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: imagemagick
version: 1.0
execute_install_scripts: true
- name: Run tox
run: |
python -m pip install --upgrade pip setuptools
pip install tox-gh-actions
tox
- name: JUnit Report Action
uses: mikepenz/action-junit-report@v4
if: always() # always run even if the previous step fails
with:
report_paths: 'reports/pytest-*.xml'
- name: Upload test artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: tests-${{ matrix.python-version }}
retention-days: 4
path: |
.tox/py*/tmp
reports
15 changes: 13 additions & 2 deletions diff_pdf_visually/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def pdftopng(sourcepath, destdir, basename, verbosity, dpi):
raise ValueError("destdir not clean: " + repr(destdir))

verbose_run(
(verbosity > VERB_PRINT_CMD),
(verbosity >= VERB_PRINT_CMD),
[
"pdftocairo",
"-png",
Expand Down Expand Up @@ -136,6 +136,17 @@ def pdfdiff_pages(
assert os.path.isfile(a), "file {} must exist".format(a)
assert os.path.isfile(b), "file {} must exist".format(b)

if threshold is None:
threshold = DEFAULT_THRESHOLD
if verbosity is None:
verbosity = DEFAULT_VERBOSITY
if dpi is None:
dpi = DEFAULT_DPI
if num_threads is None:
num_threads = DEFAULT_NUM_THREADS
if max_report_pagenos is None:
max_report_pagenos = MAX_REPORT_PAGENOS

if tempdir == None:
path_context = tempfile.TemporaryDirectory(prefix="diffpdf-")
else:
Expand Down Expand Up @@ -188,7 +199,7 @@ def pdfdiff_pages(
diffpath = p / "diff-{}.png".format(pageno)
logpath = p / "log-{}.txt".format(pageno)
s = imgdiff(
pageapath, pagebpath, diffpath, logpath, (verbosity > VERB_PRINT_CMD)
pageapath, pagebpath, diffpath, logpath, (verbosity >= VERB_PRINT_CMD)
)
if verbosity >= VERB_PERPAGE:
print("- Page {}: significance={}".format(pageno, s))
Expand Down
44 changes: 38 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,45 @@
[project]
name = 'diff-pdf-visually'
description = 'Quickly check whether there is a visible difference between two PDFs, using ImageMagick and pdftocairo.'
authors = [{name = 'Bram Geron', email = '[email protected]'}]
license = {text = 'MIT/Apache-2.0'}
name = "diff-pdf-visually"
description = "Quickly check whether there is a visible difference between two PDFs, using ImageMagick and pdftocairo."
readme = "README.rst"
urls.Homepage = 'https://github.com/bgeron/diff-pdf-visually'
urls.Source = 'https://github.com/bgeron/diff-pdf-visually'
authors = [{name = "Bram Geron", email = "[email protected]"}]
maintainers = [{name = "Bram Geron", email = "[email protected]"}]
license = {text = "MIT/Apache-2.0"}
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
]
dependencies = []
requires-python = ">=3.6"
dynamic = ["version"]

[project.optional-dependencies]
test = [
"coverage",
"pytest",
]

[project.urls]
Homepage = "https://github.com/bgeron/diff-pdf-visually"
Source = "https://github.com/bgeron/diff-pdf-visually"

[project.scripts]
diff-pdf-visually = "diff_pdf_visually.__main__:main"

[tool.setuptools.packages.find]
include = ["diff_pdf_visually*"]

[requires]
python_version = ['3.6', '3.7', '3.8', '3.9', '3.10']

Expand Down
31 changes: 0 additions & 31 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,8 @@
with open('README.rst', 'r', encoding='utf-8') as f:
readme = f.read()

REQUIRES = []

kwargs = {
'name': 'diff-pdf-visually',
'version': version,
'description': '',
'long_description': readme,
'author': 'Bram Geron',
'author_email': '[email protected]',
'maintainer': 'Bram Geron',
'maintainer_email': '[email protected]',
'url': 'https://github.com/bgeron/diff-pdf-visually',
'license': 'MIT/Apache-2.0',
'classifiers': [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
],
'install_requires': REQUIRES,
'tests_require': ['coverage', 'pytest'],
'packages': find_packages(exclude=('tests', 'tests.*')),
'entry_points': {
'console_scripts': ['diff-pdf-visually=diff_pdf_visually.__main__:main'],
},
}

#################### BEGIN USER OVERRIDES ####################
Expand Down
24 changes: 20 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
[tox]
envlist =
py310
py{39,310,311,312}

[testenv]
passenv = *
extras =
test
deps =
coverage
pytest
commands =
python setup.py --quiet clean develop
coverage run --parallel-mode -m pytest
coverage run --parallel-mode -m pytest {posargs}
coverage combine --append
coverage report -m

[testenv:check-packaging]
skip_install = true
deps =
build
twine
commands =
python -m build -o {envtmpdir}/dist
twine check {envtmpdir}/dist/*

[gh-actions]
python =
3.9: py39
3.10: py310, check-packaging
3.11: py311
3.12: py312

0 comments on commit 5c69429

Please sign in to comment.