Questions tagged [python-extensions]

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

323 questions
2
votes
1 answer

Trouble importing extension compiled with numpy.distutils

I have a project directory structure: myproject/ setup.py myproject/ editors/ .... utilities/ ... find_inf.f90 All the files in the project are python, except for the one fortran file that i have indicated. Now, I…
deepak
  • 2,045
  • 2
  • 21
  • 36
2
votes
1 answer

Python module installation fails because the gcc command is missing a flag...that the gcc command has

I am attempting to build a (very simple) Python extension from C code and have run into a snag in the compilation. (For the record: my C skills are very out-of-date and my code is probably awful.) As directed in the docs and on another site I found,…
TrevorNT
  • 23
  • 2
2
votes
2 answers

Passing numpy integer array to c code

I'm trying to write Cython code to dump a dense feature matrix, target vector pair to libsvm format faster than sklearn's built in code. I get a compilation error complaining about a type issue with passing the target vector (a numpy array of ints)…
AatG
  • 685
  • 8
  • 23
2
votes
1 answer

Why PyObject_IsInstance always return 0 in my sample code

I write a sample to learn python, but when call PyObject_IsInstance, this function always return 0. Here's my c code ReadBuf.c #include "Python.h" static PyObject* Test_IsInstance(PyObject* self, PyObject* args){ PyObject* pyTest = NULL; …
Vatel
  • 79
  • 7
2
votes
0 answers

Extending Python Program that has already been compiled to .exe?

I'm making a network analysis tool using python 2.5 ( windows) , that captures network traffic using scapy and stores the capture data in *.pcap file . What i'm trying to achieve is to allow users to write their own functions that can analyze the…
thecreator232
  • 2,145
  • 1
  • 36
  • 51
2
votes
1 answer

PyInstance_NewRaw() with old and new style classes

Recently I faced a problem in a C-based python extension while trying to instantiate objects without calling its constructor -- which is a requirement of the extension. The class to be used to create instances is obtained dynamically: at some…
Thiago Silva
  • 155
  • 3
2
votes
1 answer

None value PyObject to NULL in PyArg_ParseTupleAndKeywords()

I am passing an extension type object to a Python function, which needs to pass a variable in this type to a C function. My extension type looks like this: typedef struct { PyObject_HEAD rec_rset_t rst; //need to pass this to C function }…
Edaro
  • 43
  • 1
  • 6
2
votes
0 answers

How to access python class from C extension?

I have my extension for Python written in C. Currently I need to process in a function of my extension objects of a type declared in some external pure python module (Say, its name is ext_module). First of all I need to ensure that input object type…
Ivan
  • 588
  • 5
  • 20
2
votes
1 answer

PyString_FromStringAndSize causes segmentation fault

I have a weird segfault with python. Here's the problematic piece of code: const std::string &fullName = child.getFullName(); const char *fName = fullName.c_str(); const int len = fullName.size(); printf(":: %02d --> %s\n", len, fName); PyObject…
widgg
  • 1,358
  • 2
  • 16
  • 35
2
votes
0 answers

Python import error undefined symbol: Py_InitModule4 on executing my script

I am working on C extension of python where this extension C module will make a Remote Procedure Call(RPC) to access the network services. This C module will apply the method Py_BuildValue on the result (collected information) of RPC and append that…
dsd
  • 21
  • 1
  • 4
2
votes
1 answer

Python C extension: return PyFloat_FromDouble(double) segfault

I recently converted some slow python code into a C extension. It works beautifully, except that it generates a segfault at the 162nd call into it, right at the return statement. Here's how it works. Once, prior to all of the calls to the function I…
2
votes
0 answers

Avoid duplication of msvcr90.dll in application with embedded Python + C extensions?

I'm distributing a Windows application that embeds Python 2.7 (technique: include python27.dll + 'Python27' directory with DLLs and Lib folder, alongside my .exe). I'm also including a custom Python package that uses C extensions (.pyd files which…
djangodude
  • 5,362
  • 3
  • 27
  • 39
2
votes
1 answer

Freeing a python list from C extension code

We have some code which creates a python list and then appends data items to it. Our concern is that if one of the data items turns out to be NULL, then we consider the whole of the list (that is, any previously added items) to be worthless, and…
1
vote
0 answers

Issue with SFCB, the python-binding layer and python providers in ESX 4.0

We are writing SFCB providers in python, Since SFCB talks to only C++ providers we need to have an intermediate layer(cmpi-bindings, a python extension module) which can talk to SFCB and start the provider when needed. The same cmpi layer is working…
1
vote
1 answer

Python Extension not installing into subpackage

I'm trying to build a Python extension and package it up using distutils but the extension installs in the root package no matter how I name it. My directory layout looks like this: foo/bar/extension.c My setup.py looks like this: from…
Rich
  • 12,068
  • 9
  • 62
  • 94