Questions tagged [python-extensions]

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.

323 questions
0
votes
0 answers

I had installed python extension (windows) but unable to see python in the right menu in integrated terminal(VS Code)

I had installed python extension (windows) but unable to see python in the right menu in integrated terminal(VS Code). I can only see powershell unlike the tutor(Mosh Hamedani) has python.please see the picture for better picture of my problem.…
Sravya
  • 1
0
votes
1 answer

Is Python GIL needed if extension is single threaded

I am writing a C++ extension for my Python application. I understand that Python GIL is used to prevent multiple thread accessing PyObject at the same time. However, my questions is my extension code is single-threaded, do I still need to acquire…
Howard Yu
  • 171
  • 1
  • 10
0
votes
1 answer

Ship Python Extension that required dynamic linking

I am writing a c extension (called my_ext) and I successfully compiled the source code to a .so file. However, my_ext depends another dynamic library installed by pip. So the link directory looks like /lib/python3.6/site-packages/foo.…
Howard Yu
  • 171
  • 1
  • 10
0
votes
1 answer

How to convert PyObject to UTF-8 string?

I'm trying to pass a string value to a Python function and get a utf-8 string value. The function retrieves Japanese characters and returns characters in another language. I used ctypes.windll.user32.MessageBoxW in the Python script and made sure…
BK927
  • 23
  • 3
0
votes
3 answers

Does `pip install` respect the compiler version used to build Python?

Does pip install always build extension modules with the same compiler that was used to compile the current Python version? For example, this blog post explained that numpy package uses C code, which has to be compiled against the same compiler as…
Nub
  • 31
  • 7
0
votes
0 answers

PyMemoryView_FromMemory Losing Data

I'm currently writing some code that utilizes boost.python. I want to convert an std::vector to a Python bytes-like object, (I just need to expose the data to Python). The converter I wrote looks like this #include #include…
Mia
  • 2,466
  • 22
  • 38
0
votes
1 answer

Why relasing and acquiring GIL within two threads causes an application crash?

I have developed a Python extenstion using C++. The only function of this module is something like this: static PyObject *TestModule_API1(PyObject *self, PyObject *args) { PyThreadState *_save; _save = PyEval_SaveThread(); try { …
0
votes
0 answers

How to pass a python bytes object to a C++ extension?

I am trying to pass a numpy array to a customized C++ extension but somehow I got a segmentation fault. Here I made a simplified version of my code. On the C++ side, I simply parse a bytes object using "s#", copy the data into an opencv Mat then…
Zhenglin Geng
  • 11
  • 1
  • 3
0
votes
1 answer

Issue with Linking Python C Extension to Another Library

I am in the process of developing a Python extension to allow a script running on a Raspberry Pi to control a sensor. The sensor manufacturer provided my organization with the source code to their C API, and I am trying to create a set of bindings…
SquawkBirdies
  • 157
  • 2
  • 13
0
votes
1 answer

Python crashes on returning an C++ map value

i am writing a Test to keep Data in a C++ map. I am using the Python C-Api. Adding int values and getting the length of the map is no problem. But when i get a value from the map and want to return it to Python than the Interpreter crashes. This is…
0
votes
1 answer

Linking with Apache Portable Runtime on MS Windows

I'm trying to build a Python extension which links to APR. And this time it's on MS Windows... (It works on Linux). Here's where the build fails, the command, and the output formatted for readability: C:\Program Files (x86)\Microsoft Visual Studio…
wvxvw
  • 8,089
  • 10
  • 32
  • 61
0
votes
1 answer

My PyCFunction works the first time but leads to a segfault after successive iterations

I want to write a python object in c that holds a numpy vector (two actually, but just one in this minimal example). To begin with, I just want to create an object with a numpy array and see that I can add one to all the array-elements in a loop.…
The Unfun Cat
  • 29,987
  • 31
  • 114
  • 156
0
votes
1 answer

Incorrect message length when using C python api

I'm trying to extend libhydrogen (open source found here: https://github.com/jedisct1/libhydrogen/) to support calls to the underlying library in Python. However, I ran into a strange issue. Specifically I have the following code: static PyObject*…
0
votes
1 answer

How to handle concurrency if C/C++ Python3 extension hosting a http server and calling python code as request handler?

I try to create a Python extension which will host a HTTP server. When a particular request coming in, the extension calling a Python code from the extension consumer to handle the request. Since HTTP server is by-nature multi-thread, the…
NonStatic
  • 951
  • 1
  • 8
  • 27
0
votes
1 answer

Python C extension with executable dependency

I have this C SDK that I'm working on creating a Python extension for. The C SDK documentation says that it expects a ffmpeg executable in it's working directory. My current project structure is: my-extension/ include/ sdk-file.h …
jim
  • 140
  • 2
  • 8