Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a warning message when triggering an install action using PyPI source on a bundle/conda installation #111

Merged
merged 11 commits into from
Dec 4, 2024
23 changes: 22 additions & 1 deletion napari_plugin_manager/qt_plugin_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
QListWidget,
QListWidgetItem,
QMenu,
QMessageBox,
QPushButton,
QSizePolicy,
QSplitter,
Expand Down Expand Up @@ -531,6 +532,26 @@
if self.action_button.objectName() == 'install_button'
else InstallerActions.UNINSTALL
)
if (
tool == InstallerTools.PIP
and action == InstallerActions.INSTALL
and ON_BUNDLE
):
button_clicked = QMessageBox.warning(

Check warning on line 540 in napari_plugin_manager/qt_plugin_dialog.py

View check run for this annotation

Codecov / codecov/patch

napari_plugin_manager/qt_plugin_dialog.py#L540

Added line #L540 was not covered by tests
self,
trans._('PyPI installation on bundle'),
trans._(
'Installing from PyPI does not take into account existing installed packages, '
'so it can break existing installations. '
'If this happens the only solution is to reinstall the bundle.\n\n'
'Are you sure you want to install from PyPI?'
),
buttons=QMessageBox.StandardButton.Ok
| QMessageBox.StandardButton.Cancel,
defaultButton=QMessageBox.StandardButton.Cancel,
)
if button_clicked != QMessageBox.StandardButton.Ok:
return

Check warning on line 554 in napari_plugin_manager/qt_plugin_dialog.py

View check run for this annotation

Codecov / codecov/patch

napari_plugin_manager/qt_plugin_dialog.py#L553-L554

Added lines #L553 - L554 were not covered by tests
self.actionRequested.emit(self.item, self.name, action, version, tool)

def _update_requested(self):
Expand Down Expand Up @@ -1215,7 +1236,7 @@
self.working_indicator.setMovie(mov)
mov.start()

visibility_direct_entry = not running_as_constructor_app()
visibility_direct_entry = not ON_BUNDLE
self.direct_entry_edit = QLineEdit(self)
self.direct_entry_edit.installEventFilter(self)
self.direct_entry_edit.returnPressed.connect(self._install_packages)
Expand Down