Kentaro Wada 3 ani în urmă
părinte
comite
423aca79c1
4 a modificat fișierele cu 11 adăugiri și 49 ștergeri
  1. 5 18
      .github/workflows/ci.yml
  2. 1 1
      README.md
  3. 0 13
      labelme/app.py
  4. 5 17
      setup.py

+ 5 - 18
.github/workflows/ci.yml

@@ -14,14 +14,7 @@ jobs:
       matrix:
         os: [macos-latest, ubuntu-latest, windows-latest]
         python-version: ['3.9']
-        PYTEST_QT_API: [pyqt5, pyqt4v2]
-        exclude:
-          - os: macos-latest
-            PYTEST_QT_API: pyqt4v2
-          - os: windows-latest
-            PYTEST_QT_API: pyqt4v2
-          - python-version: '3.9'
-            PYTEST_QT_API: pyqt4v2
+        PYTEST_QT_API: [pyqt5, pyside2]
 
     steps:
     - uses: actions/checkout@v2
@@ -57,14 +50,8 @@ jobs:
       run: |
         if [ "${{ matrix.PYTEST_QT_API }}" = "pyside2" ]; then
           conda install -q -y pyside2 -c conda-forge
-        elif [ "${{ matrix.PYTEST_QT_API }}" = "pyqt4v2" ]; then
-          conda install -q -y pyqt=4 -c conda-forge
-        else  # pyqt5
-          if [ "${{ matrix.os }}" = "macos-latest" -a "${{ matrix.python-version }}" = "3.9" ]; then
-            pip install pyqt5
-          else
-            conda install -q -y pyqt=5
-          fi
+        else
+          conda install -q -y pyqt=5
         fi
         if [ "${{ matrix.os }}" != "windows-latest" ]; then
           conda install -q -y help2man
@@ -92,7 +79,7 @@ jobs:
 
     - name: Test with pytest
       shell: bash -l {0}
-      if: matrix.os != 'windows-latest'
+      if: matrix.os != 'windows-latest' && !(matrix.os == 'macos-latest' && matrix.PYTEST_QT_API == 'pyside2')
       env:
         PYTEST_QT_API: ${{ matrix.PYTEST_QT_API }}
       run: |
@@ -129,7 +116,7 @@ jobs:
 
     - name: Run pyinstaller
       shell: bash -l {0}
-      if: matrix.PYTEST_QT_API == 'pyqt5' && matrix.python-version == '3.9'
+      if: matrix.PYTEST_QT_API == 'pyqt5'
       run: |
         # Build the standalone executable
         pip install PyQt5 -I --use-feature=2020-resolver  # https://stackoverflow.com/a/68784578

+ 1 - 1
README.md

@@ -57,7 +57,7 @@ It is written in Python and uses Qt for its graphical interface.
 
 - Ubuntu / macOS / Windows
 - Python3
-- [PyQt4 / PyQt5](http://www.riverbankcomputing.co.uk/software/pyqt/intro)
+- [PyQt5 / PySide2](http://www.riverbankcomputing.co.uk/software/pyqt/intro)
 
 
 ## Installation

+ 0 - 13
labelme/app.py

@@ -792,15 +792,6 @@ class MainWindow(QtWidgets.QMainWindow):
         size = self.settings.value("window/size", QtCore.QSize(600, 500))
         position = self.settings.value("window/position", QtCore.QPoint(0, 0))
         state = self.settings.value("window/state", QtCore.QByteArray())
-        # PyQt4 cannot handle QVariant
-        if isinstance(self.recentFiles, QtCore.QVariant):
-            self.recentFiles = self.recentFiles.toList()
-        if isinstance(size, QtCore.QVariant):
-            size = size.toSize()
-        if isinstance(position, QtCore.QVariant):
-            position = position.toPoint()
-        if isinstance(state, QtCore.QVariant):
-            state = state.toByteArray()
         self.resize(size)
         self.move(position)
         # or simply:
@@ -1245,10 +1236,6 @@ class MainWindow(QtWidgets.QMainWindow):
         lf = LabelFile()
 
         def format_shape(s):
-            # PyQt4 cannot handle QVariant
-            if isinstance(s, QtCore.QVariant):
-                s = s.toPyObject()
-
             data = s.other_data.copy()
             data.update(
                 dict(

+ 5 - 17
setup.py

@@ -39,7 +39,7 @@ def get_install_requires():
     ]
 
     # Find python binding for qt with priority:
-    # PyQt5 -> PySide2 -> PyQt4,
+    # PyQt5 -> PySide2
     # and PyQt5 is automatically installed on Python3.
     QT_BINDING = None
 
@@ -59,23 +59,11 @@ def get_install_requires():
             pass
 
     if QT_BINDING is None:
-        try:
-            import PyQt4  # NOQA
+        # PyQt5 can be installed via pip for Python3
+        # 5.15.3, 5.15.4 won't work with PyInstaller
+        install_requires.append("PyQt5!=5.15.3,!=5.15.4")
+        QT_BINDING = "pyqt5"
 
-            QT_BINDING = "pyqt4"
-        except ImportError:
-            if PY2:
-                print(
-                    "Please install PyQt5, PySide2 or PyQt4 for Python2.\n"
-                    "Note that PyQt5 can be installed via pip for Python3.",
-                    file=sys.stderr,
-                )
-                sys.exit(1)
-            assert PY3
-            # PyQt5 can be installed via pip for Python3
-            # 5.15.3, 5.15.4 won't work with PyInstaller
-            install_requires.append("PyQt5!=5.15.3,!=5.15.4")
-            QT_BINDING = "pyqt5"
     del QT_BINDING
 
     if os.name == "nt":  # Windows