1,389 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
2
answers
186
views
Building a Python extension with a local C++ library dependency using setuptools and build
I have a library written in C++ for which I would like to make a Python wrapper. The directory structure of my repository is similar to the following:
.
├── include # C++ library headers
│ └── ...
├── ...
1
vote
0
answers
93
views
How to let Python runtime load its own Library ZIP file from memory during the initialization
I am using the Python C API and want to embed Python runtime into my app.
The first thing is how to let Python load everything from a memory block, which
stores the Zipped Python standard library ...
1
vote
0
answers
89
views
pyproject.toml: specify dynamic parameters for C extension
I'm updating a Python package that contains some C extensions.
In a previous version I had all parameters set up in the setuptools setup() function, and now I am porting that setup into a new version ...
0
votes
0
answers
169
views
Pytsk3 installed with .whl file does not work
I tried to use pytsk3 in my python project to extract files from .img files. Pytsk3 (https://github.com/py4n6/pytsk) is a python binding for the Sleuth Kit. It works fine on my laptop (windows 11 pro ...
0
votes
0
answers
61
views
PyEval_RestoreThread crash when calling matplotlib via Python C API
I have a c++ application that implements its own Python interpreter and console. The user can enter Python code into the console, and that text gets sent to another thread where I make calls to the ...
0
votes
0
answers
53
views
import Pytorch to create Neural Network. Running Error
I'm using C++/Qt to run my Qt application.
Development Version:
Python: 3.12
Qt: 6.6.3
C++: std 17
Visual Studio 2022
Inside my code, I use Python/C API to run python script like:
PyObject* pModule ...
0
votes
1
answer
68
views
Can a simple mutex pthread_mutex be a replacement for GIL in a multithreaded Python C extension?
Can a simple mutex pthread_mutex be a replacement for GIL in a multithreaded Python C extension? For eg: if I put mutex locks around Py_INCREF or PyMem_Alloc, would that suffice?
Tried using the GIL, ...
1
vote
1
answer
163
views
Create instance of a imported python class with C API
I want to create an instance of a Python class with the C API.
My specific use case is the PySerial Object. My Python code would be:
import serial
test = serial.Serial()
I couldn't find any clue or ...
1
vote
1
answer
38
views
How to dispose off a partially initialized list in Python C-API?
The documentation for PyList_New says that these two APIs are safe before the list is fully initialized: PyList_SetItem() and PyList_SET_ITEM(). But if an error happens in the middle of initializing ...
3
votes
1
answer
107
views
How ro run a C++ application with embedded Python in Debug mode
I'm trying to run the script below in Debug mode (Release works fine). I've linked against python310_d.lib and python310_d.dll which have been built from the source code found here https://github.com/...
0
votes
1
answer
266
views
C++ Python/C API - Is exception returned by PyErr_GetRaisedException normalized?
I'm using a new Python/C API PyErr_GetRaisedException added in 3.12 version to retrieve exception and then using other Python/C APIs to get exception type, value, and traceback details.
Then I'm ...
1
vote
1
answer
40
views
How to debug a dylib error or compiler bug in a Python-C-API function wrapper?
I am writing a Python wrapper for a C function but I have some very strange behaviour.
The C code is:
static PyObject* f12_wrapper(PyObject* self, PyObject* args, PyObject* kwargs)
{
PyObject* ...
8
votes
1
answer
392
views
How to make CPython report vectorcall as available only when it will actually help performance?
The Vectorcall protocol is a new calling convention for Python's C API defined in PEP 590. The idea is to speed up calls in Python by avoiding the need to build intermediate tuples and dicts, and ...
0
votes
0
answers
53
views
PySide6 with Python C API: EXC_BAD_ACCESS error when calling a method with inherited class from QRasterWindow
Environement:
Python version: 3.9.6 (default, May 7 2023, 23:32:45)
PySide6 version: 6.7.0
When I create an instance of QRasterWindow, calling the metric method is ok:
Py_Initialize();
PyObject *...
0
votes
1
answer
176
views
Generate pyi stubfile for not importable C module
I have a package A that uses a special package A.B, both are 3rd and 4th party packages written in C using Boost. Because it there is some special setup A.B is not included as a submodule but only as ...