mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 10:56:11 +00:00
Use Python stable ABI >= 3.5 (#1426)
This commit is contained in:
parent
65850d6aee
commit
3d454cdaa0
@ -45,7 +45,6 @@ install:
|
||||
|
||||
before_build:
|
||||
- cmd: git submodule update --init
|
||||
- cmd: python scripts\compile_python_resources.py
|
||||
|
||||
# Build config
|
||||
build_script:
|
||||
|
@ -1,10 +0,0 @@
|
||||
import compileall
|
||||
import os
|
||||
|
||||
root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
|
||||
compileall.compile_dir(os.path.join(root, 'src', 'python'), legacy=True, optimize=2)
|
||||
with open(os.path.join(root, 'src', 'resources.qrc'), 'r+b') as f:
|
||||
data = f.read()
|
||||
data = data.replace(b'.py<', b'.pyc<')
|
||||
f.seek(0)
|
||||
f.write(data)
|
@ -100,7 +100,7 @@ CUTTER_ENABLE_PYTHON {
|
||||
PYTHON_EXECUTABLE = $$system("where python", lines)
|
||||
PYTHON_EXECUTABLE = $$first(PYTHON_EXECUTABLE)
|
||||
pythonpath = $$clean_path($$dirname(PYTHON_EXECUTABLE))
|
||||
LIBS += -L$${pythonpath} -L$${pythonpath}/libs -lpython3
|
||||
LIBS += -L$${pythonpath}/libs -lpython3
|
||||
INCLUDEPATH += $${pythonpath}/include
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
#ifdef CUTTER_ENABLE_PYTHON
|
||||
|
||||
#define Py_LIMITED_API 0x03050000
|
||||
#include <Python.h>
|
||||
|
||||
PyObject *PyInit_api();
|
||||
PyObject *PyInit_api_internal();
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "PythonManager.h"
|
||||
#include "Cutter.h"
|
||||
|
||||
#include <marshal.h>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
@ -103,11 +102,14 @@ static void pySideDestructionVisitor(SbkObject* pyObj, void* data)
|
||||
|
||||
const char *reprStr = "";
|
||||
PyObject *repr = PyObject_Repr(reinterpret_cast<PyObject *>(pyObj));
|
||||
PyObject *reprBytes;
|
||||
if (repr) {
|
||||
reprStr = PyUnicode_AsUTF8(repr);
|
||||
reprBytes = PyUnicode_AsUTF8String(repr);
|
||||
reprStr = PyBytes_AsString(reprBytes);
|
||||
}
|
||||
qWarning() << "Warning: QObject from Python remaining (leaked from plugin?):" << reprStr;
|
||||
if (repr) {
|
||||
Py_DecRef(reprBytes);
|
||||
Py_DecRef(repr);
|
||||
}
|
||||
|
||||
@ -139,11 +141,11 @@ void PythonManager::shutdown()
|
||||
PySide::runCleanupFunctions();
|
||||
#endif
|
||||
|
||||
Py_Finalize();
|
||||
|
||||
if (pythonHome) {
|
||||
PyMem_RawFree(pythonHome);
|
||||
PyMem_Free(pythonHome);
|
||||
}
|
||||
|
||||
Py_Finalize();
|
||||
}
|
||||
|
||||
void PythonManager::addPythonPath(char *path) {
|
||||
|
@ -1,53 +1,37 @@
|
||||
#ifdef CUTTER_ENABLE_PYTHON
|
||||
|
||||
#define Py_LIMITED_API 0x03050000
|
||||
#include <Python.h>
|
||||
#include <marshal.h>
|
||||
|
||||
#include "QtResImporter.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
|
||||
int QtResExists(const char *name, QFile &file)
|
||||
bool QtResExists(const char *name, QFile &file)
|
||||
{
|
||||
QString fname = QString::asprintf(":/python/%s.py", name);
|
||||
file.setFileName(fname);
|
||||
if (file.exists())
|
||||
return 1;
|
||||
fname.append('c');
|
||||
file.setFileName(fname);
|
||||
if (file.exists())
|
||||
return 2;
|
||||
return 0;
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
PyObject *QtResGetCode(const char *name)
|
||||
{
|
||||
QFile moduleFile;
|
||||
bool isBytecode = false;
|
||||
|
||||
switch (QtResExists(name, moduleFile)) {
|
||||
case 0:
|
||||
if (!QtResExists(name, moduleFile)) {
|
||||
return nullptr;
|
||||
case 2:
|
||||
isBytecode = true;
|
||||
}
|
||||
|
||||
moduleFile.open(QIODevice::ReadOnly);
|
||||
QByteArray data = moduleFile.readAll();
|
||||
moduleFile.close();
|
||||
|
||||
PyObject *codeObject;
|
||||
if (isBytecode) {
|
||||
codeObject = PyMarshal_ReadObjectFromString(data.constData() + 12,
|
||||
data.size() - 12);
|
||||
} else {
|
||||
codeObject = Py_CompileString(data.constData(),
|
||||
moduleFile.fileName().toLocal8Bit().constData(),
|
||||
Py_file_input);
|
||||
}
|
||||
PyObject *codeObject = Py_CompileString(data.constData(),
|
||||
moduleFile.fileName().toLocal8Bit().constData(),
|
||||
Py_file_input);
|
||||
if (!codeObject) {
|
||||
qWarning() << "Couldn't unmarshal/compile " << moduleFile.fileName();
|
||||
qWarning() << "Couldn't compile " << moduleFile.fileName();
|
||||
}
|
||||
return codeObject;
|
||||
}
|
||||
|
@ -101,6 +101,7 @@ cpp = meson.get_compiler('cpp')
|
||||
if host_machine.system() == 'windows'
|
||||
add_project_arguments('-D_CRT_NONSTDC_NO_DEPRECATE', language: 'cpp')
|
||||
add_project_arguments('-D_CRT_SECURE_NO_WARNINGS', language: 'cpp')
|
||||
add_project_link_arguments(join_paths(py3_exe.get_variable('BINDIR'), 'libs', 'python3.lib'), language: 'cpp')
|
||||
endif
|
||||
|
||||
cutter_exe = executable(
|
||||
|
Loading…
Reference in New Issue
Block a user