Skip to content

Commit 582296f

Browse files
committed
BUG: Fix update notice when idc-index-data has a new version
idc-index-data would be marked as out of date, however it would not be upgraded, making it impossible to get rid of the update required message. Fixed by calling --upgrade on idx-index-data to trigger the update. Also reload the idc-index library after updating so that the new library is used.
1 parent a3fbf83 commit 582296f

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

IDCBrowser/IDCBrowser.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,8 @@ def onPythonRequirementsCheckTimeout(self):
476476
self.pythonRequirementsCheckTimer.stop()
477477

478478
requiredLibraries = [
479-
"idc-index"
479+
"idc-index",
480+
"idc-index-data"
480481
]
481482

482483
outdatedLibraries = []
@@ -1521,8 +1522,26 @@ def setupPythonRequirements(self, update=False):
15211522
userMessage = "The module requires idc-index python package, which will now be installed."
15221523
logging.info(userMessage)
15231524
with slicer.util.displayPythonShell() as shell, slicer.util.tryWithErrorDisplay(message=errorMessage, waitCursor=True) as errorDisplay:
1524-
slicer.util.pip_install(f"{'--upgrade ' if update else ''}idc-index>=0.7.0")
1525+
if update:
1526+
slicer.util.pip_install("--no-cache-dir --upgrade idc-index>=0.7.0")
1527+
slicer.util.pip_install("--no-cache-dir --upgrade idc-index-data")
1528+
else:
1529+
slicer.util.pip_install("idc-index>=0.7.0 idc-index-data")
15251530
installed = True
1531+
1532+
try:
1533+
import importlib
1534+
# Force reload of the module to pick up the new version
1535+
if 'idc_index' in sys.modules:
1536+
import idc_index
1537+
importlib.reload(idc_index)
1538+
if 'idc_index.index' in sys.modules:
1539+
from idc_index import index
1540+
importlib.reload(index)
1541+
except Exception as e:
1542+
logging.error("Failed to reload idc_index module after installation/update: " + str(e))
1543+
errorDisplay.setError(str(e))
1544+
installed = False
15261545
else:
15271546
installed = True
15281547

0 commit comments

Comments
 (0)