mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Embedded python package (zip) for Linux (#871)
Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
@@ -17,29 +17,28 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <stdexcept>
|
||||
#define STRINGIFY2(x) #x
|
||||
#define STRINGIFY(x) STRINGIFY2(x)
|
||||
#endif
|
||||
|
||||
#define STRINGIFY2(x) #x
|
||||
#define STRINGIFY(x) STRINGIFY2(x)
|
||||
|
||||
|
||||
PythonInit::PythonInit()
|
||||
{
|
||||
// register modules
|
||||
EffectModule::registerHyperionExtensionModule();
|
||||
|
||||
// set Python module path when exists
|
||||
wchar_t *pythonPath = nullptr;
|
||||
#ifdef _WIN32
|
||||
pythonPath = Py_DecodeLocale((QDir::cleanPath(qApp->applicationDirPath()) + "/python" + STRINGIFY(PYTHON_VERSION_MAJOR_MINOR) + ".zip").toLatin1().data(), nullptr);
|
||||
if(QFile(QString::fromWCharArray(pythonPath)).exists())
|
||||
#else
|
||||
pythonPath = Py_DecodeLocale((QDir::cleanPath(qApp->applicationDirPath() + "/../lib/python")).toLatin1().data(), nullptr);
|
||||
if(QDir(QString::fromWCharArray(pythonPath)).exists())
|
||||
#endif
|
||||
QString py_patch = QDir::cleanPath(qApp->applicationDirPath() + "/../lib/python");
|
||||
QString py_file = QDir::cleanPath(qApp->applicationDirPath() + "/python" + STRINGIFY(PYTHON_VERSION_MAJOR_MINOR) + ".zip");
|
||||
|
||||
if (QFile(py_file).exists() || QDir(py_patch).exists())
|
||||
{
|
||||
Py_NoSiteFlag++;
|
||||
Py_SetPath(pythonPath);
|
||||
PyMem_RawFree(pythonPath);
|
||||
if (QFile(py_file).exists())
|
||||
Py_SetPath(Py_DecodeLocale(py_file.toLatin1().data(), nullptr));
|
||||
else if (QDir(py_patch).exists())
|
||||
Py_SetPath(Py_DecodeLocale(py_patch.toLatin1().data(), nullptr));
|
||||
}
|
||||
|
||||
// init Python
|
||||
|
Reference in New Issue
Block a user