473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Wrapping C functions in Pyrex and distutils problem

TPJ
I'm trying to get a wrapper for my C code in order to be able to use it
as a module in Python. I'm doing it as follows:

C code (file_c.c):
-------------------------------
#include <stdio.h>

void hello( int size )
{
printf("Hello! %d\n", size);
}
-------------------------------

Pyrex code (file.pyx):
-------------------------------
cdef extern void hello( int size )
-------------------------------

Python code (setup.py):
-------------------------------
from distutils.core import setup
from distutils.extension import Extension
from Pyrex.Distutils import build_ext

setup(
name = "File",
ext_modules=[
Extension( "file", ["file.pyx", "file_c.c"] )
],
cmdclass = { 'build_ext': build_ext }
)
-------------------------------

After

$ python setup.py build_ext --inplace

all is compiled ok, but the shared library (file.so) is built only from
one file (file_c.o) - and the second object file (file.o) is ignored.
Of course it's imposible to import such a module in Python.

What am I doing wrong?

Nov 9 '05 #1
1 1457
Use additional_objects:
--------
LINKBASE = "link-4.1b"

setup(
name = "LinkWrapper",
ext_modules = [
Extension("link", ["link.pyx"],
include_dirs = ["%s/include" % LINKBASE],
extra_objects = glob.glob("%s/obj/*" % LINKBASE),
)
],
cmdclass = {'build_ext': build_ext}
)
---------

--

Regards,

Diez

Nov 9 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Gary Stephenson | last post by:
I'm getting a clean generate, compile and link from my .pyx script, but when I attempt to run the resultant .exe, I get: "The procedure entry point Py_NoneStruct could not be located in the...
6
by: SeeBelow | last post by:
I just read "about Pyrex" at http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/version/Doc/About.html It seems that it is not compiled into machine code, as C would be, and therefore it does...
1
by: SM | last post by:
Hi, I would like to play with Pyrex for Windows. I have no clue how to install it including a c compiler. Anyone using pyrex on windows who could give a quickstart? Stani http://spe.pycs.net...
13
by: Roy Smith | last post by:
I've got a C library with about 50 calls in it that I want to wrap in Python. I know I could use some tool like SWIG, but that will give me a too-literal translation; I want to make some...
1
by: Martin Bless | last post by:
Now that I've got my extension building machine using the VC++ Toolkit 2003 up and running I'm keen on using Pyrex (Pyrex-0.9.3, Python-2.4.0). But the definition of the swig_sources() method...
4
by: Carl | last post by:
I have recently started to use Pyrex and am amazed by it's useability. Are there any alternatives to Pyrex? One thing that I haven't figured out is how to embed pure C/C++ source code into...
6
by: ajikoe | last post by:
Hello I tried to combine c++ and python together. So I follow from this website: http://kortis.to/radix/python_ext/ I have this code: # prmodule.c static PyObject *pr_isprime(PyObject *self,...
1
by: Will Ware | last post by:
I am trying to build a Pyrex module on Mac OS X version 10.3.9 (don't know which big cat that is). It already builds fine on Mandrake Linux and Windows XP. I have one source file where gcc hangs if...
27
by: Julien Fiore | last post by:
Do you wand to install Pyrex on Windows ? Here is a step-by-step guide explaining: A) how to install Pyrex on Windows XP. B) how to compile a Pyrex module. Julien Fiore, U. of Geneva
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.