From a6785ad13fc096c60b2fc38d4220010ae708743a Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 15 May 2013 17:05:08 -0700 Subject: Preload OpenSSL DLLs on Windows. Add code to _setupQtDirectories that will preload the OpenSSL DLLs if they are included in the PySide package. It uses a trick of temporarily modifying the PATH so Qt's QSystemLibrary will be able to find them. Change-Id: I67b56642ef74444f19806b52c6a1080dc6d92996 Reviewed-by: John Ehresman --- PySide/__init__.py.in | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'PySide') diff --git a/PySide/__init__.py.in b/PySide/__init__.py.in index a61e54b52..a5b540cad 100644 --- a/PySide/__init__.py.in +++ b/PySide/__init__.py.in @@ -4,15 +4,32 @@ __version_info__ = (@BINDING_API_MAJOR_VERSION@, @BINDING_API_MINOR_VERSION@, def _setupQtDirectories(): - from . import QtCore + import sys import os - # Look first in the PySide package for Qt's plugins folder if it exists, - # instead of just the default of looking in Qt's install or build folder. - pluginsDir = os.path.join( - os.path.abspath(os.path.dirname(QtCore.__file__)), 'plugins') + pysideDir = os.path.abspath(os.path.dirname(__file__)) + + # On Windows add the PySide\openssl folder (if it exists) to the + # PATH so the SSL DLLs can be found when Qt tries to dynamically + # load them. Tell Qt to load them and then reset the PATH. + if sys.platform == 'win32': + opensslDir = os.path.join(pysideDir, 'openssl') + if os.path.exists(opensslDir): + path = os.environ['PATH'] + try: + os.environ['PATH'] = opensslDir + os.pathsep + path + from . import QtNetwork + QtNetwork.QSslSocket.supportsSsl() + finally: + os.environ['PATH'] = path + + # Tell Qt to look for plugins in the PySide package, if the + # plugins folder exists there, instead of just the default of + # looking only in Qt's install or build folder. + from . import QtCore + pluginsDir = os.path.join(pysideDir, 'plugins') if os.path.exists(pluginsDir) and \ - pluginsDir not in QtCore.QCoreApplication.libraryPaths(): + pluginsDir not in QtCore.QCoreApplication.libraryPaths(): QtCore.QCoreApplication.addLibraryPath(pluginsDir) -- cgit v1.2.3