From 8824e18b0a6e1c6fb4b69f88b69a8211b1c7dde5 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 19 Apr 2017 17:37:46 +0100 Subject: [PATCH] Search share/renderdoc/pylibs for python libs. * This is only relevant for static qrenderdoc builds where the python used isn't the system python, so it needs to locate its libs. Otherwise the system libpython3.so and libs will be used. --- qrenderdoc/CMakeLists.txt | 6 +++--- qrenderdoc/Code/pyrenderdoc/PythonContext.cpp | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/qrenderdoc/CMakeLists.txt b/qrenderdoc/CMakeLists.txt index 728177fc7..dc996e5e7 100644 --- a/qrenderdoc/CMakeLists.txt +++ b/qrenderdoc/CMakeLists.txt @@ -6,16 +6,16 @@ option(QRENDERDOC_NO_CXX11_REGEX "Disable C++11 regex in scintilla" OFF) set(QMAKE_CONFIG "debug") set(QMAKE_LDFLAGS "") +set(QMAKE_CXXFLAGS "") if(STATIC_QRENDERDOC) + set(QMAKE_CXXFLAGS "-DSTATIC_QRENDERDOC=1") set(QMAKE_CONFIG "debug static") set(QMAKE_LDFLAGS "-static-libstdc++ -lutil") endif() -set(QMAKE_CXXFLAGS "") - if(QRENDERDOC_NO_CXX11_REGEX) - set(QMAKE_CXXFLAGS "-DNO_CXX11_REGEX=1") + set(QMAKE_CXXFLAGS "-DNO_CXX11_REGEX=1 ${QMAKE_CXXFLAGS}") endif() if(ENABLE_GL) diff --git a/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp b/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp index e3dc41197..3a1049f6b 100644 --- a/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp +++ b/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp @@ -41,7 +41,9 @@ PyTypeObject **SbkPySide2_QtWidgetsTypes = NULL; #include #include +#include #include +#include #include #include #include "PythonContext.h" @@ -112,6 +114,7 @@ static inline QString ToQStr(PyObject *value) } static wchar_t program_name[] = L"qrenderdoc"; +static wchar_t python_home[1024] = {0}; struct OutputRedirector { @@ -207,6 +210,19 @@ void PythonContext::GlobalInit() PyImport_AppendInittab("_renderdoc", &PyInit__renderdoc); PyImport_AppendInittab("_qrenderdoc", &PyInit__qrenderdoc); +#if defined(STATIC_QRENDERDOC) + // add the location where our libs will be for statically-linked python installs + { + QDir bin = QFileInfo(QCoreApplication::applicationFilePath()).absoluteDir(); + + QString pylibs = QDir::cleanPath(bin.absoluteFilePath("../share/renderdoc/pylibs")); + + pylibs.toWCharArray(python_home); + + Py_SetPythonHome(python_home); + } +#endif + Py_SetProgramName(program_name); Py_Initialize();