Skip to content

Commit

Permalink
Fix for Python debug build (#128)
Browse files Browse the repository at this point in the history
* Minor updates for debug Python/PyQt.
* Fix issue with destructor of lambda in shared holder.
  • Loading branch information
Holt59 authored Jun 14, 2024
1 parent 8c044e2 commit 5bb4de0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ set(PYTHON_BUILD_PATH ${PYTHON_ROOT}/PCBuild/amd64)
set(Python_USE_STATIC_LIBS False)
set(Python_INCLUDE_DIR ${PYTHON_ROOT}/Include)
set(Python_EXECUTABLE ${PYTHON_BUILD_PATH}/python.exe)
if (EXISTS "${PYTHON_BUILD_PATH}/python_d.exe")
set(Python_EXECUTABLE ${PYTHON_BUILD_PATH}/python_d.exe)
endif()
file(GLOB Python_LIBRARY ${PYTHON_BUILD_PATH}/python[0-9][0-9]*.lib)
find_package(Python COMPONENTS Interpreter Development REQUIRED)

Expand Down
1 change: 0 additions & 1 deletion src/plugin_python_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ Do you want to try initializing python again (at the risk of another crash)?
<message>
<location filename="proxy/proxypython.cpp" line="260"/>
<source>The path to Mod Organizer (%1) contains a semicolon.&lt;br&gt;While this is legal on NTFS drives, many applications do not handle it correctly.&lt;br&gt;Unfortunately MO depends on libraries that seem to fall into that group.&lt;br&gt;As a result the python plugin cannot be loaded, and the only solution we can offer is to remove the semicolon or move MO to a path without a semicolon.</source>
<oldsource>The path to Mod Organizer (%1) contains a semicolon. &lt;br&gt;While this is legal on NTFS drives, many softwares do not handle it correctly.&lt;br&gt;Unfortunately MO depends on libraries that seem to fall into that group.&lt;br&gt;As a result the python plugin cannot be loaded, and the only solution we canoffer is to remove the semicolon or move MO to a path without a semicolon.</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
Expand Down
2 changes: 1 addition & 1 deletion src/proxy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mo2_add_translations(proxy
set(DLL_DIRS ${PLUGIN_PYTHON_DIR}/dlls)
file(GLOB dlls_to_install
${PYTHON_BUILD_PATH}/libffi*.dll
${PYTHON_BUILD_PATH}/python${Python_VERSION_SHORT}.dll)
${PYTHON_BUILD_PATH}/python${Python_VERSION_SHORT}*.dll)
install(FILES ${dlls_to_install} DESTINATION ${DLL_DIRS})

# install Python files
Expand Down
2 changes: 1 addition & 1 deletion src/pybind11-qt/include/pybind11_qt/pybind11_qt_holder.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace pybind11::detail::qt {
~qobject_holder_impl()
{
gil_scoped_acquire s;
p_ = std::move(none());
p_ = object();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace mo2::python::detail {
holder.reset(holder.get(), [pyobj = py::reinterpret_borrow<py::object>(
src)](auto*) mutable {
py::gil_scoped_acquire s;
pyobj = std::move(py::none());
pyobj = py::object();

// we do NOT delete the object here - if this was the last reference to
// the Python object, the Python object will delete it
Expand Down
16 changes: 9 additions & 7 deletions src/runner/pythonrunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ namespace mo2::python {
return false;
}

py::module_ mainModule = py::module_::import("__main__");
py::object mainNamespace = mainModule.attr("__dict__");
mainNamespace["sys"] = py::module_::import("sys");
mainNamespace["mobase"] = py::module_::import("mobase");

mo2::python::configure_python_stream();
mo2::python::configure_python_logging(mainNamespace["mobase"]);
{
py::module_ mainModule = py::module_::import("__main__");
py::object mainNamespace = mainModule.attr("__dict__");
mainNamespace["sys"] = py::module_::import("sys");
mainNamespace["mobase"] = py::module_::import("mobase");

mo2::python::configure_python_stream();
mo2::python::configure_python_logging(mainNamespace["mobase"]);
}

// we need to release the GIL here - which is what this does
//
Expand Down

0 comments on commit 5bb4de0

Please sign in to comment.