Skip to content

Commit 9490509

Browse files
authored
Merge pull request #6237 from hugovk/deprecate-qt5
Deprecate support for Qt 5 (PyQt5 and PySide2)
2 parents 439d197 + 889ceed commit 9490509

File tree

10 files changed

+88
-14
lines changed

10 files changed

+88
-14
lines changed

.ci/install.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@ python3 -m pip install pyroma
3434
python3 -m pip install test-image-results
3535
python3 -m pip install numpy
3636

37-
# PyQt5 doesn't support PyPy3
37+
# PyQt6 doesn't support PyPy3
3838
if [[ $GHA_PYTHON_VERSION == 3.* ]]; then
39-
# arm64, ppc64le, s390x CPUs:
40-
# "ERROR: Could not find a version that satisfies the requirement pyqt5"
41-
sudo apt-get -qq install libxcb-xinerama0 pyqt5-dev-tools
42-
python3 -m pip install pyqt5
39+
sudo apt-get -qq install libegl1 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxkbcommon-x11-0
40+
python3 -m pip install pyqt6
4341
fi
4442

4543
# webp

Tests/test_deprecated_imageqt.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import warnings
2+
3+
with warnings.catch_warnings(record=True) as w:
4+
# Arrange: cause all warnings to always be triggered
5+
warnings.simplefilter("always")
6+
7+
# Act: trigger a warning with Qt5
8+
from PIL import ImageQt
9+
10+
11+
def test_deprecated():
12+
# Assert
13+
if ImageQt.qt_version in ("5", "side2"):
14+
assert len(w) == 1
15+
assert issubclass(w[0].category, DeprecationWarning)
16+
assert "deprecated" in str(w[0].message)
17+
else:
18+
assert len(w) == 0

Tests/test_image_fromqimage.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
import warnings
2+
13
import pytest
24

3-
from PIL import Image, ImageQt
5+
from PIL import Image
6+
7+
with warnings.catch_warnings():
8+
warnings.simplefilter("ignore", category=DeprecationWarning)
9+
from PIL import ImageQt
410

511
from .helper import assert_image_equal, hopper
612

Tests/test_imageqt.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
import pytest
44

5-
from PIL import ImageQt
6-
75
from .helper import assert_image_similar, hopper
86

7+
with warnings.catch_warnings() as w:
8+
warnings.simplefilter("ignore", category=DeprecationWarning)
9+
from PIL import ImageQt
10+
11+
912
pytestmark = pytest.mark.skipif(
1013
not ImageQt.qt_is_installed, reason="Qt bindings are not installed"
1114
)

Tests/test_qt_image_qapplication.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import warnings
2+
13
import pytest
24

3-
from PIL import ImageQt
5+
with warnings.catch_warnings():
6+
warnings.simplefilter("ignore", category=DeprecationWarning)
7+
from PIL import ImageQt
48

59
from .helper import assert_image_equal, assert_image_equal_tofile, hopper
610

Tests/test_qt_image_toqimage.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import warnings
2+
13
import pytest
24

3-
from PIL import ImageQt
5+
with warnings.catch_warnings():
6+
warnings.simplefilter("ignore", category=DeprecationWarning)
7+
from PIL import ImageQt
48

59
from .helper import assert_image_equal, assert_image_equal_tofile, hopper
610

docs/deprecations.rst

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,33 @@ The stub image plugin ``FitsStubImagePlugin`` has been deprecated and will be re
142142
Pillow 10.0.0 (2023-07-01). FITS images can be read without a handler through
143143
:mod:`~PIL.FitsImagePlugin` instead.
144144

145+
FreeTypeFont.getmask2 fill parameter
146+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
147+
148+
.. deprecated:: 9.2.0
149+
150+
The undocumented ``fill`` parameter of :py:meth:`.FreeTypeFont.getmask2` has been
151+
deprecated and will be removed in Pillow 10 (2023-07-01).
152+
145153
PhotoImage.paste box parameter
146154
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
147155

148156
.. deprecated:: 9.2.0
149157

150158
The ``box`` parameter is unused. It will be removed in Pillow 10.0.0 (2023-07-01).
151159

152-
FreeTypeFont.getmask2 fill parameter
153-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
160+
PyQt5 and PySide2
161+
~~~~~~~~~~~~~~~~~
154162

155163
.. deprecated:: 9.2.0
156164

157-
The undocumented ``fill`` parameter of :py:meth:`.FreeTypeFont.getmask2` has been
158-
deprecated and will be removed in Pillow 10 (2023-07-01).
165+
`Qt 5 reached end-of-life <https://www.qt.io/blog/qt-5.15-released>`_ on 2020-12-08 for
166+
open-source users (and will reach EOL on 2023-12-08 for commercial licence holders).
167+
168+
Support for PyQt5 and PySide2 has been deprecated from ``ImageQt`` and will be removed
169+
in Pillow 10 (2023-07-01). Upgrade to
170+
`PyQt6 <https://www.riverbankcomputing.com/static/Docs/PyQt6/>`_ or
171+
`PySide6 <https://doc.qt.io/qtforpython/>`_ instead.
159172

160173
Removed features
161174
----------------

docs/reference/ImageQt.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
The :py:mod:`~PIL.ImageQt` module contains support for creating PyQt6, PySide6, PyQt5
88
or PySide2 QImage objects from PIL images.
99

10+
`Qt 5 reached end-of-life <https://www.qt.io/blog/qt-5.15-released>`_ on 2020-12-08 for
11+
open-source users (and will reach EOL on 2023-12-08 for commercial licence holders).
12+
13+
Support for PyQt5 and PySide2 has been deprecated from ``ImageQt`` and will be removed
14+
in Pillow 10 (2023-07-01). Upgrade to
15+
`PyQt6 <https://www.riverbankcomputing.com/static/Docs/PyQt6/>`_ or
16+
`PySide6 <https://doc.qt.io/qtforpython/>`_ instead.
17+
1018
.. versionadded:: 1.1.6
1119

1220
.. py:class:: ImageQt(image)

docs/releasenotes/9.2.0.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,24 @@ TODO
1010
Deprecations
1111
============
1212

13+
PyQt5 and PySide2
14+
^^^^^^^^^^^^^^^^^
15+
16+
.. deprecated:: 9.2.0
17+
18+
`Qt 5 reached end-of-life <https://www.qt.io/blog/qt-5.15-released>`_ on 2020-12-08 for
19+
open-source users (and will reach EOL on 2023-12-08 for commercial licence holders).
20+
21+
Support for PyQt5 and PySide2 has been deprecated from ``ImageQt`` and will be removed
22+
in Pillow 10 (2023-07-01). Upgrade to
23+
`PyQt6 <https://www.riverbankcomputing.com/static/Docs/PyQt6/>`_ or
24+
`PySide6 <https://doc.qt.io/qtforpython/>`_ instead.
25+
1326
FreeTypeFont.getmask2 fill parameter
1427
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1528

29+
.. deprecated:: 9.2.0
30+
1631
The undocumented ``fill`` parameter of :py:meth:`.FreeTypeFont.getmask2`
1732
has been deprecated and will be removed in Pillow 10 (2023-07-01).
1833

src/PIL/ImageQt.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from io import BytesIO
2121

2222
from . import Image
23+
from ._deprecate import deprecate
2324
from ._util import is_path
2425

2526
qt_versions = [
@@ -42,9 +43,13 @@
4243
elif qt_module == "PyQt5":
4344
from PyQt5.QtCore import QBuffer, QIODevice
4445
from PyQt5.QtGui import QImage, QPixmap, qRgba
46+
47+
deprecate("Support for PyQt5", 10, "PyQt6 or PySide6")
4548
elif qt_module == "PySide2":
4649
from PySide2.QtCore import QBuffer, QIODevice
4750
from PySide2.QtGui import QImage, QPixmap, qRgba
51+
52+
deprecate("Support for PySide2", 10, "PyQt6 or PySide6")
4853
except (ImportError, RuntimeError):
4954
continue
5055
qt_is_installed = True

0 commit comments

Comments
 (0)