Drop support for EOL PyQt4 and PySide

This commit is contained in:
Hugo 2019-09-26 21:38:19 +03:00
parent cc16025e23
commit f0a87e25a4
5 changed files with 17 additions and 67 deletions

View File

@ -35,10 +35,6 @@ class PillowQPixmapTestCase(PillowQtTestCase):
try:
if ImageQt.qt_version == "5":
from PyQt5.QtGui import QGuiApplication
elif ImageQt.qt_version == "4":
from PyQt4.QtGui import QGuiApplication
elif ImageQt.qt_version == "side":
from PySide.QtGui import QGuiApplication
elif ImageQt.qt_version == "side2":
from PySide2.QtGui import QGuiApplication
except ImportError:
@ -59,10 +55,6 @@ class TestImageQt(PillowQtTestCase, PillowTestCase):
# equivalent to an unsigned int.
if ImageQt.qt_version == "5":
from PyQt5.QtGui import qRgb
elif ImageQt.qt_version == "4":
from PyQt4.QtGui import qRgb
elif ImageQt.qt_version == "side":
from PySide.QtGui import qRgb
elif ImageQt.qt_version == "side2":
from PySide2.QtGui import qRgb

View File

@ -9,25 +9,9 @@ if ImageQt.qt_is_installed:
try:
from PyQt5 import QtGui
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QApplication
QT_VERSION = 5
except (ImportError, RuntimeError):
try:
from PySide2 import QtGui
from PySide2.QtWidgets import QWidget, QHBoxLayout, QLabel, QApplication
QT_VERSION = 5
except (ImportError, RuntimeError):
try:
from PyQt4 import QtGui
from PyQt4.QtGui import QWidget, QHBoxLayout, QLabel, QApplication
QT_VERSION = 4
except (ImportError, RuntimeError):
from PySide import QtGui
from PySide.QtGui import QWidget, QHBoxLayout, QLabel, QApplication
QT_VERSION = 4
from PySide2 import QtGui
from PySide2.QtWidgets import QWidget, QHBoxLayout, QLabel, QApplication
class TestToQImage(PillowQtTestCase, PillowTestCase):
@ -60,10 +44,6 @@ class TestToQImage(PillowQtTestCase, PillowTestCase):
# Check that it actually worked.
reloaded = Image.open(tempfile)
# Gray images appear to come back in palette mode.
# They're roughly equivalent
if QT_VERSION == 4 and mode == "L":
src = src.convert("P")
self.assert_image_equal(reloaded, src)
def test_segfault(self):

View File

@ -45,17 +45,6 @@ Python 2.7 reaches end-of-life on 2020-01-01.
Pillow 7.0.0 will be released on 2020-01-01 and will drop support for Python 2.7, making
Pillow 6.x the last series to support Python 2.
PyQt4 and PySide
~~~~~~~~~~~~~~~~
.. deprecated:: 6.0.0
Qt 4 reached end-of-life on 2015-12-19. Its Python bindings are also EOL: PyQt4 since
2018-08-31 and PySide since 2015-10-14.
Support for PyQt4 and PySide has been deprecated from ``ImageQt`` and will be removed in
a future version. Please upgrade to PyQt5 or PySide2.
PIL.*ImagePlugin.__version__ attributes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -128,6 +117,17 @@ Removed features
Deprecated features are only removed in major releases after an appropriate
period of deprecation has passed.
PyQt4 and PySide
~~~~~~~~~~~~~~~~
*Removed in version 7.0.0.*
Qt 4 reached end-of-life on 2015-12-19. Its Python bindings are also EOL: PyQt4 since
2018-08-31 and PySide since 2015-10-14.
Support for PyQt4 and PySide has been removed from ``ImageQt``. Please upgrade to PyQt5
or PySide2.
VERSION constant
~~~~~~~~~~~~~~~~

View File

@ -4,14 +4,8 @@
:py:mod:`ImageQt` Module
========================
The :py:mod:`ImageQt` module contains support for creating PyQt4, PyQt5, PySide or
PySide2 QImage objects from PIL images.
Qt 4 reached end-of-life on 2015-12-19. Its Python bindings are also EOL: PyQt4 since
2018-08-31 and PySide since 2015-10-14.
Support for PyQt4 and PySide is deprecated since Pillow 6.0.0 and will be removed in a
future version. Please upgrade to PyQt5 or PySide2.
The :py:mod:`ImageQt` module contains support for creating PyQt5 or PySide2 QImage
objects from PIL images.
.. versionadded:: 1.1.6
@ -20,7 +14,7 @@ future version. Please upgrade to PyQt5 or PySide2.
Creates an :py:class:`~PIL.ImageQt.ImageQt` object from a PIL
:py:class:`~PIL.Image.Image` object. This class is a subclass of
QtGui.QImage, which means that you can pass the resulting objects directly
to PyQt4/PyQt5/PySide API functions and methods.
to PyQt5/PySide2 API functions and methods.
This operation is currently supported for mode 1, L, P, RGB, and RGBA
images. To handle other modes, you need to convert the image first.

View File

@ -17,18 +17,12 @@
#
import sys
import warnings
from io import BytesIO
from . import Image
from ._util import isPath, py3
qt_versions = [["5", "PyQt5"], ["side2", "PySide2"], ["4", "PyQt4"], ["side", "PySide"]]
WARNING_TEXT = (
"Support for EOL {} is deprecated and will be removed in a future version. "
"Please upgrade to PyQt5 or PySide2."
)
qt_versions = [["5", "PyQt5"], ["side2", "PySide2"]]
# If a version has already been imported, attempt it first
qt_versions.sort(key=lambda qt_version: qt_version[1] in sys.modules, reverse=True)
@ -40,16 +34,6 @@ for qt_version, qt_module in qt_versions:
elif qt_module == "PySide2":
from PySide2.QtGui import QImage, qRgba, QPixmap
from PySide2.QtCore import QBuffer, QIODevice
elif qt_module == "PyQt4":
from PyQt4.QtGui import QImage, qRgba, QPixmap
from PyQt4.QtCore import QBuffer, QIODevice
warnings.warn(WARNING_TEXT.format(qt_module), DeprecationWarning)
elif qt_module == "PySide":
from PySide.QtGui import QImage, qRgba, QPixmap
from PySide.QtCore import QBuffer, QIODevice
warnings.warn(WARNING_TEXT.format(qt_module), DeprecationWarning)
except (ImportError, RuntimeError):
continue
qt_is_installed = True