| 14 | #include <iostream> |
| 15 | |
| 16 | static QString packageInstallPath(const QString &python) |
| 17 | { |
| 18 | auto getVersion = [](const QString &output) -> QString { |
| 19 | static QRegularExpression regex(R"((\d{1,3}(?:\.\d{1,3}){0,2}))"); |
| 20 | if (output.isEmpty()) |
| 21 | return ""; |
| 22 | |
| 23 | QRegularExpressionMatch match = regex.match(output); |
| 24 | if (match.hasMatch()) |
| 25 | return match.captured(1); |
| 26 | |
| 27 | return ""; |
| 28 | }; |
| 29 | |
| 30 | QProcess process; |
| 31 | process.start(python, { "--version" }); |
| 32 | process.waitForFinished(); |
| 33 | |
| 34 | QString output = process.readAllStandardOutput(); |
| 35 | QString version = getVersion(output); |
| 36 | if (version.isEmpty()) { |
| 37 | output = process.readAllStandardError(); |
| 38 | version = getVersion(output); |
| 39 | if (version.isEmpty()) { |
| 40 | int index = python.lastIndexOf('/') + 1; |
| 41 | output = python.mid(index, python.length() - index); |
| 42 | version = getVersion(output); |
| 43 | } |
| 44 | } |
| 45 | return QStandardPaths::writableLocation(QStandardPaths::HomeLocation) |
| 46 | + "/.unioncode/packages/Python" + version; |
| 47 | } |
| 48 | |
| 49 | // setting from clangd trismit |
| 50 | QProcess *createCxxServ(const newlsp::ProjectKey &key) |
no test coverage detected