diff --git a/avogadro/qtplugins/plugindownloader/pluginmanagerwidget.cpp b/avogadro/qtplugins/plugindownloader/pluginmanagerwidget.cpp index cdd1ecb2de..bd42424bd8 100644 --- a/avogadro/qtplugins/plugindownloader/pluginmanagerwidget.cpp +++ b/avogadro/qtplugins/plugindownloader/pluginmanagerwidget.cpp @@ -202,7 +202,7 @@ void PluginManagerWidget::updatePluginsList() m_repoList[i].zipballUrl = it.value().get().c_str(); else if (it.key() == "has_release" && it.value().is_boolean()) m_repoList[i].hasRelease = it.value().get(); - else if (it.key() == "repo_url" && it.value().is_string()) + else if (it.key() == "repo" && it.value().is_string()) m_repoList[i].baseUrl = it.value().get().c_str(); else if (it.key() == "readme_url" && it.value().is_string()) m_repoList[i].readmeUrl = it.value().get().c_str(); @@ -392,6 +392,16 @@ void PluginManagerWidget::appendInstallationInformation(QString text) { text ); } + +PluginManagerWidget::repo* PluginManagerWidget::getRepoByName(QString name) { + for(int i = 0; i < m_repoList.size(); i++) { + if ( name == m_repoList[i].name ) { + return &m_repoList[i]; + } + } + return nullptr; +} + // Save and unzip the plugin zipball QString PluginManagerWidget::unzipPlugin() { @@ -400,7 +410,12 @@ QString PluginManagerWidget::unzipPlugin() QByteArray fileData = m_reply->readAll(); QDir().mkpath(m_filePath); // create any needed directories for the download QString repoName = m_downloadList.last().name; - QString filename = repoName + ".zip"; + PluginManagerWidget::repo* repoData = getRepoByName(repoName); + std::string repoBaseUrl = repoData->baseUrl.toUtf8().toStdString(); + std::string::size_type lastSlash = repoBaseUrl.rfind('/'); + QString pluginOutputDirName = QString::fromStdString(repoBaseUrl.substr(lastSlash + 1)); + + QString filename = pluginOutputDirName + ".zip"; QString absolutePath = m_filePath + "/" + filename; QString extractDirectory; @@ -466,7 +481,7 @@ QString PluginManagerWidget::unzipPlugin() m_reply->deleteLater(); m_downloadList.removeLast(); installNextPlugin(); - return extractDirectory + QDir::separator() + repoName; + return extractDirectory + QDir::separator() + pluginOutputDirName; } return NULL; } diff --git a/avogadro/qtplugins/plugindownloader/pluginmanagerwidget.h b/avogadro/qtplugins/plugindownloader/pluginmanagerwidget.h index c5bba906af..76355499fe 100644 --- a/avogadro/qtplugins/plugindownloader/pluginmanagerwidget.h +++ b/avogadro/qtplugins/plugindownloader/pluginmanagerwidget.h @@ -103,6 +103,7 @@ public slots: void fetchPluginsList(QString url = "https://avogadro.cc/plugins.json"); void installNextPlugin(); bool checkSHA1(QByteArray); + repo* getRepoByName(QString name); std::vector m_repoList; Ui::PluginManagerWidget* m_ui; diff --git a/avogadro/qtplugins/plugindownloader/pythoncmdlineinterface.cpp b/avogadro/qtplugins/plugindownloader/pythoncmdlineinterface.cpp index bccbe6e5eb..6f8d1c5d9b 100644 --- a/avogadro/qtplugins/plugindownloader/pythoncmdlineinterface.cpp +++ b/avogadro/qtplugins/plugindownloader/pythoncmdlineinterface.cpp @@ -20,18 +20,21 @@ void installRequirements(const QString& folderPath, const QString& installMethod // Extract the environment name from pythonInstallation, if present QString envName; int colonIndex = pythonInstallation.indexOf(":"); - int parenIndex = pythonInstallation.indexOf("("); + int parenIndex = pythonInstallation.indexOf(")"); if (parenIndex != -1 && colonIndex != -1) { - envName = pythonInstallation.mid(parenIndex + 1, colonIndex - parenIndex - 1).trimmed(); + assert(colonIndex < parenIndex); + envName = pythonInstallation.mid(colonIndex + 1, parenIndex - colonIndex - 1).trimmed(); } // Prepare environment activation command only if envName is not empty QString activateCommand; if (!envName.isEmpty()) { if (pythonInstallation.contains("Conda")) { - activateCommand = (QSysInfo::productType() == "windows") ? - QString("activate %1 && ").arg(envName) : - QString("conda activate %1 && ").arg(envName); + if ( envName.isEmpty() ) { + activateCommand = QString("conda run "); + } else { + activateCommand = QString("conda run -n %1 ").arg(envName); + } } else if (pythonInstallation.contains("VirtualEnv")) { activateCommand = (QSysInfo::productType() == "windows") ? QString("%1\\Scripts\\activate && ").arg(envName) : @@ -56,18 +59,17 @@ void installRequirements(const QString& folderPath, const QString& installMethod QMessageBox::information(nullptr, "Installation Info", "Conda cannot install from a pyproject.toml file."); return; } + } else { + QMessageBox::information(nullptr, "No Requirements Found", "Neither requirements.txt nor pyproject.toml found."); + return; } - if (!installCommand.isEmpty()) { - QProcess process; - process.start(installCommand); - process.waitForFinished(); + QProcess process; + process.start(installCommand); + process.waitForFinished(); - if (process.exitCode() != 0) { - QMessageBox::critical(nullptr, "Installation Error", process.readAllStandardError()); - } - } else { - QMessageBox::information(nullptr, "No Requirements Found", "Neither requirements.txt nor pyproject.toml found."); + if (process.exitCode() != 0) { + QMessageBox::critical(nullptr, "Installation Error", process.readAllStandardError()); } }