mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Merge pull request #99 from Holt59/no-more-external-python
Remove support for external Python.
This commit is contained in:
@@ -1164,12 +1164,12 @@ public:
|
||||
PythonRunner();
|
||||
~PythonRunner();
|
||||
|
||||
bool initPython(const QString& pythonDir);
|
||||
bool initPython();
|
||||
|
||||
QList<QObject*> load(const QString& identifier);
|
||||
void unload(const QString& identifier);
|
||||
|
||||
bool isPythonInstalled() const;
|
||||
bool isPythonInitialized() const;
|
||||
bool isPythonVersionSupported() const;
|
||||
|
||||
private:
|
||||
@@ -1201,14 +1201,13 @@ private:
|
||||
wchar_t* m_PythonHome;
|
||||
};
|
||||
|
||||
IPythonRunner* CreatePythonRunner(const QString& pythonDir)
|
||||
IPythonRunner* CreatePythonRunner()
|
||||
{
|
||||
PythonRunner* result = new PythonRunner;
|
||||
if (result->initPython(pythonDir)) {
|
||||
return result;
|
||||
std::unique_ptr<PythonRunner> result = std::make_unique<PythonRunner>();
|
||||
if (result->initPython()) {
|
||||
return result.release();
|
||||
}
|
||||
else {
|
||||
delete result;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -1306,19 +1305,11 @@ BOOST_PYTHON_MODULE(moprivate)
|
||||
}, bpy::arg("callback") = bpy::object{});
|
||||
}
|
||||
|
||||
bool PythonRunner::initPython(const QString &pythonPath)
|
||||
bool PythonRunner::initPython()
|
||||
{
|
||||
if (Py_IsInitialized())
|
||||
return true;
|
||||
try {
|
||||
if (!pythonPath.isEmpty() && !QFile::exists(pythonPath + "/python.exe")) {
|
||||
return false;
|
||||
}
|
||||
pythonPath.toWCharArray(m_PythonHome);
|
||||
if (!pythonPath.isEmpty()) {
|
||||
Py_SetPythonHome(m_PythonHome);
|
||||
}
|
||||
|
||||
wchar_t argBuffer[MAX_PATH];
|
||||
const size_t cSize = strlen(argv0) + 1;
|
||||
mbstowcs(argBuffer, argv0, MAX_PATH);
|
||||
@@ -1568,15 +1559,7 @@ void PythonRunner::unload(const QString& identifier)
|
||||
}
|
||||
}
|
||||
|
||||
bool PythonRunner::isPythonInstalled() const
|
||||
bool PythonRunner::isPythonInitialized() const
|
||||
{
|
||||
return Py_IsInitialized() != 0;
|
||||
}
|
||||
|
||||
|
||||
bool PythonRunner::isPythonVersionSupported() const
|
||||
{
|
||||
const char *version = Py_GetVersion();
|
||||
return strstr(version, "3.8") == version;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user