diff options
Diffstat (limited to 'src/plugins/python/pythonutils.cpp')
| -rw-r--r-- | src/plugins/python/pythonutils.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index 24d8a1f188..346c42d183 100644 --- a/src/plugins/python/pythonutils.cpp +++ b/src/plugins/python/pythonutils.cpp @@ -22,6 +22,12 @@ using namespace Utils; namespace Python::Internal { +static QHash<FilePath, FilePath> &userDefinedPythonsForDocument() +{ + static QHash<FilePath, FilePath> userDefines; + return userDefines; +} + FilePath detectPython(const FilePath &documentPath) { Project *project = documentPath.isEmpty() ? nullptr @@ -42,6 +48,10 @@ FilePath detectPython(const FilePath &documentPath) } } + const FilePath userDefined = userDefinedPythonsForDocument().value(documentPath); + if (userDefined.exists()) + return userDefined; + // check whether this file is inside a python virtual environment const QList<Interpreter> venvInterpreters = PythonSettings::detectPythonVenvs(documentPath); if (!venvInterpreters.isEmpty()) @@ -71,6 +81,11 @@ FilePath detectPython(const FilePath &documentPath) return PythonSettings::interpreters().value(0).command; } +void definePythonForDocument(const FilePath &documentPath, const FilePath &python) +{ + userDefinedPythonsForDocument()[documentPath] = python; +} + static QStringList replImportArgs(const FilePath &pythonFile, ReplType type) { using MimeTypes = QList<MimeType>; |
