diff -r f5f5f5803935 -r 3a1ba42ac50a src/eric7/PipInterface/Pip.py --- 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