diff options
author | Robin Dunn <robin@alldunn.com> | 2013-05-15 17:05:08 -0700 |
---|---|---|
committer | John Ehresman <jpe@wingware.com> | 2013-05-17 17:59:10 +0200 |
commit | a6785ad13fc096c60b2fc38d4220010ae708743a (patch) | |
tree | 271aca0a1b41b3e46f778e5e7e04fe6fd547eee4 /PySide | |
parent | 72ab0b07c8be82802371aa6a934261a5a1eb237e (diff) |
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 <jpe@wingware.com>
Diffstat (limited to 'PySide')
-rw-r--r-- | PySide/__init__.py.in | 29 |
1 files changed, 23 insertions, 6 deletions
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) |