16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-17 23:39:18 +02:00

Python 3.14 build and CI updates

Squashes the last five commits: migrate to Python 3.14 (CMake, AppVeyor, Azure, README), vcpkg/setup-ci fixes, CMake adjustments, remove bundled ref/python 2.7, and related scripting/static file updates.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
maj00r
2026-05-11 16:22:17 +02:00
parent 6542021253
commit 3786ecd98f
104 changed files with 130 additions and 13532 deletions

View File

@@ -38,7 +38,7 @@ void render_task::run()
}
for (auto const &datapair : m_input->integers)
{
auto *value{PyGetInt(datapair.second)};
auto *value{PyLong_FromLong(datapair.second)};
PyDict_SetItemString(input, datapair.first.c_str(), value);
Py_DECREF(value);
}
@@ -49,7 +49,7 @@ void render_task::run()
}
for (auto const &datapair : m_input->strings)
{
auto *value{PyGetString(datapair.second.c_str())};
auto *value{PyUnicode_FromString(datapair.second.c_str())};
PyDict_SetItemString(input, datapair.first.c_str(), value);
Py_DECREF(value);
}
@@ -85,8 +85,8 @@ void render_task::run()
if (outputWidth != nullptr && outputHeight != nullptr && m_target != nullptr)
{
const int screenWidth = static_cast<int>(PyInt_AsLong(outputWidth));
const int screenHeight = static_cast<int>(PyInt_AsLong(outputHeight));
const int screenWidth = static_cast<int>(PyLong_AsLong(outputWidth));
const int screenHeight = static_cast<int>(PyLong_AsLong(outputHeight));
const bool useRgb = (false && !Global.gfx_usegles);
@@ -98,9 +98,7 @@ void render_task::run()
Py_ssize_t pythonBufferBytes = 0;
char *pythonBufferPtr = nullptr;
const bool bufferExtracted =
(PyString_AsStringAndSize(output, &pythonBufferPtr, &pythonBufferBytes) == 0)
&& (pythonBufferPtr != nullptr);
const bool bufferExtracted = (PyBytes_AsStringAndSize(output, &pythonBufferPtr, &pythonBufferBytes) == 0) && (pythonBufferPtr != nullptr);
if (!bufferExtracted)
{
@@ -199,25 +197,6 @@ void render_task::upload()
if (Global.python_uploadmain && m_target && m_target->shared_tex)
{
m_target->shared_tex->update_from_memory(m_target->width, m_target->height, reinterpret_cast<const uint8_t *>(m_target->image.data()));
// glBindTexture(GL_TEXTURE_2D, m_target->shared_tex->get_id());
// glTexImage2D(
// GL_TEXTURE_2D, 0,
// m_target->format,
// m_target->width, m_target->height, 0,
// m_target->components, GL_UNSIGNED_BYTE, m_target->image);
//
// if (Global.python_mipmaps)
//{
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
// glGenerateMipmap(GL_TEXTURE_2D);
//}
// else
//{
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//}
//
// if (Global.python_threadedupload)
// glFlush();
}
}
@@ -229,27 +208,24 @@ auto python_taskqueue::init() -> bool
crashreport_add_info("python.threadedupload", Global.python_threadedupload ? "yes" : "no");
crashreport_add_info("python.uploadmain", Global.python_uploadmain ? "yes" : "no");
#ifdef _WIN32
if (sizeof(void *) == 8)
Py_SetPythonHome(const_cast<char *>("python64"));
Py_SetPythonHome(L"python64");
else
Py_SetPythonHome(const_cast<char *>("python"));
Py_SetPythonHome(L"python");
#elif __linux__
if (sizeof(void *) == 8)
Py_SetPythonHome(const_cast<char *>("linuxpython64"));
Py_SetPythonHome(L"linuxpython64");
else
Py_SetPythonHome(const_cast<char *>("linuxpython"));
Py_SetPythonHome(L"linuxpython");
#elif __APPLE__
if (sizeof(void *) == 8)
Py_SetPythonHome(const_cast<char *>("macpython64"));
Py_SetPythonHome(L"macpython64");
else
Py_SetPythonHome(const_cast<char *>("macpython"));
Py_SetPythonHome(L"macpython");
#endif
Py_InitializeEx(0);
PyEval_InitThreads();
PyObject *stringiomodule{nullptr};
PyObject *stringioclassname{nullptr};
PyObject *stringioobject{nullptr};
@@ -262,7 +238,7 @@ auto python_taskqueue::init() -> bool
goto release_and_exit;
}
stringiomodule = PyImport_ImportModule("cStringIO");
stringiomodule = PyImport_ImportModule("io");
stringioclassname = (stringiomodule != nullptr ? PyObject_GetAttrString(stringiomodule, "StringIO") : nullptr);
stringioobject = (stringioclassname != nullptr ? PyObject_CallObject(stringioclassname, nullptr) : nullptr);
m_stderr = {(stringioobject == nullptr ? nullptr : PySys_SetObject(const_cast<char *>("stderr"), stringioobject) != 0 ? nullptr : stringioobject)};
@@ -297,7 +273,7 @@ auto python_taskqueue::init() -> bool
return true;
release_and_exit:
PyEval_ReleaseLock();
PyEval_SaveThread();
return false;
}
@@ -493,9 +469,9 @@ void python_taskqueue::run(GLFWwindow *Context, rendertask_sequence &Tasks, uplo
glfwMakeContextCurrent(Context);
// create a state object for this thread
PyEval_AcquireLock();
PyEval_AcquireThread(m_mainthread);
auto *threadstate{PyThreadState_New(m_mainthread->interp)};
PyEval_ReleaseLock();
PyEval_ReleaseThread(m_mainthread);
std::shared_ptr<render_task> task{nullptr};
@@ -546,11 +522,12 @@ void python_taskqueue::run(GLFWwindow *Context, rendertask_sequence &Tasks, uplo
Condition.wait_for(std::chrono::milliseconds(250));
}
// clean up thread state data
PyEval_AcquireLock();
// Python 3: PyEval_AcquireLock() is gone, use PyEval_RestoreThread / PyThreadState_Swap
PyEval_RestoreThread(threadstate);
PyThreadState_Swap(nullptr);
PyThreadState_Clear(threadstate);
PyThreadState_Delete(threadstate);
PyEval_ReleaseLock();
PyEval_SaveThread();
// detach the GL context before the worker terminates; some drivers
// (NVIDIA on X11, certain Mesa/Wayland configs) hang in process teardown
@@ -571,15 +548,20 @@ void python_taskqueue::update()
void python_taskqueue::error()
{
if (m_stderr != nullptr)
{
// std err pythona jest buforowane
PyErr_Print();
auto *errortext{PyObject_CallMethod(m_stderr, const_cast<char *>("getvalue"), nullptr)};
ErrorLog(PyString_AsString(errortext));
// czyscimy bufor na kolejne bledy
PyObject_CallMethod(m_stderr, const_cast<char *>("truncate"), const_cast<char *>("i"), 0);
if (errortext != nullptr)
{
const char *errstr = PyUnicode_AsUTF8(errortext);
if (errstr != nullptr)
ErrorLog(errstr);
Py_DECREF(errortext);
}
PyObject_CallMethod(m_stderr, const_cast<char *>("truncate"), const_cast<char *>("L"), (long long)0);
PyObject_CallMethod(m_stderr, const_cast<char *>("seek"), const_cast<char *>("L"), (long long)0);
}
else
{
@@ -598,16 +580,29 @@ void python_taskqueue::error()
auto *typetext{PyObject_Str(type)};
if (typetext != nullptr)
{
ErrorLog(PyString_AsString(typetext));
const char *s = PyUnicode_AsUTF8(typetext);
if (s)
ErrorLog(s);
Py_DECREF(typetext);
}
if (value != nullptr)
{
ErrorLog(PyString_AsString(value));
auto *valuetext{PyObject_Str(value)};
if (valuetext != nullptr)
{
const char *s = PyUnicode_AsUTF8(valuetext);
if (s)
ErrorLog(s);
Py_DECREF(valuetext);
}
}
auto *tracebacktext{PyObject_Str(traceback)};
if (tracebacktext != nullptr)
{
ErrorLog(PyString_AsString(tracebacktext));
const char *s = PyUnicode_AsUTF8(tracebacktext);
if (s)
ErrorLog(s);
Py_DECREF(tracebacktext);
}
else
{
@@ -636,7 +631,7 @@ std::vector<std::string> python_external_utils::PyObjectToStringArray(PyObject *
return emptyIfError;
}
const char *str = PyString_AsString(item);
const char *str = PyUnicode_AsUTF8(item);
if (str == nullptr)
{
Py_DECREF(item);
@@ -653,4 +648,4 @@ std::vector<std::string> python_external_utils::PyObjectToStringArray(PyObject *
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#endif

View File

@@ -53,9 +53,7 @@ http://mozilla.org/MPL/2.0/.
#include <thread>
#define PyGetFloat(param) PyFloat_FromDouble(param)
#define PyGetInt(param) PyInt_FromLong(param)
#define PyGetBool(param) param ? Py_True : Py_False
#define PyGetString(param) PyString_FromString(param)
// python rendertarget
struct python_rt