diff options
author | Eike Ziller <eike.ziller@qt.io> | 2018-09-19 16:49:02 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2018-09-19 14:58:55 +0000 |
commit | 6eed121d31bd5f37a32af6fad798bf17b203ce99 (patch) | |
tree | 4dad0365ab256880389c51c3b3039a59121b1b63 | |
parent | 55732e19082a566f644e08bd28b9cff6161dcb7e (diff) |
Fix installation of requirements at first run
If our custom site-packages path does not exist, the Python interpreter
drops it from its list of directories to look for imports at some point.
This results in packages not being found in the custom site-packages
directory on the first run.
Create the directory explicitly at first startup.
Change-Id: Iaff4376890fb68828bbef4c1b05e2d4e7911406a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r-- | plugins/pythonextensions/pythonextensionsplugin.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/plugins/pythonextensions/pythonextensionsplugin.cpp b/plugins/pythonextensions/pythonextensionsplugin.cpp index 3547a59..a230924 100644 --- a/plugins/pythonextensions/pythonextensionsplugin.cpp +++ b/plugins/pythonextensions/pythonextensionsplugin.cpp @@ -162,10 +162,13 @@ QString PythonExtensionsPlugin::pythonPackagePath() void PythonExtensionsPlugin::initializePythonBindings() { // Add our custom module directory - if (extensionDir().exists()) { + if (extensionDir().exists()) PyUtil::addToSysPath(extensionDir().path().toStdString()); - PyUtil::addToSysPath(pythonPackagePath().toStdString()); - } + // Add directory for local python packages that are installed as requirements of extensions + // Need to create it first if it doesn't exist, otherwise python will ignore the path + if (!QFile::exists(pythonPackagePath())) + QDir().mkpath(pythonPackagePath()); + PyUtil::addToSysPath(pythonPackagePath().toStdString()); // Initialize the Python context and register global Qt Creator variable if (!PyUtil::bindShibokenModuleObject("PythonExtension", "QtCreator")) { qWarning() << "Python bindings could not be initialized"; |