Make python plugins optional during the build process

This commit is contained in:
Michael Zanetti 2020-11-30 20:00:04 +01:00
parent bfaa85979d
commit d1b57be370
3 changed files with 38 additions and 16 deletions

View File

@ -33,7 +33,9 @@
#if QT_VERSION >= QT_VERSION_CHECK(5,12,0)
#include "scriptintegrationplugin.h"
#endif
#ifdef WITH_PYTHON
#include "pythonintegrationplugin.h"
#endif
#include "loggingcategories.h"
#include "typeutils.h"
@ -98,7 +100,9 @@ ThingManagerImplementation::ThingManagerImplementation(HardwareManager *hardware
// Make sure this is always emitted after plugins and things are loaded
QMetaObject::invokeMethod(this, "onLoaded", Qt::QueuedConnection);
#ifdef WITH_PYTHON
PythonIntegrationPlugin::initPython();
#endif
}
ThingManagerImplementation::~ThingManagerImplementation()
@ -120,7 +124,9 @@ ThingManagerImplementation::~ThingManagerImplementation()
}
}
#ifdef WITH_PYTHON
PythonIntegrationPlugin::deinitPython();
#endif
}
QStringList ThingManagerImplementation::pluginSearchDirs()
@ -1293,6 +1299,7 @@ void ThingManagerImplementation::loadPlugins()
qCWarning(dcThingManager()) << "Not loading JS plugin as JS plugin support is not included in this nymea instance.";
#endif
} else if (entry.startsWith("integrationplugin") && entry.endsWith(".py")) {
#ifdef WITH_PYTHON
PythonIntegrationPlugin *p = new PythonIntegrationPlugin(this);
bool ok = p->loadScript(fi.absoluteFilePath());
if (ok) {
@ -1300,6 +1307,9 @@ void ThingManagerImplementation::loadPlugins()
} else {
delete p;
}
#else
qCWarning(dcThingManager()) << "Not loading Python plugin as Python plugin support is not included in this nymea instance.2";
#endif
} else {
// Not a known plugin type
continue;

View File

@ -14,17 +14,22 @@ PKGCONFIG += nymea-mqtt nymea-networkmanager
# For everything below python 3.8 we need to manually select one
packagesExist(python3-embed) {
PKGCONFIG += python3-embed
CONFIG += python
} else:packagesExist(python-3.5) {
# xenial, stretch
PKGCONFIG += python-3.5
CONFIG += python
} else:packagesExist(python-3.6) {
# bionic
PKGCONFIG += python-3.6
CONFIG += python
} else:packagesExist(python-3.7) {
# buster, eoan
PKGCONFIG += python-3.7
CONFIG += python
} else {
error("Python development package not found.")
message("Python development package not found. Building without python support.")
CONFIG -= python
}
target.path = $$[QT_INSTALL_LIBS]
@ -38,20 +43,8 @@ RESOURCES += $$top_srcdir/icons.qrc \
HEADERS += nymeacore.h \
integrations/apikeysprovidersloader.h \
integrations/plugininfocache.h \
integrations/python/pynymealogginghandler.h \
integrations/python/pynymeamodule.h \
integrations/python/pyparam.h \
integrations/python/pystdouthandler.h \
integrations/python/pything.h \
integrations/python/pythingactioninfo.h \
integrations/python/pythingdescriptor.h \
integrations/python/pythingdiscoveryinfo.h \
integrations/python/pythingpairinginfo.h \
integrations/python/pythingsetupinfo.h \
integrations/python/pyutils.h \
integrations/thingmanagerimplementation.h \
integrations/translator.h \
integrations/pythonintegrationplugin.h \
experiences/experiencemanager.h \
ruleengine/ruleengine.h \
ruleengine/rule.h \
@ -134,7 +127,6 @@ SOURCES += nymeacore.cpp \
integrations/plugininfocache.cpp \
integrations/thingmanagerimplementation.cpp \
integrations/translator.cpp \
integrations/pythonintegrationplugin.cpp \
experiences/experiencemanager.cpp \
ruleengine/ruleengine.cpp \
ruleengine/rule.cpp \
@ -210,11 +202,32 @@ SOURCES += nymeacore.cpp \
debugreportgenerator.cpp \
platform/platform.cpp \
versionAtLeast(QT_VERSION, 5.12.0) {
message("Building with JS plugin support")
HEADERS += \
integrations/scriptintegrationplugin.h
SOURCES += \
integrations/scriptintegrationplugin.cpp
}
CONFIG(python) {
message("Building with Python plugin support")
DEFINES += WITH_PYTHON
HEADERS += \
integrations/pythonintegrationplugin.h \
integrations/python/pynymealogginghandler.h \
integrations/python/pynymeamodule.h \
integrations/python/pyparam.h \
integrations/python/pystdouthandler.h \
integrations/python/pything.h \
integrations/python/pythingactioninfo.h \
integrations/python/pythingdescriptor.h \
integrations/python/pythingdiscoveryinfo.h \
integrations/python/pythingpairinginfo.h \
integrations/python/pythingsetupinfo.h \
integrations/python/pyutils.h
SOURCES += \
integrations/pythonintegrationplugin.cpp
}

View File

@ -84,7 +84,6 @@ message("Qt version:" $$[QT_VERSION])
message("Copyright $${COPYRIGHT_YEAR_FROM} - $${COPYRIGHT_YEAR_TO}")
message("Building nymea version $${NYMEA_VERSION_STRING}")
message("JSON-RPC API version $${JSON_PROTOCOL_VERSION_MAJOR}.$${JSON_PROTOCOL_VERSION_MINOR}")
message("REST API version $${REST_API_VERSION}")
message("Source directory: $${top_srcdir}")
message("Build directory: $${top_builddir}")
message("Translations: $${TRANSLATIONS}")