Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
2k views

I am building a C extension using pybind11 with CMake. I used to do this with: find_package(Python3 3.7 REQUIRED) find_package(PythonLibs 3.7 REQUIRED) without any issues. Now I need python 3.8 and ...
Mike's user avatar
  • 4,359
0 votes
1 answer
1k views

I am trying to build a python package with a c extension to be used in a Docker container. I create a python wheel as follows: python install bdist_wheel and the package looks (more or less) like ...
Mike's user avatar
  • 4,359
2 votes
0 answers
530 views

Question: What is the proper way to structure and build a Python wheel with C extensions for deployment? Ideally, the user shouldn't need elevated privileges or be required to point environment ...
rgmann's user avatar
  • 31
1 vote
0 answers
147 views

There are many tutorials out there on how to create C extensions of Python which introduce a new type. One example: https://docs.python.org/3.5/extending/newtypes.html This usually boils down to ...
Flamefire's user avatar
  • 5,927
8 votes
2 answers
10k views

When I execute a command python setup.py install or python setup.py develop it would execute build_ext command as one of the steps. How can I pass --debug option to it as if it was invoked as python ...
Gill Bates's user avatar
  • 15.5k
2 votes
3 answers
521 views

I embedded and extended Python 2.7 in my C application a while ago. Late on the train I am bringing it to Python 3, and a lot of initializations for the module registration changed for me. Before I ...
Daniel Stephens's user avatar
4 votes
3 answers
8k views

I've been using pybind11 recently, and now that I'm getting the hang of it, I'm thrilled with it. It's an awesome piece of work. The final piece of the tool puzzle for doing pybind11 is the debug part....
Andrew Voelkel's user avatar
5 votes
1 answer
10k views

I have code which successfully runs. Its CmakeLists.txt is: cmake_minimum_required(VERSION 3.15) project(rotapro3) set(CMAKE_CXX_STANDARD 14) add_executable(rotapro3 main.cpp): I want to use pybind ...
user avatar
0 votes
0 answers
141 views

Currently using VS Code version 1.43.2 and Python 3.8.1. I want to know how will I make my codes display in the Output section and NOT the Terminal section when I ran them
Rakim B'Liwena's user avatar
-1 votes
1 answer
42 views

i'm making a some code for project, the all i want to do in test function is i want to print out each of 'list_total[y]' values i input input example 1 # forget this input for now, 1 # the lines ...
GG OTL's user avatar
  • 1
0 votes
1 answer
318 views

I'm converting a pure-Python module to a C-extension to familiarize myself with the C API. The Python implementation is as follows: _CRC_TABLE_ = [0] * 256 def initialize_crc_table(): if ...
Kamikaze Rusher's user avatar
2 votes
0 answers
172 views

I have a what looks like this in some directory. . ├── Makefile ├── mod │   ├── advancedmath.cpp │   ├── advancedmath.py │   ├── __init__.cpp │   ├── __init__.py │   ├── main.cpp │   ├── main.pxd ...
axolotl's user avatar
  • 1,098
1 vote
2 answers
622 views

I'm having trouble creating an instance of a class (type) I wrote from within the C module. I've written a minimal, self-contained example that illustrates the point. Just copy-paste the three files ...
musbur's user avatar
  • 679
1 vote
1 answer
192 views

I wrote the following code for my CPython extension : #include <Python.h> static PyObject *greeting(PyObject* self) { return Py_BuildValue("s" , "Hello python modules!!!"); } static ...
Parsa Mousavi's user avatar
11 votes
2 answers
807 views

How can I create a Python C extension wheel for MacOS that is backwards compatible (MacOS 10.9+) using MacOS 10.15? This is what I have so far: export MACOSX_DEPLOYMENT_TARGET=10.9 python -m pip ...
AstrOne's user avatar
  • 3,809
1 vote
0 answers
534 views

