src/eric7/PipInterface/Pip.py

branch
eric7
changeset 11091
3a1ba42ac50a
parent 11090
f5f5f5803935
child 11112
f96a04843ed4
--- a/src/eric7/PipInterface/Pip.py	Tue Dec 10 15:46:34 2024 +0100
+++ b/src/eric7/PipInterface/Pip.py	Wed Dec 11 18:12:50 2024 +0100
@@ -1364,3 +1364,33 @@
                         licenses = json.loads(output)
 
         return licenses
+
+    #######################################################################
+    ## Cleanup of the site-packages directory in case pip updated or
+    ## removed packages currently in use.
+    #######################################################################
+
+    def runCleanup(self, envName):
+        """
+        Public method to perform a cleanup run for a given environment.
+
+        @param envName name of the environment to get the licenses for
+        @type str
+        @return flag indicating a successful removal. A missing environment
+            name or an undefined Python interpreter is treated as success
+            (i.e. nothing to do).
+        @rtype bool
+        """
+        if envName:
+            interpreter = self.getVirtualenvInterpreter(envName)
+            if interpreter:
+                args = [os.path.join(os.path.dirname(__file__), "pipcleanup.py")]
+
+                proc = QProcess()
+                proc.start(interpreter, args)
+                if proc.waitForStarted(15000) and proc.waitForFinished(30000):
+                    return proc.exitCode() == 0
+
+                return False
+
+        return True

eric ide

mercurial