From 505157fa60381ba7a0a21e8656c72913373a54c3 Mon Sep 17 00:00:00 2001 From: HucSte Date: Sat, 14 Apr 2018 21:39:14 +0200 Subject: [PATCH 1/2] Add support PyQt5 for OpenBSD 6.x! --- setup.py | 5 ++++- webview/__init__.py | 4 ++-- webview/qt.py | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 07fe0e9..72aa6ea 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,10 @@ elif platform.system() == "Linux": 'gtk3': ['PyGObject'], 'qt5': ['PyQt5'], } - +elif platform.system() == 'OpenBSD': + extras_require = { + 'qt5': ['PyQt5'], + } setup( name="pywebview", diff --git a/webview/__init__.py b/webview/__init__.py index a890314..826a536 100755 --- a/webview/__init__.py +++ b/webview/__init__.py @@ -75,7 +75,7 @@ def _initialize_imports(): logger.exception('QT cannot be loaded') raise Exception('You must have either PyObjC (for Cocoa support) or Qt with Python bindings installed in order to use this library.') - elif platform.system() == 'Linux': + elif platform.system() == 'Linux' or platform.system() == 'OpenBSD': if not config.use_qt: try: import webview.gtk as gui @@ -115,7 +115,7 @@ def _initialize_imports(): logger.exception('PyWin32 cannot be loaded') raise Exception('You must have either pythonnet or pywin32 installed in order to use this library.') else: - raise Exception('Unsupported platform. Only Windows, Linux and OS X are supported.') + raise Exception('Unsupported platform. Only Windows, Linux, OS X, OpenBSD are supported.') _initialized = True diff --git a/webview/qt.py b/webview/qt.py index 57f6cef..d332d81 100755 --- a/webview/qt.py +++ b/webview/qt.py @@ -6,6 +6,7 @@ http://github.com/r0x0r/pywebview/ ''' import os +import platform import json import logging from uuid import uuid1 @@ -30,7 +31,7 @@ try: from PyQt5.QtCore import QT_VERSION_STR _qt_version = [int(n) for n in QT_VERSION_STR.split('.')] - if _qt_version >= [5, 5]: + if _qt_version >= [5, 5] and platform.version() == 'Linux': from PyQt5.QtWebEngineWidgets import QWebEngineView as QWebView from PyQt5.QtWebChannel import QWebChannel else: @@ -154,7 +155,7 @@ class BrowserView(QMainWindow): self.evaluate_js_trigger.connect(self.on_evaluate_js) self.set_title_trigger.connect(self.on_set_title) - if _qt_version >= [5, 5]: + if _qt_version >= [5, 5] and platform.version() == 'Linux': self.channel = QWebChannel(self.view.page()) self.view.page().setWebChannel(self.channel) From a780407d84bec60a98acf51b16529cb2b6d6d9e3 Mon Sep 17 00:00:00 2001 From: HucSte Date: Sun, 15 Apr 2018 23:38:42 +0200 Subject: [PATCH 2/2] Correction to detect correctly only OpenBSD --- webview/qt.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webview/qt.py b/webview/qt.py index d332d81..43da9d4 100755 --- a/webview/qt.py +++ b/webview/qt.py @@ -31,7 +31,7 @@ try: from PyQt5.QtCore import QT_VERSION_STR _qt_version = [int(n) for n in QT_VERSION_STR.split('.')] - if _qt_version >= [5, 5] and platform.version() == 'Linux': + if _qt_version >= [5, 5] and platform.system() != 'OpenBSD': from PyQt5.QtWebEngineWidgets import QWebEngineView as QWebView from PyQt5.QtWebChannel import QWebChannel else: @@ -62,7 +62,7 @@ if _import_error: _import_error = False if _import_error: - raise Exception('This module requires PyQt4 or PyQt5 to work under Linux.') + raise Exception('This module requires PyQt4 or PyQt5 to work under Linux or *BSD.') class BrowserView(QMainWindow): @@ -155,7 +155,7 @@ class BrowserView(QMainWindow): self.evaluate_js_trigger.connect(self.on_evaluate_js) self.set_title_trigger.connect(self.on_set_title) - if _qt_version >= [5, 5] and platform.version() == 'Linux': + if _qt_version >= [5, 5] and platform.system() != 'OpenBSD': self.channel = QWebChannel(self.view.page()) self.view.page().setWebChannel(self.channel)