Skip to content

Conversation

@andersonhc
Copy link
Collaborator

@andersonhc andersonhc commented Oct 15, 2025

Add Python 3.14 support

Checklist:

  • A unit test is covering the code added / modified by this PR

  • In case of a new feature, docstrings have been added, with also some documentation in the docs/ folder

  • A mention of the change is present in CHANGELOG.md

  • This PR is ready to be merged

By submitting this pull request, I confirm that my contribution is made under the terms of the GNU LGPL 3.0 license.

Comment on lines 130 to 140
# --- Create constraints file ---
CONSTRAINTS_FILE="constraints.txt"
if [[ "${{ matrix.python-version }}" == "3.14" ]]; then
echo "numpy>=2.3.3" > "$CONSTRAINTS_FILE"
echo "Added numpy>=2.3.3 to $CONSTRAINTS_FILE"
else
: > "$CONSTRAINTS_FILE" # create empty file
echo "Created empty $CONSTRAINTS_FILE"
fi
# --- Install dependencies respecting constraints ---
pip install --upgrade . -r test/requirements.txt -c "$CONSTRAINTS_FILE"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why adding numpy>=2.3.3 there?
Why is it needed to introduce a constraints.txt file?

Wouldn't adding numpy>=2.3.3 to test/requirements.txt be enough?

Maybe that's worth an explanatory comment 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fought pip for a day and couldn't find another solution... It was installing 2.3.3 and then downgrading back to numpy 2.2.6. I believe the problem is a dependency downstream from camelot-py.
I added the constraints file on python 3.14 builds only and skipped the camelot table extraction test on 3.14.
When camelot publish a Python 3.14 compatible build we should be OK to remove this.

I'll add comments to have it documented.

@andersonhc
Copy link
Collaborator Author

@Lucas-C
The Windows build of cpython 3.14 is now using zlib-ng instead of the standard zlib
python/cpython#91349
python/cpython#131438

This change alters the output of zlib.compress, which means that our PDF file comparisons no longer match byte-for-byte between platforms.
The generated compressed streams differ even though the decompressed content is identical.

To mitigate this problem for now I:

  • Changed our github workflow to make sure qpdf is used for the Windows tests so we compare uncompressed data
  • There were 3 edge cases remaining because of compressed data embedded on PDF files that qpdf won't decompress - I am skipping on Python 3.14+Windows for now

I believe this deserves more thought and a long term solution, but I'm planning on a new release in the next few weeks and I'd like to have 3.14 wheels published.

@Lucas-C
Copy link
Member

Lucas-C commented Oct 15, 2025

The Windows build of cpython 3.14 is now using zlib-ng instead of the standard zlib python/cpython#91349 python/cpython#131438
[...]
This change alters the output of zlib.compress, which means that our PDF file comparisons no longer match byte-for-byte between platforms. > I believe this deserves more thought and a long term solution, but I'm planning on a new release in the next few weeks and I'd like to have 3.14 wheels published.

Alright.

So far we did not bother running tests with qpdf under Windows,
I just wonder if it's worth the hassle, and to introduce minor kludges add this?

Just some humble questioning, I approved the PR and I'm fine if you decide to merge it with those additions 🙂

@andersonhc andersonhc merged commit fe7af3e into py-pdf:master Oct 16, 2025
23 checks passed
@andersonhc andersonhc deleted the python314 branch October 19, 2025 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants