Skip to content

Commit

Permalink
Merge pull request #6237 from hugovk/deprecate-qt5
Browse files Browse the repository at this point in the history
Deprecate support for Qt 5 (PyQt5 and PySide2)
  • Loading branch information
radarhere committed Apr 25, 2022
2 parents 439d197 + 889ceed commit 9490509
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 14 deletions.
8 changes: 3 additions & 5 deletions .ci/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ python3 -m pip install pyroma
python3 -m pip install test-image-results
python3 -m pip install numpy

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

# webp
Expand Down
18 changes: 18 additions & 0 deletions Tests/test_deprecated_imageqt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import warnings

with warnings.catch_warnings(record=True) as w:
# Arrange: cause all warnings to always be triggered
warnings.simplefilter("always")

# Act: trigger a warning with Qt5
from PIL import ImageQt


def test_deprecated():
# Assert
if ImageQt.qt_version in ("5", "side2"):
assert len(w) == 1
assert issubclass(w[0].category, DeprecationWarning)
assert "deprecated" in str(w[0].message)
else:
assert len(w) == 0
8 changes: 7 additions & 1 deletion Tests/test_image_fromqimage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import warnings

import pytest

from PIL import Image, ImageQt
from PIL import Image

with warnings.catch_warnings():
warnings.simplefilter("ignore", category=DeprecationWarning)
from PIL import ImageQt

from .helper import assert_image_equal, hopper

Expand Down
7 changes: 5 additions & 2 deletions Tests/test_imageqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import pytest

from PIL import ImageQt

from .helper import assert_image_similar, hopper

with warnings.catch_warnings() as w:
warnings.simplefilter("ignore", category=DeprecationWarning)
from PIL import ImageQt


pytestmark = pytest.mark.skipif(
not ImageQt.qt_is_installed, reason="Qt bindings are not installed"
)
Expand Down
6 changes: 5 additions & 1 deletion Tests/test_qt_image_qapplication.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import warnings

import pytest

from PIL import ImageQt
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=DeprecationWarning)
from PIL import ImageQt

from .helper import assert_image_equal, assert_image_equal_tofile, hopper

Expand Down
6 changes: 5 additions & 1 deletion Tests/test_qt_image_toqimage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import warnings

import pytest

from PIL import ImageQt
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=DeprecationWarning)
from PIL import ImageQt

from .helper import assert_image_equal, assert_image_equal_tofile, hopper

Expand Down
21 changes: 17 additions & 4 deletions docs/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,33 @@ The stub image plugin ``FitsStubImagePlugin`` has been deprecated and will be re
Pillow 10.0.0 (2023-07-01). FITS images can be read without a handler through
:mod:`~PIL.FitsImagePlugin` instead.

FreeTypeFont.getmask2 fill parameter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. deprecated:: 9.2.0

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

PhotoImage.paste box parameter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. deprecated:: 9.2.0

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

FreeTypeFont.getmask2 fill parameter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PyQt5 and PySide2
~~~~~~~~~~~~~~~~~

.. deprecated:: 9.2.0

The undocumented ``fill`` parameter of :py:meth:`.FreeTypeFont.getmask2` has been
deprecated and will be removed in Pillow 10 (2023-07-01).
`Qt 5 reached end-of-life <https://www.qt.io/blog/qt-5.15-released>`_ on 2020-12-08 for
open-source users (and will reach EOL on 2023-12-08 for commercial licence holders).

Support for PyQt5 and PySide2 has been deprecated from ``ImageQt`` and will be removed
in Pillow 10 (2023-07-01). Upgrade to
`PyQt6 <https://www.riverbankcomputing.com/static/Docs/PyQt6/>`_ or
`PySide6 <https://doc.qt.io/qtforpython/>`_ instead.

Removed features
----------------
Expand Down
8 changes: 8 additions & 0 deletions docs/reference/ImageQt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
The :py:mod:`~PIL.ImageQt` module contains support for creating PyQt6, PySide6, PyQt5
or PySide2 QImage objects from PIL images.

`Qt 5 reached end-of-life <https://www.qt.io/blog/qt-5.15-released>`_ on 2020-12-08 for
open-source users (and will reach EOL on 2023-12-08 for commercial licence holders).

Support for PyQt5 and PySide2 has been deprecated from ``ImageQt`` and will be removed
in Pillow 10 (2023-07-01). Upgrade to
`PyQt6 <https://www.riverbankcomputing.com/static/Docs/PyQt6/>`_ or
`PySide6 <https://doc.qt.io/qtforpython/>`_ instead.

.. versionadded:: 1.1.6

.. py:class:: ImageQt(image)
Expand Down
15 changes: 15 additions & 0 deletions docs/releasenotes/9.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,24 @@ TODO
Deprecations
============

PyQt5 and PySide2
^^^^^^^^^^^^^^^^^

.. deprecated:: 9.2.0

`Qt 5 reached end-of-life <https://www.qt.io/blog/qt-5.15-released>`_ on 2020-12-08 for
open-source users (and will reach EOL on 2023-12-08 for commercial licence holders).

Support for PyQt5 and PySide2 has been deprecated from ``ImageQt`` and will be removed
in Pillow 10 (2023-07-01). Upgrade to
`PyQt6 <https://www.riverbankcomputing.com/static/Docs/PyQt6/>`_ or
`PySide6 <https://doc.qt.io/qtforpython/>`_ instead.

FreeTypeFont.getmask2 fill parameter
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. deprecated:: 9.2.0

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

Expand Down
5 changes: 5 additions & 0 deletions src/PIL/ImageQt.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from io import BytesIO

from . import Image
from ._deprecate import deprecate
from ._util import is_path

qt_versions = [
Expand All @@ -42,9 +43,13 @@
elif qt_module == "PyQt5":
from PyQt5.QtCore import QBuffer, QIODevice
from PyQt5.QtGui import QImage, QPixmap, qRgba

deprecate("Support for PyQt5", 10, "PyQt6 or PySide6")
elif qt_module == "PySide2":
from PySide2.QtCore import QBuffer, QIODevice
from PySide2.QtGui import QImage, QPixmap, qRgba

deprecate("Support for PySide2", 10, "PyQt6 or PySide6")
except (ImportError, RuntimeError):
continue
qt_is_installed = True
Expand Down

0 comments on commit 9490509

Please sign in to comment.