Skip to content

Commit

Permalink
Support Python 3.13 (#1291)
Browse files Browse the repository at this point in the history
* Support Python 3.13

* remove numpy from test/requirements.txt

---------

Co-authored-by: Lucas Cimon <925560+Lucas-C@users.noreply.github.com>
  • Loading branch information
andersonhc and Lucas-C authored Dec 11, 2024
1 parent 9f2ccce commit 1f28448
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 12 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
test:
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
platform: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand All @@ -34,21 +34,21 @@ jobs:
python -m pip install --upgrade pip setuptools wheel
pip install --upgrade . -r test/requirements.txt -r docs/requirements.txt -r contributors/requirements.txt
- name: Statically checking code 🔎
if: matrix.python-version == '3.12' && matrix.platform == 'ubuntu-latest'
if: matrix.python-version == '3.13' && matrix.platform == 'ubuntu-latest'
run: |
pip install --upgrade . -r test/linters-requirements.txt
black --check .
pylint fpdf test tutorial/tuto*.py
bandit -c .banditrc.yml -r contributors/ fpdf/ tutorial/
semgrep scan --config auto --error --strict --exclude-rule=python.lang.security.insecure-hash-function.insecure-hash-function fpdf
- name: Scan current project
if: matrix.python-version == '3.12' && matrix.platform == 'ubuntu-latest'
if: matrix.python-version == '3.13' && matrix.platform == 'ubuntu-latest'
uses: anchore/scan-action@v3
with:
path: "."
fail-build: true
- name: Checking all PDF samples ☑
if: matrix.python-version == '3.12' && matrix.platform == 'ubuntu-latest'
if: matrix.python-version == '3.13' && matrix.platform == 'ubuntu-latest'
run: |
# Using qpdf
find . -name '*.pdf' | xargs -n 1 sh -c 'qpdf --check --password=fpdf2 $0 || exit 255'
Expand All @@ -64,7 +64,7 @@ jobs:
- name: Running tests ☑
env:
CHECK_EXEC_TIME: ${{ matrix.python-version == '3.9' && 'test-enabled' || '' }}
CHECK_RSS_MEMORY: ${{ matrix.python-version == '3.12' && 'test-enabled' || '' }}
CHECK_RSS_MEMORY: ${{ matrix.python-version == '3.13' && 'test-enabled' || '' }}
run: |
# Ensuring there is no `generate=True` left remaining in calls to assert_pdf_equal:
grep -IRF generate=True test/ && exit 1
Expand All @@ -79,12 +79,12 @@ jobs:
# Targetting only a subset of tests because: A) it's faster and B) some tests are dependant on a specific version of fonttools or Pillow
pytest -vv test/barcodes test/drawing test/errors test/image/test_load_image.py test/metadata test/shapes test/signing test/text_region test/utils
- name: Uploading coverage report to codecov.io ☑
if: matrix.python-version == '3.12' && matrix.platform == 'ubuntu-latest'
if: matrix.python-version == '3.13' && matrix.platform == 'ubuntu-latest'
run: bash <(curl -s https://codecov.io/bash)
- name: Generating HTML documentation 🏗️
# As build_contributors_html_page.py can hang due to GitHub rate-limiting,
# we only execute this on master for now. And it should always be executed for one Python version only.
if: github.ref == 'refs/heads/master' && matrix.python-version == '3.12' && matrix.platform == 'ubuntu-latest'
if: github.ref == 'refs/heads/master' && matrix.python-version == '3.13' && matrix.platform == 'ubuntu-latest'
env:
# Needed by contributors/build_contributors_html_page.py:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -101,7 +101,7 @@ jobs:
- name: Deploy documentation 🚀
# GitHub Pages deployment should not be done for all Python versions,
# otherwise commits will conflict on the gh-pages branch:
if: github.ref == 'refs/heads/master' && matrix.python-version == '3.12' && matrix.platform == 'ubuntu-latest'
if: github.ref == 'refs/heads/master' && matrix.python-version == '3.13' && matrix.platform == 'ubuntu-latest'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -118,10 +118,10 @@ jobs:
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Set up Python 3.12 🔧
- name: Set up Python 3.13 🔧
uses: actions/setup-python@v4
with:
python-version: '3.12'
python-version: '3.13'
- name: Building distributions for Pypi 🏗️
id: build
run: |
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
* new optional parameter `border` for table cells: users can define specific borders (left, right, top, bottom) for individual cells - [issue #1192](https://github.com/py-pdf/fpdf2/issues/1192)
* [`FPDF.write_html()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.write_html): now parses `<title>` tags to set the [document title](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.set_title). By default, it is added as PDF metadata, but not rendered in the document body. However, this can be enabled by passing `render_title_tag=True` to `FPDF.write_html()`.
* support for LZWDecode compression [issue #1271](https://github.com/py-pdf/fpdf2/issues/1271)
* Python 3.13 is now officially supported
* support for [page labels](https://py-pdf.github.io/fpdf2/PageLabels.html) and created a [reference table of contents](https://py-pdf.github.io/fpdf2/DocumentOutlineAndTableOfContents.html) implementation
* documentation on how to: [render spreadsheets as PDF tables](https://py-pdf.github.io/fpdf2/RenderingSpreadsheetsAsPDFTables.html)
### Fixed
Expand Down
4 changes: 4 additions & 0 deletions fpdf/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

import copy, decimal, math, re
from collections import OrderedDict

# disable import error temporarily until pylint fixed colections.abc issue with python 3.13
# https://github.com/pylint-dev/pylint/issues/10112
# pylint: disable=import-error
from collections.abc import Sequence
from contextlib import contextmanager
from typing import Optional, NamedTuple, Union
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ classifiers =
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Operating System :: OS Independent
Topic :: Printing
Topic :: Software Development :: Libraries :: Python Modules
Expand Down
Binary file modified test/embed_file_all_optionals.pdf
Binary file not shown.
Binary file modified test/embed_file_self.pdf
Binary file not shown.
Binary file modified test/file_attachment_annotation.pdf
Binary file not shown.
1 change: 0 additions & 1 deletion test/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
camelot-py
endesive
ghostscript # required by camelot-py[base]: https://github.com/camelot-dev/camelot/blob/master/setup.py#L27
numpy<2 # required by opencv-python, required for now to avoid an ImportError: numpy.core.multiarray failed to import, followed by an AttributeError: _ARRAY_API not found when importing cv2
opencv-python # required by camelot-py[base]: https://github.com/camelot-dev/camelot/blob/master/setup.py#L27
pytest
pytest-cov
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

[tox]
envlist = py38, py39, py310, py311, py312
envlist = py38, py39, py310, py311, py312, py313

[gh-actions]
python =
Expand All @@ -16,6 +16,7 @@ python =
3.10: py310
3.11: py311
3.12: py312
3.13: py313

[testenv]
deps = -rtest/requirements.txt
Expand Down

0 comments on commit 1f28448

Please sign in to comment.