diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index b2d7cf4..4940fcc 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -14,7 +14,7 @@ jobs: id: build-plugin-python uses: ModOrganizer2/build-with-mob-action@master with: - mo2-third-parties: fmt gtest python spdlog boost sip pyqt pybind11 + mo2-third-parties: gtest python spdlog boost sip pyqt pybind11 mo2-dependencies: cmake_common uibase mo2-cmake-command: -DPLUGIN_PYTHON_TESTS=1 .. - name: Build Plugin Python Tests diff --git a/CMakeLists.txt b/CMakeLists.txt index a65e6d0..bb45be8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.16) +cmake_policy(SET CMP0144 NEW) + if(DEFINED DEPENDENCIES_DIR) include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/mo2.cmake) else() @@ -14,9 +16,14 @@ 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) -file(GLOB Python_LIBRARY ${PYTHON_BUILD_PATH}/python[0-9]+.lib) +file(GLOB Python_LIBRARY ${PYTHON_BUILD_PATH}/python[0-9][0-9]*.lib) find_package(Python COMPONENTS Interpreter Development REQUIRED) +# pybind11 needs uppercase (at least EXECUTABLE and LIBRARY) +set(PYTHON_EXECUTABLE ${Python_EXECUTABLE}) +set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIR}) +set(PYTHON_LIBRARY ${Python_LIBRARY}) + # useful for naming DLL, zip, etc. (3.10 -> 310) set(Python_VERSION_SHORT ${Python_VERSION_MAJOR}${Python_VERSION_MINOR}) diff --git a/src/mobase/mobase.cpp b/src/mobase/mobase.cpp index 2415af6..a6b1032 100644 --- a/src/mobase/mobase.cpp +++ b/src/mobase/mobase.cpp @@ -1,6 +1,7 @@ #pragma warning(disable : 4100) #pragma warning(disable : 4996) +#include #include #include @@ -15,7 +16,6 @@ #include #include #include -#include #include #include #include diff --git a/src/mobase/wrappers/basic_classes.cpp b/src/mobase/wrappers/basic_classes.cpp index cf8e037..169c4f3 100644 --- a/src/mobase/wrappers/basic_classes.cpp +++ b/src/mobase/wrappers/basic_classes.cpp @@ -2,11 +2,7 @@ #include "../pybind11_all.h" -#pragma warning(push) -#pragma warning(disable : 4459) -#include -#include -#pragma warning(pop) +#include #include #include @@ -763,7 +759,7 @@ namespace mo2::python { .def_readwrite("isDirectory", &Mapping::isDirectory) .def_readwrite("createTarget", &Mapping::createTarget) .def("__str__", [](Mapping const& m) { - return fmt::format(L"Mapping({}, {}, {}, {})", m.source.toStdWString(), + return std::format(L"Mapping({}, {}, {}, {})", m.source.toStdWString(), m.destination.toStdWString(), m.isDirectory, m.createTarget); }); diff --git a/src/plugin_python_en.ts b/src/plugin_python_en.ts deleted file mode 100644 index 9bad015..0000000 --- a/src/plugin_python_en.ts +++ /dev/null @@ -1,83 +0,0 @@ - - - - - ProxyPython - - - Python Initialization failed - - - - - On a previous start the Python Plugin failed to initialize. -Do you want to try initializing python again (at the risk of another crash)? - Suggestion: Select "no", and click the warning sign for further help.Afterwards you have to re-enable the python plugin. - - - - - Python Proxy - - - - - Proxy Plugin to allow plugins written in python to be loaded - - - - - ModOrganizer path contains a semicolon - - - - - Python DLL not found - - - - - Invalid Python DLL - - - - - Initializing Python failed - - - - - - invalid problem key %1 - - - - - The path to Mod Organizer (%1) contains a semicolon. <br>While this is legal on NTFS drives, many softwares do not handle it correctly.<br>Unfortunately MO depends on libraries that seem to fall into that group.<br>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. - - - - - The Python plugin DLL was not found, maybe your antivirus deleted it. Re-installing MO2 might fix the problem. - - - - - The Python plugin DLL is invalid, maybe your antivirus is blocking it. Re-installing MO2 and adding exclusions for it to your AV might fix the problem. - - - - - The initialization of the Python plugin DLL failed, unfortunately without any details. - - - - - QObject - - - An unknown exception was thrown in python code. - - - - diff --git a/src/runner/error.h b/src/runner/error.h index ac8683f..d38c8af 100644 --- a/src/runner/error.h +++ b/src/runner/error.h @@ -1,9 +1,10 @@ #ifndef ERROR_H #define ERROR_H +#include + #include -#include #include #include @@ -19,7 +20,7 @@ namespace pyexcept { MissingImplementation(std::string const& className, std::string const& methodName) : Exception(QString::fromStdString( - fmt::format("Python class implementing \"{}\" has no " + std::format("Python class implementing \"{}\" has no " "implementation of method \"{}\".", className, methodName))) { diff --git a/src/runner/pythonutils.cpp b/src/runner/pythonutils.cpp index 0aed5a1..9cc3a75 100644 --- a/src/runner/pythonutils.cpp +++ b/src/runner/pythonutils.cpp @@ -25,7 +25,7 @@ namespace mo2::python { buffer_ << message; if (buffer_.tellp() != 0 && buffer_.str().back() == '\n') { const auto full_message = buffer_.str(); - MOBase::log::log(level_, + MOBase::log::log(level_, "{}", full_message.substr(0, full_message.length() - 1)); buffer_ = std::stringstream{}; } diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt index 8cefd01..69d3dea 100644 --- a/tests/python/CMakeLists.txt +++ b/tests/python/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.16) # pytest +cmake_policy(SET CMP0144 NEW) find_package(GTest REQUIRED) set(PYLIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/pylibs)