I understand a basic C++ function wrapped for Python looks like this: int square(int n) { return n*n; } static PyObject* square_wrapper(PyObject* self, PyObject* args) { int n = 0; if(!...
Aidan Lethaby's user avatar
1 vote
1 answer
3k views

I am writing a python extension in C and I am trying to pass a bytes object to my function. Obviously the 's' token is for strings; I have tried 'O', 'N', and a few others with no luck. Is there a ...
Daniel's user avatar
  • 597
0 votes
1 answer
1k views

I've used other editors (Spyder) where linting is real time, and it's incredibly useful to catch coding errors in real time. I'm not necessarily looking for real time, but even after I save, I have to ...
David Miller's user avatar
0 votes
1 answer
193 views

I'm toying around with Python C extension modules and I've got this simple function: static PyObject *e_parse_metadata(PyObject *self, PyObject *args) { Py_buffer buf; if(!PyArg_ParseTuple(...
bool3max's user avatar
  • 2,875
5 votes
1 answer
2k views

In a nutshell I try to compile a cython extension called extension2 that cimports a file extension from a self-created package. When building extension2, I get the error that extension.pxd is not ...
Samufi's user avatar
  • 2,740
0 votes
1 answer
350 views

I'm working on improving the setup.py script for an open source package that supports various platforms. On Linux, the package defines a setuptools.Extension for some C code that needs to be built ...
rgov's user avatar
  • 4,468
0 votes
1 answer
125 views

I have a long-running Python app which scans many megabytes of files in a loop every few minutes. Over the course of a day I see that it gobbles up gigybates of memory, and in the end I have to kill ...
musbur's user avatar
  • 679
0 votes
1 answer
25 views

I'm trying to debug a Python extension that I wrote. In order to enable some memory debugging features I downloaded and built a Python version, which worked just fine. Now I'm trying to build my own ...
musbur's user avatar
  • 679
1 vote
1 answer
434 views

I'm chasing an annoying segfault bug in a Python extension. Drilling down to the core I first created a standalone C version of the extension, and while trying to further reduce the problem, I've ...
musbur's user avatar
  • 679
1 vote
1 answer
381 views

I'm chasing a memory leak that seems to come from a long-running process which contains a C extension that I wrote. I've been poring over the code and the Extensions docs and I'm sure it's correct but ...
musbur's user avatar
  • 679
1 vote
0 answers
74 views

I am developing a program that extends python with C++ code, and it looks like I'm missing something in initialization or cleanup. The symptom is that when the program terminates it prints out ...
Michael's user avatar
  • 6,021
4 votes
2 answers
961 views

This question is pretty simple but will help cement my understanding. I know that arguments to C extension functions are guaranteed to be live references for the duration of the C code (unless ...
Michael Carilli's user avatar
0 votes
0 answers
49 views

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 ...
Sravya's user avatar
  • 1
6 votes
0 answers
889 views

I'm developing a C(++) extension for python. I have a library in C that I wrap using Swig. Unfortunately I have some error that I would like to debug that is within the C extension. My program makes ...
hetepeperfan's user avatar
  • 4,441
0 votes
1 answer
204 views

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 ...
Howard  Yu's user avatar
  • 311
3 votes
1 answer
335 views

I am writing a Python3 extension module for an existing C++ library which returns a string that appears to be in cp1252 encoding. The C++ function signature is int get_name(std::string& name); ...
Paul Grinberg's user avatar
1 vote
1 answer
425 views

My goal is to create a Python library that I can import into any of my projects, and I wish to have the library made faster by the use of the C language (similar to how NumPy works). However, after ...
Pencilcaseman's user avatar
0 votes
1 answer
113 views

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 ...
Howard  Yu's user avatar
  • 311
3 votes
1 answer
349 views

I'm writing a C extension module for python3.7. I have a simple structure as PyObject: typedef struct { PyObject_HEAD double attacker; double victim; double game_hardness; int ...
pomo_mondreganto's user avatar
0 votes
1 answer
2k views

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....
BK927's user avatar
  • 23
5 votes
1 answer
468 views

While following a C extension for Python tutorial, my module seems to missing its contents. While building and importing the module have no problem, using the function in the module fails. I am using ...
nedla2004's user avatar
  • 1,145
2 votes
1 answer
413 views

Experimentally, I verified that when a compiled extension.pyd (or .so) and plain extension.py both exist in the same directory, the .pyd file gets imported first ; the .py is only imported if the .pyd ...
F.X.'s user avatar
  • 7,515
1 vote
1 answer
222 views

My PyFLoat_ParseTuple call always return false, with correct call from python side. I am working on wrapping my C++ for Python and using python extension. I had a successful project, and generating ...
Charlie's user avatar
  • 21
3 votes
0 answers
800 views

I am trying to compile a python module using a compiler other than 'gcc', specifically 'icc' (for efficiency reasons). I tried forcing the compilation setting 'cc' to 'clang' but still that did not ...
PintoDoido's user avatar
  • 1,051
0 votes
3 answers
3k views

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 ...
Nub's user avatar
  • 31
1 vote
1 answer
2k views

I'm developing a Python extension in c++. I'm am really rusty in c++ however and don't have the necessary experience to figure this out it seems. I'm trying to read in numpy arrays, do the ...
Mineral's user avatar
  • 417
-1 votes
1 answer
420 views

I am working on data science using python and visual studio code but every time i run the code even the single line file starts from the begging which again upload the data and give the result which ...
Goldi Rana's user avatar
0 votes
0 answers
860 views

I'm currently writing some code that utilizes boost.python. I want to convert an std::vector<unsigned char> to a Python bytes-like object, (I just need to expose the data to Python). The ...
Mia's user avatar
  • 2,674
0 votes
1 answer
638 views

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; ...
TonySalimi's user avatar
  • 8,505
3 votes
1 answer
779 views

Introduction I am working on project where a lot of textual data needs to be processed. Many quite big (hundreds of MB) text files. The python is the requirement (don't ask why). I want to use C++ ...
nosbor's user avatar
  • 3,049
1 vote
0 answers
777 views

I have a large (numpy ndarray) object whose memory I want to free as soon as I am finished with it in my Python extension (or I will quickly run out of memory). How can I safely do this? It seems ...
Zach Boyd's user avatar
  • 439
1 vote
2 answers
2k views

I am trying to create .so file of a c++ file(twocams.cpp) which includes main() and another C++ file (say abc.h). abc.c includes opencv. while creating an object using ctypes, g++ -fPIC -shared ...
Arun Sharma's user avatar
1 vote
2 answers
1k views

I have the following python code: class Meta(type): def __call__(cls, *args, **kwargs): obj = type.__call__(cls, *args, **kwargs) # Only do checks for subclasses if cls....
Nelson's user avatar
  • 952
-1 votes
1 answer
89 views

I have used a random function in python but its not working , I am very new at python. Please review below code def get_context_data(self, **kwargs): context = super().get_context_data(**...
md. saroar Jahan's user avatar
2 votes
1 answer
561 views

I am trying to import a python extension coded in c++ with boost. While I experienced some problems compiling the extension using cmake, I managed to do so linked to the boost_python27 library. I then ...
mnmldani's user avatar

1 2
3
4 5
7