From 1244f1a32fc62dcb28c49fbb1129e6cb3efdf880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Sun, 10 Mar 2019 16:54:55 +0100 Subject: [PATCH] fix python home and path on windows --- CMakeLists.txt | 4 ++-- src/python_interpreter.cc | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74b2a17..f133543 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ if(${CMAKE_VERSION} VERSION_GREATER 3.11.4) find_path(Python3_INCLUDE_DIRS "Python.h" HINTS "${MINGW_INCLUDE_DIR}/python${MINGW_PYTHON_VERSION}m" NO_DEFAULT_PATH) if (EXISTS ${Python3_LIBRARIES} AND EXISTS ${Python3_INCLUDE_DIRS}) set(Python3_FOUND True) - set(Python3_LIBRARY_DIRS "${MINGW_LIBRARY_DIR}/python${MINGW_PYTHON_VERSION}") + set(Python3_LIBRARY_DIRS ${MINGW_LIBRARY_DIR}) set(Python3_VERSION_MAJOR 3) set(Python3_VERSION_MINOR 7) endif() @@ -76,7 +76,6 @@ endif() if(${Python3_FOUND}) if(${CMAKE_HOST_WIN32}) - set(PYTHONLIBS_FOUND True) set(PYTHON_MODULE_EXTENSION True) endif() set(PYTHONLIBS_FOUND ${Python3_FOUND}) @@ -99,6 +98,7 @@ endif() if(${PYGOBJECT_FOUND}) add_definitions(-DJUCI_ENABLE_PLUGINS) + add_definitions(-DPYTHON_HOME_DIR=L"${PYTHON_LIBRARY_DIR}") else() message(STATUS "Python or pygobject not found. Building juCi++ without plugin support.") endif() diff --git a/src/python_interpreter.cc b/src/python_interpreter.cc index bc03174..5d5d2e0 100644 --- a/src/python_interpreter.cc +++ b/src/python_interpreter.cc @@ -27,5 +27,13 @@ Python::Interpreter::~Interpreter() { } Python::Interpreter::Interpreter() { +#ifdef PYTHON_HOME_DIR +#ifdef _WIN32 + const std::wstring python_home(PYTHON_HOME_DIR); + const std::wstring python_path(python_home + L";" + python_home + L"\\lib-dynload;" + python_home + L"\\site-packages" ); + Py_SetPythonHome(python_home.c_str()); + Py_SetPath(python_path.c_str()); +#endif +#endif py::initialize_interpreter(); }