Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Add FORCE_QT_API environment variable #194

Merged
merged 2 commits into from
Jul 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions qtpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,17 @@ class PythonQtWarning(Warning):
PYQT5 = True
PYQT4 = PYSIDE = PYSIDE2 = False


if 'PyQt5' in sys.modules:
API = initial_api if initial_api in PYQT5_API else 'pyqt5'
elif 'PySide2' in sys.modules:
API = initial_api if initial_api in PYSIDE2_API else 'pyside2'
elif 'PyQt4' in sys.modules:
API = initial_api if initial_api in PYQT4_API else 'pyqt4'
elif 'PySide' in sys.modules:
API = initial_api if initial_api in PYSIDE_API else 'pyside'
# When `FORCE_QT_API` is set, we disregard
# any previously imported python bindings.
if os.environ.get('FORCE_QT_API') is not None:
if 'PyQt5' in sys.modules:
API = initial_api if initial_api in PYQT5_API else 'pyqt5'
elif 'PySide2' in sys.modules:
API = initial_api if initial_api in PYSIDE2_API else 'pyside2'
elif 'PyQt4' in sys.modules:
API = initial_api if initial_api in PYQT4_API else 'pyqt4'
elif 'PySide' in sys.modules:
API = initial_api if initial_api in PYSIDE_API else 'pyside'


if API in PYQT5_API:
Expand Down