Detect python version at build time

This remove the hardcoded version in CMakeLists.txt and
loader_script_handler.cpp.

Fixing building on Arch Linux and probably other systems.
This commit is contained in:
Mary
2020-12-05 12:46:50 +01:00
parent 168ba2ff9f
commit d3dccace37
2 changed files with 13 additions and 3 deletions

View File

@@ -181,7 +181,7 @@ namespace hex {
bool LoaderScript::processFile(std::string_view scriptPath) {
Py_SetProgramName(Py_DecodeLocale(mainArgv[0], nullptr));
if (std::filesystem::exists(std::filesystem::path(mainArgv[0]).parent_path().string() + "/lib/python3.8"))
if (std::filesystem::exists(std::filesystem::path(mainArgv[0]).parent_path().string() + "/lib/python" PYTHON_VERSION_MAJOR_MINOR))
Py_SetPythonHome(Py_DecodeLocale(std::filesystem::path(mainArgv[0]).parent_path().string().c_str(), nullptr));
PyImport_AppendInittab("_imhex", []() -> PyObject* {