-
Notifications
You must be signed in to change notification settings - Fork 12
Add a warning message when triggering an install action using PyPI source on a bundle/conda installation #111
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
Changes from 3 commits
9c7aecf
a9f6f81
807e313
4b787c0
fc9afc8
7e995b1
cb7e0dc
3260704
b503f7e
a9ce355
63adb5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ | |
| QListWidget, | ||
| QListWidgetItem, | ||
| QMenu, | ||
| QMessageBox, | ||
| QPushButton, | ||
| QSizePolicy, | ||
| QSplitter, | ||
|
|
@@ -600,6 +601,17 @@ def _on_enabled_checkbox(self, state: Qt.CheckState) -> None: | |
| """ | ||
| raise NotImplementedError | ||
|
|
||
| def _on_bundle(self) -> bool: | ||
| """ | ||
| If the current installation comes from a bundle/standalone approach or not. | ||
|
|
||
| Returns | ||
| ------- | ||
| This should return a `bool`, `True` if under a bundle like installation, `False` | ||
| otherwise. | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| def _cancel_requested(self): | ||
| version = self.version_choice_dropdown.currentText() | ||
| tool = self.get_installer_tool() | ||
|
|
@@ -615,6 +627,26 @@ def _action_requested(self): | |
| if self.action_button.objectName() == 'install_button' | ||
| else InstallerActions.UNINSTALL | ||
| ) | ||
| if ( | ||
| tool == InstallerTools.PIP | ||
| and action == InstallerActions.INSTALL | ||
| and self._on_bundle() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some folks might not want this behavior, on bundle or not. Let's turn this third condition into
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking about how to generalize the warning dialog text, maybe another approach that could be done is to instead add a def _action_validation(self, tool, action) -> bool:
raise NotImplementedError
def _action_requested(self):
version = self.version_choice_dropdown.currentText()
tool = self.get_installer_tool()
action = (
InstallerActions.INSTALL
if self.action_button.objectName() == 'install_button'
else InstallerActions.UNINSTALL
)
if self._action_validation(tool, action):
self.actionRequested.emit(self.item, self.name, action, version, tool)Then the napari implementation would be something like: def _action_validation(self, tool, action) -> bool:
if (
tool == InstallerTools.PIP
and action == InstallerActions.INSTALL
and (running_as_constructor_app() or is_conda_package('napari'))
):
button_clicked = QMessageBox.warning(
self,
self._trans('PyPI installation on bundle'),
self._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 False
return TrueWhat do you think @jaimergp ? |
||
| ): | ||
| button_clicked = QMessageBox.warning( | ||
| self, | ||
| self._trans('PyPI installation on bundle'), | ||
| self._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 | ||
| self.actionRequested.emit(self.item, self.name, action, version, tool) | ||
|
|
||
| def _update_requested(self): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.