2016-04-27 01:56:16 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <list>
|
|
|
|
|
|
|
|
#include "pymodule.h"
|
|
|
|
|
|
|
|
class PythonInterpreter;
|
|
|
|
|
|
|
|
PythonInterpreter* activateInterpreter(bool global = true, int majorVersion = -1, int minorVersion = -1);
|
|
|
|
|
2016-04-28 06:18:55 +08:00
|
|
|
|
2016-04-27 01:56:16 +08:00
|
|
|
void releaseInterpretor(PythonInterpreter* interpret);
|
|
|
|
|
2016-04-28 06:18:55 +08:00
|
|
|
struct InterpreterDesc {
|
|
|
|
int majorVersion;
|
|
|
|
int minorVersion;
|
|
|
|
std::string imagePath;
|
|
|
|
};
|
|
|
|
|
2016-06-23 07:20:06 +08:00
|
|
|
inline bool operator < (const InterpreterDesc& d1, const InterpreterDesc& d2)
|
|
|
|
{
|
|
|
|
if (d1.majorVersion != d2.majorVersion)
|
|
|
|
return d1.majorVersion < d2.majorVersion;
|
|
|
|
|
|
|
|
if (d1.minorVersion != d2.minorVersion)
|
|
|
|
return d1.minorVersion < d2.minorVersion;
|
|
|
|
|
|
|
|
return d1.imagePath < d2.imagePath;
|
|
|
|
}
|
|
|
|
|
2016-04-28 06:18:55 +08:00
|
|
|
std::list<InterpreterDesc> getInstalledInterpreter();
|
|
|
|
|
2016-06-24 23:05:43 +08:00
|
|
|
void getDefaultInterpreter(int majorVersion, int minorVersion);
|
|
|
|
|
2016-04-28 06:18:55 +08:00
|
|
|
bool isInterpreterLoaded(int majorVersion, int minorVersion);
|
|
|
|
|
|
|
|
void stopAllInterpreter();
|
|
|
|
|
2016-06-22 03:27:57 +08:00
|
|
|
void checkPykd();
|
|
|
|
|
2016-04-28 06:18:55 +08:00
|
|
|
|
2016-04-27 01:56:16 +08:00
|
|
|
class AutoInterpreter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
explicit AutoInterpreter(bool global = true, int majorVersion = -1, int minorVersion = -1)
|
|
|
|
{
|
|
|
|
m_interpreter = activateInterpreter(global, majorVersion, minorVersion);
|
|
|
|
}
|
|
|
|
|
|
|
|
~AutoInterpreter()
|
|
|
|
{
|
|
|
|
if (m_interpreter)
|
|
|
|
releaseInterpretor(m_interpreter);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
AutoInterpreter(const AutoInterpreter&) = delete;
|
|
|
|
|
|
|
|
PythonInterpreter* m_interpreter;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|