| 545 | } |
| 546 | |
| 547 | bool AbstractPythonInterface::checkDependencies(bool force, bool async) |
| 548 | { |
| 549 | if (m_installStatus == InProgress || (!force && m_dependenciesChecked)) { |
| 550 | // Don't check twice if dependencies are satisfied |
| 551 | return true; |
| 552 | } |
| 553 | // Force check, reset flag |
| 554 | m_missing.clear(); |
| 555 | m_optionalMissing.clear(); |
| 556 | // Check if venv is correctly installed |
| 557 | PythonExec exes = venvPythonExecs(true); |
| 558 | if (exes.python.isEmpty() || exes.pip.isEmpty()) { |
| 559 | // Check if venv folder exists |
| 560 | QDir pluginDir(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)); |
| 561 | const QString binaryPath = getVenvPath(); |
| 562 | if (!pluginDir.exists(binaryPath)) { |
| 563 | setStatus(NotInstalled); |
| 564 | return false; |
| 565 | } |
| 566 | setStatus(Broken); |
| 567 | return false; |
| 568 | } |
| 569 | const QString output = runPackageScript(QStringLiteral("--check"), false, false, force); |
| 570 | QStringList missingDeps = output.split(QStringLiteral("Missing: "), Qt::SkipEmptyParts); |
| 571 | QStringList outputMissing; |
| 572 | for (auto &m : missingDeps) { |
| 573 | outputMissing << m.simplified(); |
| 574 | } |
| 575 | const QStringList deps = parseDependencies(m_dependencies.keys(), true); |
| 576 | QStringList messages; |
| 577 | if (!output.isEmpty()) { |
| 578 | // We have missing dependencies |
| 579 | for (const auto &i : deps) { |
| 580 | if (outputMissing.contains(i)) { |
| 581 | if (m_optionalDeps.contains(i)) { |
| 582 | m_optionalMissing << i; |
| 583 | continue; |
| 584 | } |
| 585 | m_missing.append(i); |
| 586 | messages.append(xi18n("The <application>%1</application> python module is required.", i)); |
| 587 | } |
| 588 | } |
| 589 | } |
| 590 | m_dependenciesChecked = true; |
| 591 | if (messages.isEmpty()) { |
| 592 | if (async) { |
| 593 | checkVersionsConcurrently(); |
| 594 | } else { |
| 595 | checkVersions(true); |
| 596 | } |
| 597 | Q_EMIT dependenciesAvailable(); |
| 598 | } else { |
| 599 | messages.prepend(i18n("Using python from %1", exes.python)); |
| 600 | Q_EMIT dependenciesMissing(messages); |
| 601 | } |
| 602 | return false; |
| 603 | } |
| 604 |
no test coverage detected