PluginPipxInterface.py

changeset 31
17e37d4ebe42
parent 29
9a783db4f4ed
child 32
b7a3ae7519ba
diff -r 1b6adcd21c6c -r 17e37d4ebe42 PluginPipxInterface.py
--- a/PluginPipxInterface.py	Sat Jul 27 17:39:00 2024 +0200
+++ b/PluginPipxInterface.py	Sat Jul 27 19:39:32 2024 +0200
@@ -7,6 +7,7 @@
 Module implementing the pipx Interface plug-in.
 """
 
+import importlib.util
 import os
 import sysconfig
 
@@ -148,6 +149,8 @@
         self.__ui = ui
         self.__initialize()
 
+        # TODO: add option to check outdated dependencies when checking for
+        #       outdated status
         self.__defaults = {
             "RecentAppWorkdirs": [],
             "MaxRecentAppWorkdirs": 20,
@@ -303,10 +306,14 @@
     @param pipInstall function to be called with a list of package names.
     @type function
     """
-    try:
-        import pipx  # __IGNORE_WARNING__
-    except ImportError:
-        pipInstall(["pipx>=1.5.0"])
+    packagesToInstall = []
+    if importlib.util.find_spec("pipx") is None:
+        packagesToInstall.append("pipx>=1.5.0")
+    if importlib.util.find_spec("psutil") is None:
+        packagesToInstall.append("psutil")
+
+    if packagesToInstall:
+        pipInstall(packagesToInstall)
 
 
 #

eric ide

mercurial