mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Move to VCPKG (#133)
This commit is contained in:
@@ -2,24 +2,37 @@ name: Build & Test Plugin Python
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: master
|
||||
branches: [master]
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
env:
|
||||
VCPKG_BINARY_SOURCES: clear;x-azblob,${{ vars.AZ_BLOB_VCPKG_URL }},${{ secrets.AZ_BLOB_SAS }},readwrite
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- name: Build Plugin Python
|
||||
id: build-plugin-python
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: Configure Plugin Python
|
||||
id: configure-plugin-python
|
||||
uses: ModOrganizer2/build-with-mob-action@master
|
||||
with:
|
||||
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
|
||||
run: cmake --build vsbuild --config RelWithDebInfo -j4 --target python-tests --target runner-tests
|
||||
working-directory: ${{ steps.build-plugin-python.outputs.working-directory }}
|
||||
mo2-dependencies: uibase
|
||||
mo2-skip-build: true
|
||||
|
||||
- name: Build Plugin Python
|
||||
working-directory: ${{ steps.configure-plugin-python.outputs.working-directory }}
|
||||
run: cmake --build vsbuild --config RelWithDebInfo --verbose `
|
||||
--target python-tests --target runner-tests --target proxy
|
||||
|
||||
- name: Test Plugin Python
|
||||
working-directory: ${{ steps.configure-plugin-python.outputs.working-directory }}
|
||||
run: ctest --test-dir vsbuild -C RelWithDebInfo --output-on-failure
|
||||
working-directory: ${{ steps.build-plugin-python.outputs.working-directory }}
|
||||
|
||||
- name: Install Plugin Python
|
||||
working-directory: ${{ steps.configure-plugin-python.outputs.working-directory }}
|
||||
run: cmake --build vsbuild --config RelWithDebInfo --target INSTALL
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v5.0.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-merge-conflict
|
||||
- id: check-case-conflict
|
||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
rev: v19.1.5
|
||||
hooks:
|
||||
- id: clang-format
|
||||
'types_or': [c++, c]
|
||||
|
||||
ci:
|
||||
autofix_commit_msg: "[pre-commit.ci] Auto fixes from pre-commit.com hooks."
|
||||
autofix_prs: true
|
||||
autoupdate_commit_msg: "[pre-commit.ci] Pre-commit autoupdate."
|
||||
autoupdate_schedule: quarterly
|
||||
submodules: false
|
||||
+14
-26
@@ -2,44 +2,32 @@ 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()
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../cmake_common/mo2.cmake)
|
||||
endif()
|
||||
|
||||
project(plugin_python CXX)
|
||||
|
||||
set(PYTHON_BUILD_PATH ${PYTHON_ROOT}/PCBuild/amd64)
|
||||
set(Python_FIND_VIRTUALENV STANDARD)
|
||||
|
||||
# find Python - lots of "Hints" since we have a weird setup
|
||||
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)
|
||||
# find Python before include mo2-cmake, otherwise this will trigger a bunch of CMP0111
|
||||
# due to the imported configuration mapping variables defined in mo2.cmake
|
||||
find_package(Python ${MO2_PYTHON_VERSION} COMPONENTS Interpreter Development REQUIRED)
|
||||
find_package(pybind11 CONFIG 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})
|
||||
find_package(mo2-cmake CONFIG REQUIRED)
|
||||
|
||||
get_filename_component(Python_HOME ${Python_EXECUTABLE} PATH)
|
||||
set(Python_DLL_DIR "${Python_HOME}/DLLs")
|
||||
set(Python_LIB_DIR "${Python_HOME}/Lib")
|
||||
|
||||
mo2_python_install_pyqt()
|
||||
|
||||
# useful for naming DLL, zip, etc. (3.10 -> 310)
|
||||
set(Python_VERSION_SHORT ${Python_VERSION_MAJOR}${Python_VERSION_MINOR})
|
||||
|
||||
# pybind11
|
||||
add_subdirectory(${MO2_BUILD_PATH}/pybind11 ${CMAKE_CURRENT_BINARY_DIR}/pybind11)
|
||||
|
||||
# projects
|
||||
add_subdirectory(src)
|
||||
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT proxy)
|
||||
|
||||
# tests (if requested)
|
||||
set(PLUGIN_PYTHON_TESTS ${PLUGIN_PYTHON_TESTS} CACHE BOOL "build tests for plugin_python")
|
||||
if (PLUGIN_PYTHON_TESTS)
|
||||
set(BUILD_TESTING ${BUILD_TESTING} CACHE BOOL "build tests for plugin_python")
|
||||
if (BUILD_TESTING)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"configurePresets": [
|
||||
{
|
||||
"errors": {
|
||||
"deprecated": true
|
||||
},
|
||||
"hidden": true,
|
||||
"name": "cmake-dev",
|
||||
"warnings": {
|
||||
"deprecated": true,
|
||||
"dev": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"cacheVariables": {
|
||||
"VCPKG_MANIFEST_NO_DEFAULT_FEATURES": {
|
||||
"type": "BOOL",
|
||||
"value": "ON"
|
||||
}
|
||||
},
|
||||
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
|
||||
"hidden": true,
|
||||
"name": "vcpkg"
|
||||
},
|
||||
{
|
||||
"cacheVariables": {
|
||||
"VCPKG_MANIFEST_FEATURES": {
|
||||
"type": "STRING",
|
||||
"value": "testing"
|
||||
}
|
||||
},
|
||||
"hidden": true,
|
||||
"inherits": ["vcpkg"],
|
||||
"name": "vcpkg-dev"
|
||||
},
|
||||
{
|
||||
"binaryDir": "${sourceDir}/vsbuild",
|
||||
"architecture": {
|
||||
"strategy": "set",
|
||||
"value": "x64"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4",
|
||||
"VCPKG_TARGET_TRIPLET": {
|
||||
"type": "STRING",
|
||||
"value": "x64-windows-static-md"
|
||||
}
|
||||
},
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"inherits": ["cmake-dev", "vcpkg-dev"],
|
||||
"name": "vs2022-windows",
|
||||
"toolset": "v143"
|
||||
},
|
||||
{
|
||||
"cacheVariables": {
|
||||
"VCPKG_MANIFEST_FEATURES": {
|
||||
"type": "STRING",
|
||||
"value": "standalone;testing"
|
||||
}
|
||||
},
|
||||
"inherits": "vs2022-windows",
|
||||
"name": "vs2022-windows-standalone"
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "vs2022-windows",
|
||||
"resolvePackageReferences": "on",
|
||||
"configurePreset": "vs2022-windows"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
@@ -1,12 +1,38 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
find_package(Qt6 COMPONENTS Core)
|
||||
find_package(mo2-uibase CONFIG REQUIRED)
|
||||
|
||||
pybind11_add_module(mobase MODULE)
|
||||
mo2_configure_library(mobase
|
||||
SOURCE_TREE
|
||||
mo2_default_source_group()
|
||||
mo2_configure_target(mobase
|
||||
NO_SOURCES
|
||||
WARNINGS 4
|
||||
EXTERNAL_WARNINGS 4
|
||||
AUTOMOC ON
|
||||
TRANSLATIONS OFF
|
||||
PRIVATE_DEPENDS uibase Qt::Core
|
||||
)
|
||||
target_link_libraries(mobase PRIVATE pybind11::qt pybind11::utils)
|
||||
mo2_target_sources(mobase
|
||||
FOLDER src
|
||||
PRIVATE
|
||||
deprecation.cpp
|
||||
deprecation.h
|
||||
mobase.cpp
|
||||
pybind11_all.h
|
||||
)
|
||||
mo2_target_sources(mobase
|
||||
FOLDER src/wrappers
|
||||
PRIVATE
|
||||
./wrappers/basic_classes.cpp
|
||||
./wrappers/game_features.cpp
|
||||
./wrappers/known_folders.h
|
||||
./wrappers/pyfiletree.cpp
|
||||
./wrappers/pyfiletree.h
|
||||
./wrappers/pyplugins.cpp
|
||||
./wrappers/pyplugins.h
|
||||
./wrappers/utils.cpp
|
||||
./wrappers/widgets.cpp
|
||||
./wrappers/wrappers.cpp
|
||||
./wrappers/wrappers.h
|
||||
)
|
||||
target_link_libraries(mobase PRIVATE pybind11::qt pybind11::utils mo2::uibase Qt6::Core)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "log.h"
|
||||
#include <uibase/log.h>
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
|
||||
@@ -12,23 +12,6 @@
|
||||
#include "wrappers/pyfiletree.h"
|
||||
#include "wrappers/wrappers.h"
|
||||
|
||||
// TODO: remove these include (only for testing)
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QWidget>
|
||||
#include <iplugin.h>
|
||||
#include <iplugindiagnose.h>
|
||||
#include <ipluginfilemapper.h>
|
||||
#include <iplugingame.h>
|
||||
#include <iplugininstaller.h>
|
||||
#include <iplugininstallersimple.h>
|
||||
#include <ipluginlist.h>
|
||||
#include <ipluginmodpage.h>
|
||||
#include <ipluginpreview.h>
|
||||
#include <iplugintool.h>
|
||||
#include <isavegame.h>
|
||||
#include <isavegameinfowidget.h>
|
||||
|
||||
using namespace MOBase;
|
||||
namespace py = pybind11;
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
#include "pybind11_utils/shared_cpp_owner.h"
|
||||
#include "pybind11_utils/smart_variant_wrapper.h"
|
||||
|
||||
#include <game_feature.h>
|
||||
#include <isavegame.h>
|
||||
#include <pluginrequirements.h>
|
||||
#include <uibase/game_features/game_feature.h>
|
||||
#include <uibase/isavegame.h>
|
||||
#include <uibase/pluginrequirements.h>
|
||||
|
||||
namespace mo2::python {
|
||||
|
||||
|
||||
@@ -4,21 +4,21 @@
|
||||
|
||||
#include <format>
|
||||
|
||||
#include <executableinfo.h>
|
||||
#include <filemapping.h>
|
||||
#include <guessedvalue.h>
|
||||
#include <idownloadmanager.h>
|
||||
#include <igamefeatures.h>
|
||||
#include <iinstallationmanager.h>
|
||||
#include <imodinterface.h>
|
||||
#include <imodrepositorybridge.h>
|
||||
#include <imoinfo.h>
|
||||
#include <iplugin.h>
|
||||
#include <iplugindiagnose.h>
|
||||
#include <iplugingame.h>
|
||||
#include <ipluginlist.h>
|
||||
#include <pluginsetting.h>
|
||||
#include <versioninfo.h>
|
||||
#include <uibase/executableinfo.h>
|
||||
#include <uibase/filemapping.h>
|
||||
#include <uibase/game_features/igamefeatures.h>
|
||||
#include <uibase/guessedvalue.h>
|
||||
#include <uibase/idownloadmanager.h>
|
||||
#include <uibase/iinstallationmanager.h>
|
||||
#include <uibase/imodinterface.h>
|
||||
#include <uibase/imodrepositorybridge.h>
|
||||
#include <uibase/imoinfo.h>
|
||||
#include <uibase/iplugin.h>
|
||||
#include <uibase/iplugindiagnose.h>
|
||||
#include <uibase/iplugingame.h>
|
||||
#include <uibase/ipluginlist.h>
|
||||
#include <uibase/pluginsetting.h>
|
||||
#include <uibase/versioninfo.h>
|
||||
|
||||
#include "../deprecation.h"
|
||||
#include "pyfiletree.h"
|
||||
@@ -33,6 +33,69 @@ namespace mo2::python {
|
||||
|
||||
void add_versioninfo_classes(py::module_ m)
|
||||
{
|
||||
// Version
|
||||
py::class_<Version> pyVersion(m, "Version");
|
||||
|
||||
py::enum_<Version::ReleaseType>(pyVersion, "ReleaseType")
|
||||
.value("DEVELOPMENT", Version::Development)
|
||||
.value("ALPHA", Version::Alpha)
|
||||
.value("BETA", Version::Beta)
|
||||
.value("RELEASE_CANDIDATE", Version::ReleaseCandidate)
|
||||
.export_values();
|
||||
|
||||
py::enum_<Version::ParseMode>(pyVersion, "ParseMode")
|
||||
.value("SEMVER", Version::ParseMode::SemVer)
|
||||
.value("MO2", Version::ParseMode::MO2);
|
||||
|
||||
py::enum_<Version::FormatMode>(pyVersion, "FormatMode", py::arithmetic{})
|
||||
.value("FORCE_SUBPATCH", Version::FormatMode::ForceSubPatch)
|
||||
.value("NO_SEPARATOR", Version::FormatMode::NoSeparator)
|
||||
.value("SHORT_ALPHA_BETA", Version::FormatMode::ShortAlphaBeta)
|
||||
.value("NO_METADATA", Version::FormatMode::NoMetadata)
|
||||
.value("CONDENSED",
|
||||
static_cast<Version::FormatMode>(Version::FormatCondensed.toInt()))
|
||||
.export_values();
|
||||
|
||||
pyVersion
|
||||
.def_static("parse", &Version::parse, "value"_a,
|
||||
"mode"_a = Version::ParseMode::SemVer)
|
||||
.def(py::init<int, int, int, QString>(), "major"_a, "minor"_a, "patch"_a,
|
||||
"metadata"_a = "")
|
||||
.def(py::init<int, int, int, int, QString>(), "major"_a, "minor"_a,
|
||||
"patch"_a, "subpatch"_a, "metadata"_a = "")
|
||||
.def(py::init<int, int, int, Version::ReleaseType, QString>(), "major"_a,
|
||||
"minor"_a, "patch"_a, "type"_a, "metadata"_a = "")
|
||||
.def(py::init<int, int, int, int, Version::ReleaseType, QString>(),
|
||||
"major"_a, "minor"_a, "patch"_a, "subpatch"_a, "type"_a,
|
||||
"metadata"_a = "")
|
||||
.def(py::init<int, int, int, Version::ReleaseType, int, QString>(),
|
||||
"major"_a, "minor"_a, "patch"_a, "type"_a, "prerelease"_a,
|
||||
"metadata"_a = "")
|
||||
.def(py::init<int, int, int, int, Version::ReleaseType, int, QString>(),
|
||||
"major"_a, "minor"_a, "patch"_a, "subpatch"_a, "type"_a,
|
||||
"prerelease"_a, "metadata"_a = "")
|
||||
.def(py::init<int, int, int, int,
|
||||
std::vector<std::variant<int, Version::ReleaseType>>,
|
||||
QString>(),
|
||||
"major"_a, "minor"_a, "patch"_a, "subpatch"_a, "prereleases"_a,
|
||||
"metadata"_a = "")
|
||||
.def("isPreRelease", &Version::isPreRelease)
|
||||
.def_property_readonly("major", &Version::major)
|
||||
.def_property_readonly("minor", &Version::minor)
|
||||
.def_property_readonly("patch", &Version::patch)
|
||||
.def_property_readonly("subpatch", &Version::subpatch)
|
||||
.def_property_readonly("prereleases", &Version::preReleases)
|
||||
.def_property_readonly("build_metadata", &Version::buildMetadata)
|
||||
.def("string", &Version::string, "mode"_a = Version::FormatCondensed)
|
||||
.def("__str__", &Version::string)
|
||||
.def(py::self < py::self)
|
||||
.def(py::self > py::self)
|
||||
.def(py::self <= py::self)
|
||||
.def(py::self >= py::self)
|
||||
.def(py::self != py::self)
|
||||
.def(py::self == py::self);
|
||||
|
||||
// VersionInfo
|
||||
py::enum_<MOBase::VersionInfo::ReleaseType>(m, "ReleaseType")
|
||||
.value("final", MOBase::VersionInfo::RELEASE_FINAL)
|
||||
.value("candidate", MOBase::VersionInfo::RELEASE_CANDIDATE)
|
||||
@@ -453,7 +516,17 @@ namespace mo2::python {
|
||||
.def("overwritePath", &IOrganizer::overwritePath)
|
||||
.def("basePath", &IOrganizer::basePath)
|
||||
.def("modsPath", &IOrganizer::modsPath)
|
||||
.def("appVersion", &IOrganizer::appVersion)
|
||||
.def("appVersion",
|
||||
[](IOrganizer& o) {
|
||||
mo2::python::show_deprecation_warning(
|
||||
"appVersion", "IOrganizer::appVersion() is deprecated, use "
|
||||
"IOrganizer::version() instead.");
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996)
|
||||
return o.appVersion();
|
||||
#pragma warning(pop)
|
||||
})
|
||||
.def("version", &IOrganizer::version)
|
||||
.def("createMod", &IOrganizer::createMod,
|
||||
py::return_value_policy::reference, "name"_a)
|
||||
.def("getGame", &IOrganizer::getGame, py::return_value_policy::reference,
|
||||
|
||||
@@ -4,19 +4,19 @@
|
||||
|
||||
#include "../pybind11_all.h"
|
||||
|
||||
#include <ipluginlist.h>
|
||||
#include <isavegameinfowidget.h>
|
||||
#include <uibase/ipluginlist.h>
|
||||
#include <uibase/isavegameinfowidget.h>
|
||||
|
||||
#include <bsainvalidation.h>
|
||||
#include <dataarchives.h>
|
||||
#include <gameplugins.h>
|
||||
#include <igamefeatures.h>
|
||||
#include <localsavegames.h>
|
||||
#include <moddatachecker.h>
|
||||
#include <moddatacontent.h>
|
||||
#include <savegameinfo.h>
|
||||
#include <scriptextender.h>
|
||||
#include <unmanagedmods.h>
|
||||
#include <uibase/game_features/bsainvalidation.h>
|
||||
#include <uibase/game_features/dataarchives.h>
|
||||
#include <uibase/game_features/gameplugins.h>
|
||||
#include <uibase/game_features/igamefeatures.h>
|
||||
#include <uibase/game_features/localsavegames.h>
|
||||
#include <uibase/game_features/moddatachecker.h>
|
||||
#include <uibase/game_features/moddatacontent.h>
|
||||
#include <uibase/game_features/savegameinfo.h>
|
||||
#include <uibase/game_features/scriptextender.h>
|
||||
#include <uibase/game_features/unmanagedmods.h>
|
||||
|
||||
#include "pyfiletree.h"
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
#include "../pybind11_all.h"
|
||||
|
||||
#include <ifiletree.h>
|
||||
#include <log.h>
|
||||
#include <uibase/ifiletree.h>
|
||||
#include <uibase/log.h>
|
||||
|
||||
namespace py = pybind11;
|
||||
using namespace MOBase;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "../pybind11_all.h"
|
||||
|
||||
#include <ifiletree.h>
|
||||
#include <uibase/ifiletree.h>
|
||||
|
||||
namespace pybind11 {
|
||||
template <>
|
||||
|
||||
@@ -3,18 +3,18 @@
|
||||
|
||||
#include "../pybind11_all.h"
|
||||
|
||||
#include <iinstallationmanager.h>
|
||||
#include <uibase/iinstallationmanager.h>
|
||||
|
||||
#include <iplugin.h>
|
||||
#include <iplugindiagnose.h>
|
||||
#include <ipluginfilemapper.h>
|
||||
#include <iplugingame.h>
|
||||
#include <iplugininstaller.h>
|
||||
#include <iplugininstallercustom.h>
|
||||
#include <iplugininstallersimple.h>
|
||||
#include <ipluginmodpage.h>
|
||||
#include <ipluginpreview.h>
|
||||
#include <iplugintool.h>
|
||||
#include <uibase/iplugin.h>
|
||||
#include <uibase/iplugindiagnose.h>
|
||||
#include <uibase/ipluginfilemapper.h>
|
||||
#include <uibase/iplugingame.h>
|
||||
#include <uibase/iplugininstaller.h>
|
||||
#include <uibase/iplugininstallercustom.h>
|
||||
#include <uibase/iplugininstallersimple.h>
|
||||
#include <uibase/ipluginmodpage.h>
|
||||
#include <uibase/ipluginpreview.h>
|
||||
#include <uibase/iplugintool.h>
|
||||
|
||||
// these needs to be defined in a header file for automoc - this file is included only
|
||||
// in pyplugins.cpp
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include "../pybind11_all.h"
|
||||
|
||||
#include <report.h>
|
||||
#include <utility.h>
|
||||
#include <uibase/report.h>
|
||||
#include <uibase/utility.h>
|
||||
|
||||
#include "known_folders.h"
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "../pybind11_all.h"
|
||||
|
||||
#include <report.h>
|
||||
#include <uibase/report.h>
|
||||
|
||||
namespace py = pybind11;
|
||||
using namespace MOBase;
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
|
||||
// IOrganizer must be bring here to properly compile the Python bindings of
|
||||
// plugin requirements
|
||||
#include <imoinfo.h>
|
||||
#include <isavegame.h>
|
||||
#include <isavegameinfowidget.h>
|
||||
#include <pluginrequirements.h>
|
||||
#include <uibase/imoinfo.h>
|
||||
#include <uibase/isavegame.h>
|
||||
#include <uibase/isavegameinfowidget.h>
|
||||
#include <uibase/pluginrequirements.h>
|
||||
|
||||
using namespace pybind11::literals;
|
||||
namespace py = pybind11;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
|
||||
#include <iplugingame.h>
|
||||
#include <uibase/iplugingame.h>
|
||||
|
||||
namespace mo2::python {
|
||||
|
||||
|
||||
+34
-16
@@ -1,9 +1,12 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
find_package(mo2-uibase CONFIG REQUIRED)
|
||||
|
||||
set(PLUGIN_NAME "plugin_python")
|
||||
|
||||
add_library(proxy SHARED)
|
||||
add_library(proxy SHARED proxypython.cpp proxypython.h)
|
||||
mo2_configure_plugin(proxy
|
||||
NO_SOURCES
|
||||
WARNINGS 4
|
||||
EXTERNAL_WARNINGS 4
|
||||
TRANSLATIONS OFF
|
||||
@@ -11,15 +14,16 @@ mo2_configure_plugin(proxy
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../runner
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../mobase
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../pybind11-qt)
|
||||
target_link_libraries(proxy PRIVATE runner)
|
||||
mo2_default_source_group()
|
||||
target_link_libraries(proxy PRIVATE runner mo2::uibase)
|
||||
set_target_properties(proxy PROPERTIES OUTPUT_NAME ${PLUGIN_NAME})
|
||||
mo2_install_target(proxy FOLDER)
|
||||
mo2_install_plugin(proxy FOLDER)
|
||||
|
||||
set(PLUGIN_PYTHON_DIR ${MO2_INSTALL_PATH}/bin/plugins/${PLUGIN_NAME})
|
||||
set(PLUGIN_PYTHON_DIR bin/plugins/${PLUGIN_NAME})
|
||||
|
||||
# install runner
|
||||
target_link_options(proxy PRIVATE "/DELAYLOAD:runner.dll")
|
||||
mo2_install_target(runner INSTALLDIR ${PLUGIN_PYTHON_DIR}/dlls)
|
||||
install(FILES $<TARGET_FILE:runner> DESTINATION ${PLUGIN_PYTHON_DIR}/dlls)
|
||||
|
||||
# translations (custom location)
|
||||
mo2_add_translations(proxy
|
||||
@@ -33,23 +37,37 @@ mo2_add_translations(proxy
|
||||
# install DLLs files needed
|
||||
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}/libffi*.dll
|
||||
${Python_HOME}/python${Python_VERSION_MAJOR}*.dll)
|
||||
install(FILES ${dlls_to_install} DESTINATION ${DLL_DIRS})
|
||||
|
||||
# install Python files
|
||||
# install Python .pyd files
|
||||
set(PYLIB_DIR ${PLUGIN_PYTHON_DIR}/libs)
|
||||
file(GLOB libs_to_install ${PYTHON_BUILD_PATH}/pythoncore/*.pyd)
|
||||
file(GLOB libs_to_install ${Python_DLL_DIR}/*.pyd)
|
||||
install(FILES ${libs_to_install} DESTINATION ${PYLIB_DIR})
|
||||
install(FILES ${PYTHON_BUILD_PATH}/pythoncore/python${Python_VERSION_SHORT}.zip
|
||||
DESTINATION ${PYLIB_DIR} RENAME pythoncore.zip)
|
||||
|
||||
# generate + install standard library
|
||||
set(pythoncore_zip "${CMAKE_CURRENT_BINARY_DIR}/pythoncore.zip")
|
||||
add_custom_command(
|
||||
TARGET proxy POST_BUILD
|
||||
COMMAND ${Python_EXECUTABLE}
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}\\build_pythoncore.py"
|
||||
${pythoncore_zip}
|
||||
)
|
||||
install(FILES ${pythoncore_zip} DESTINATION ${PYLIB_DIR})
|
||||
|
||||
# install mobase
|
||||
install(TARGETS mobase DESTINATION ${PYLIB_DIR})
|
||||
|
||||
# install PyQt6
|
||||
#file(GLOB PYQT_DIR ${MO2_BUILD_PATH}/PyQt${QT_MAJOR_VERSION}*)
|
||||
set(PYQT_LIB_DIR ${PYTHON_ROOT}/Lib/site-packages/PyQt${QT_MAJOR_VERSION})
|
||||
set(PYQT_TARGET_DIR ${PYLIB_DIR}/PyQt${QT_MAJOR_VERSION})
|
||||
file(GLOB pyqt_files ${PYQT_LIB_DIR}/*.py ${PYQT_LIB_DIR}/*.pyd ${PYQT_LIB_DIR}/*.pyi)
|
||||
install(FILES ${pyqt_files} DESTINATION ${PYQT_TARGET_DIR})
|
||||
install(
|
||||
DIRECTORY ${CMAKE_BINARY_DIR}/pylibs/PyQt${MO2_QT_VERSION_MAJOR}
|
||||
DESTINATION ${PYLIB_DIR}
|
||||
PATTERN "*.pyd"
|
||||
PATTERN "*.pyi"
|
||||
PATTERN "__pycache__" EXCLUDE
|
||||
PATTERN "bindings" EXCLUDE
|
||||
PATTERN "lupdate" EXCLUDE
|
||||
PATTERN "Qt6" EXCLUDE
|
||||
PATTERN "uic" EXCLUDE
|
||||
)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import sys
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
_EXCLUDE_MODULES = ["ensurepip", "idlelib", "test", "tkinter", "turtle_demo", "venv"]
|
||||
|
||||
libdir = Path(sys.executable).parent.joinpath("Lib")
|
||||
assert libdir.exists()
|
||||
|
||||
with zipfile.PyZipFile(sys.argv[1], optimize=2, mode="w") as fp:
|
||||
fp.writepy(libdir) # pyright: ignore[reportArgumentType]
|
||||
for path in libdir.iterdir():
|
||||
if path.is_dir() and path.name not in _EXCLUDE_MODULES:
|
||||
fp.writepy(path) # pyright: ignore[reportArgumentType]
|
||||
@@ -28,9 +28,9 @@ along with python proxy plugin. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include <QWidget>
|
||||
#include <QtPlugin>
|
||||
|
||||
#include <log.h>
|
||||
#include <utility.h>
|
||||
#include <versioninfo.h>
|
||||
#include <uibase/log.h>
|
||||
#include <uibase/utility.h>
|
||||
#include <uibase/versioninfo.h>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
using namespace MOBase;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user