--- a/eric7/PipInterface/Pip.py Sun Mar 13 12:46:57 2022 +0100 +++ b/eric7/PipInterface/Pip.py Sun Mar 13 15:20:26 2022 +0100 @@ -771,6 +771,49 @@ return result + def getFrozenPackages(self, envName, localPackages=True, usersite=False, + requirement=None): + """ + Public method to get the list of package specifiers to freeze them. + + @param envName name of the environment to get the package specifiers + for + @type str + @param localPackages flag indicating to get package specifiers for + local packages only + @type bool + @param usersite flag indicating to get package specifiers for packages + installed in user-site only + @type bool + @param requirement name of a requirements file + @type str + @return list of package specifiers + @rtype list of str + """ + specifiers = [] + + if envName: + interpreter = self.getVirtualenvInterpreter(envName) + if interpreter: + args = [ + "-m", "pip", + "freeze", + ] + if localPackages: + args.append("--local") + if usersite: + args.append("--user") + if requirement and os.path.exists(requirement): + args.append("--requirement") + args.append(requirement) + + success, output = self.runProcess(args, interpreter) + if success and output: + specifiers = [spec.strip() for spec in output.splitlines() + if spec.strip()] + + return specifiers + ####################################################################### ## Cache handling methods below #######################################################################