diff -r d9f12defd944 -r 51996454f89f Utilities/__init__.py --- a/Utilities/__init__.py Sun Oct 07 18:18:13 2018 +0200 +++ b/Utilities/__init__.py Sat Oct 13 14:08:21 2018 +0200 @@ -1957,6 +1957,42 @@ else: return bool(dataStr) +def getSysPath(interpreter): + """ + Module function to get the Python path (sys.path) of a specific + interpreter. + + @param interpreter Python interpreter executable to get sys.path for + @type str + @return list containing sys.path of the interpreter; an empty list + is returned, if the interpreter is the one used to run eric itself + @rtype list of str + """ + import json + + sysPath = [] + + getSysPath = os.path.join( + getConfig('ericDir'), "Utilities", "GetSysPath.py") + args = [getSysPath] + proc = QProcess() + proc.setProcessChannelMode(QProcess.MergedChannels) + proc.start(interpreter, args) + finished = proc.waitForFinished(30000) + if finished: + if proc.exitCode() == 0: + text = proc.readAllStandardOutput() + sysPathResult = str(text, "utf-8", "replace").strip() + try: + sysPath = json.loads(sysPathResult) + if "" in sysPath: + sysPath.remove("") + except (TypeError, ValueError): + # ignore faulty results and return empty list + pass + + return sysPath + ############################################################################### # posix compatibility functions below ###############################################################################