From 55ef6ef863f21643785f71a544a3ac98934aa68f Mon Sep 17 00:00:00 2001 From: Nate Skulic Date: Thu, 5 Oct 2023 00:23:54 -0500 Subject: [PATCH] Improve Python Support (#567) - Reduce requirements for the python build. - Fix version number. - Generate type hints for *.pyi files. - Make functional for sip-build - Reduced the unnecessary depth of the package. NOTE: This is a breaking change for python users, where, `from PyQtAds import QtAds` is changed to `import PyQtAds as QtAds`( or simply `import PyQtAds`) --- demo/status_dialog.py | 2 +- examples/autohide/main.py | 2 +- examples/centralwidget/main.py | 2 +- examples/deleteonclose/main.py | 4 ++-- examples/dockindock/dockindock.py | 4 ++-- examples/dockindock/dockindockmanager.py | 4 ++-- examples/dockindock/main.py | 4 ++-- examples/dockindock/perspectives.py | 4 ++-- examples/emptydockarea/main.py | 4 ++-- examples/sidebar/main.py | 2 +- examples/simple/main.py | 2 +- pyproject.toml | 6 ++++-- sip/ads.sip | 2 ++ 13 files changed, 23 insertions(+), 19 deletions(-) diff --git a/demo/status_dialog.py b/demo/status_dialog.py index 8c42f158..cf58a385 100644 --- a/demo/status_dialog.py +++ b/demo/status_dialog.py @@ -2,7 +2,7 @@ import sys from PyQt5 import uic -from PyQtAds import QtAds +import PyQtAds as QtAds UI_FILE = os.path.join(os.path.dirname(__file__), 'StatusDialog.ui') StatusDialogUI, StatusDialogBase = uic.loadUiType(UI_FILE) diff --git a/examples/autohide/main.py b/examples/autohide/main.py index 5fe6a492..48c29278 100644 --- a/examples/autohide/main.py +++ b/examples/autohide/main.py @@ -8,7 +8,7 @@ QTableWidget, QFileSystemModel, QPlainTextEdit, QToolBar, QWidgetAction, QComboBox, QAction, QSizePolicy, QInputDialog) -from PyQtAds import QtAds +import PyQtAds as QtAds UI_FILE = os.path.join(os.path.dirname(__file__), 'mainwindow.ui') MainWindowUI, MainWindowBase = uic.loadUiType(UI_FILE) diff --git a/examples/centralwidget/main.py b/examples/centralwidget/main.py index 5fe6a492..48c29278 100644 --- a/examples/centralwidget/main.py +++ b/examples/centralwidget/main.py @@ -8,7 +8,7 @@ QTableWidget, QFileSystemModel, QPlainTextEdit, QToolBar, QWidgetAction, QComboBox, QAction, QSizePolicy, QInputDialog) -from PyQtAds import QtAds +import PyQtAds as QtAds UI_FILE = os.path.join(os.path.dirname(__file__), 'mainwindow.ui') MainWindowUI, MainWindowBase = uic.loadUiType(UI_FILE) diff --git a/examples/deleteonclose/main.py b/examples/deleteonclose/main.py index 514f1a07..d1504bff 100644 --- a/examples/deleteonclose/main.py +++ b/examples/deleteonclose/main.py @@ -1,6 +1,6 @@ import sys -from PyQtAds import QtAds +import PyQtAds as QtAds from PyQt5.QtGui import QCloseEvent from PyQt5.QtCore import (qDebug, pyqtSlot, QObject, pyqtSignal) from PyQt5.QtWidgets import (QMainWindow, QAction, QTextEdit, QApplication, @@ -70,4 +70,4 @@ def on_action2_triggered(): action.triggered.connect(on_action2_triggered) w.show() - app.exec_() \ No newline at end of file + app.exec_() diff --git a/examples/dockindock/dockindock.py b/examples/dockindock/dockindock.py index 4853b574..5d64fe17 100644 --- a/examples/dockindock/dockindock.py +++ b/examples/dockindock/dockindock.py @@ -3,7 +3,7 @@ from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, QMessageBox, QInputDialog, QMenu, QLineEdit) from PyQt5.QtGui import QIcon -from PyQtAds import QtAds +import PyQtAds as QtAds from dockindockmanager import DockInDockManager from perspectiveactions import LoadPerspectiveAction, RemovePerspectiveAction @@ -200,4 +200,4 @@ def dumpStatus(self, echo: callable = print, widget: QtAds.CDockWidget = None, t for closed in self.getManager().dockWidgetsMap().values(): if not closed in visible_widgets: - self.dumpStatus(widget=closed, tab=tab, suffix=" (closed)") \ No newline at end of file + self.dumpStatus(widget=closed, tab=tab, suffix=" (closed)") diff --git a/examples/dockindock/dockindockmanager.py b/examples/dockindock/dockindockmanager.py index c6f47cb7..224d7195 100644 --- a/examples/dockindock/dockindockmanager.py +++ b/examples/dockindock/dockindockmanager.py @@ -1,7 +1,7 @@ from PyQt5.QtWidgets import QAction, QMenu, QInputDialog, QLineEdit from PyQt5.QtCore import QSettings -from PyQtAds import QtAds +import PyQtAds as QtAds CHILD_PREFIX = "Child-" @@ -211,4 +211,4 @@ def move(self, widget: QtAds.CDockWidget, move_to: QtAds.CDockManager) -> None: widget.dockManager().removeDockWidget(widget) move_to.addDockWidget(QtAds.CenterDockWidgetArea, widget, move_to.getInsertDefaultPos()) else: - assert False \ No newline at end of file + assert False diff --git a/examples/dockindock/main.py b/examples/dockindock/main.py index 5b6e4788..be32b082 100644 --- a/examples/dockindock/main.py +++ b/examples/dockindock/main.py @@ -4,7 +4,7 @@ from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel from PyQt5.QtCore import Qt -from PyQtAds import QtAds +import PyQtAds as QtAds from perspectives import PerspectivesManager from dockindock import DockInDockWidget @@ -69,4 +69,4 @@ def cleanup(self): w = MainWindow() w.show() - app.exec_() \ No newline at end of file + app.exec_() diff --git a/examples/dockindock/perspectives.py b/examples/dockindock/perspectives.py index ab9dddb5..9b6c00df 100644 --- a/examples/dockindock/perspectives.py +++ b/examples/dockindock/perspectives.py @@ -4,7 +4,7 @@ import atexit from PyQt5.QtCore import pyqtSignal, QSettings, QObject -from PyQtAds import QtAds +import PyQtAds as QtAds from dockindockmanager import DockInDockManager from dockindock import DockInDockWidget @@ -200,4 +200,4 @@ def savePerspectives(self) -> None: except FileNotFoundError: pass if not shutil.copy(settings.fileName(), to_save): - assert False \ No newline at end of file + assert False diff --git a/examples/emptydockarea/main.py b/examples/emptydockarea/main.py index 046d45fe..475cc2ed 100644 --- a/examples/emptydockarea/main.py +++ b/examples/emptydockarea/main.py @@ -6,7 +6,7 @@ from PyQt5.QtWidgets import (QApplication, QMainWindow, QLabel, QComboBox, QTableWidget, QAction, QWidgetAction, QSizePolicy, QInputDialog) from PyQt5.QtGui import QCloseEvent -from PyQtAds import QtAds +import PyQtAds as QtAds UI_FILE = os.path.join(os.path.dirname(__file__), 'mainwindow.ui') @@ -105,4 +105,4 @@ def closeEvent(self, event: QCloseEvent): w = CMainWindow() w.show() - app.exec_() \ No newline at end of file + app.exec_() diff --git a/examples/sidebar/main.py b/examples/sidebar/main.py index 27170ba9..8005908d 100644 --- a/examples/sidebar/main.py +++ b/examples/sidebar/main.py @@ -5,7 +5,7 @@ from PyQt5.QtCore import Qt, QMargins from PyQt5.QtWidgets import QApplication, QLabel, QVBoxLayout, QPlainTextEdit -from PyQtAds import QtAds +import PyQtAds as QtAds UI_FILE = os.path.join(os.path.dirname(__file__), 'MainWindow.ui') MainWindowUI, MainWindowBase = uic.loadUiType(UI_FILE) diff --git a/examples/simple/main.py b/examples/simple/main.py index b21767dd..dcacef89 100644 --- a/examples/simple/main.py +++ b/examples/simple/main.py @@ -6,7 +6,7 @@ from PyQt5.QtGui import QCloseEvent from PyQt5.QtWidgets import QApplication, QLabel -from PyQtAds import QtAds +import PyQtAds as QtAds UI_FILE = os.path.join(os.path.dirname(__file__), 'MainWindow.ui') MainWindowUI, MainWindowBase = uic.loadUiType(UI_FILE) diff --git a/pyproject.toml b/pyproject.toml index cbe95d1b..a9b93bb7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ # Specify the build system. [build-system] -requires = ["sip >=6.0.2, <6.3", "PyQt-builder >=1.6, <2", "PyQt5==5.15.4", "PyQt5-sip<13,>=12.8"] +requires = ["sip >=6.0.2", "PyQt-builder >=1.6", "PyQt5>=5.15", "PyQt5-sip>=12.8"] build-backend = "sipbuild.api" # Specify the PEP 566 metadata for the project. [tool.sip.metadata] name = "PyQtAds" -version = "4.0.2" +version = "4.4.1" summary = "Python bindings for Qt Advanced Docking System" home-page = "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/" license = "LGPL v2.1" @@ -16,8 +16,10 @@ description-content-type = "text/markdown" [tool.sip.project] tag-prefix = "QtAds" +dunder-init = true [tool.sip.bindings.ads] +pep484-pyi = true define-macros = ["ADS_SHARED_EXPORT"] sip-file = "ads.sip" include-dirs = ["src"] diff --git a/sip/ads.sip b/sip/ads.sip index 70a252ae..28c2695f 100644 --- a/sip/ads.sip +++ b/sip/ads.sip @@ -1,4 +1,6 @@ %Module(name=PyQtAds, call_super_init=True, keyword_arguments="Optional", use_limited_api=True) +%HideNamespace(name=ads) + %Import QtCore/QtCoremod.sip %DefaultSupertype sip.simplewrapper