[Pyrex] [newbie] first error : "init function"
Jean-Baptiste Richet - AREAS
jb.richet at areas.asso.fr
Fri Sep 19 17:42:35 CEST 2003
Hi,
I'm trying pyrex to use my C functions into new jobs I want to implement
in python ('cause it's nicer). I'm working on a linux box for the while.
I wrote my .pyx file, mostly imitating the pyxcups.pyx given by Michael
JasonSmith, and using distutils. It compiles, but when trying to import
the module in python, it clames for an init function !?
Here are the messages :
===============================
jb at areas:~/routines/commun/test_pyrex$ python setup.py build
running build
running build_ext
building 'py_date' extension
creating build
creating build/temp.linux-i686-2.3
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall
-Wstrict-prototypes -fPIC -I/usr/local/include/python2.3 -c pro_auget.c
-o build/temp.linux-i686-2.3/pro_auget.o
pro_auget.c: In function `initpro_auget':
pro_auget.c:130: warning: label `__pyx_L1' defined but not used
pro_auget.c: At top level:
pro_auget.c:8: warning: `__Pyx_UnpackItem' declared `static' but never
defined
pro_auget.c:9: warning: `__Pyx_EndUnpack' declared `static' but never
defined
pro_auget.c:12: warning: `__Pyx_Raise' declared `static' but never defined
pro_auget.c:13: warning: `__Pyx_ReRaise' declared `static' but never defined
pro_auget.c:14: warning: `__Pyx_Import' declared `static' but never defined
pro_auget.c:15: warning: `__Pyx_GetExcValue' declared `static' but never
definedpro_auget.c:16: warning: `__Pyx_GetName' declared `static' but
never defined
pro_auget.c:17: warning: `__Pyx_ArgTypeTest' declared `static' but never
definedpro_auget.c:18: warning: `__Pyx_TypeTest' declared `static' but
never defined
pro_auget.c:19: warning: `__Pyx_GetStarArgs' declared `static' but never
definedpro_auget.c:20: warning: `__Pyx_WriteUnraisable' declared
`static' but never defined
pro_auget.c:22: warning: `__Pyx_ImportType' declared `static' but never
defined gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall
-Wstrict-prototypes -fPIC -I/usr/local/include/python2.3 -c date.c -o
build/temp.linux-i686-2.3/date.o
date.c: In function `dates_non_croissantes':
date.c:190: warning: unknown conversion type character 0xa in format
date.c:191: warning: control reaches end of non-void function
date.c: In function `positionne_flot':
date.c:331: warning: unused variable `i'
date.c:329: warning: unused variable `trouve'
creating build/lib.linux-i686-2.3
gcc -pthread -shared build/temp.linux-i686-2.3/pro_auget.o
build/temp.linux-i686-2.3/date.o -o build/lib.linux-i686-2.3/py_date.so
jb at areas:~/routines/commun/test_pyrex$ cd build/lib.linux-i686-2.3/
jb at areas:~/routines/commun/test_pyrex/build/lib.linux-i686-2.3$ python
Python 2.3 (#3, Sep 15 2003, 14:12:28)
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import py_date
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: dynamic module does not define init function (initpy_date)
>>>
================================
Here is my very simple .pyx file :
============= pro_auget.pyx ============
cdef extern from "pro_auget_pyx.h":
ctypedef struct Tps:
int tps_10e
int tps_sec
int tps_min
int tps_h
int tps_j
int tps_m
int tps_year
int decomp_date(double t, Tps* pdate)
def py_decomp_date(t):
cdef Tps date
retour = decomp_date(t,&date)
print "%2d/%2d/%4d %2d:%2d:%2d,%1d\n" %
(date.tps_j,date.tps_m+1,date.tps_year+1900,date.tps_h, date.tps_min,
date.tps_sec, date.tps_10e)
====================================
Maybe the confusion comes from my setup.py file (imitating the demo's as
well, without realy understanding)... here is it:
=============== setup .py ==============
from distutils.core import setup
from distutils.extension import Extension
from Pyrex.Distutils import build_ext
setup(
name = "py_pro_auget",
ext_modules=[
Extension("py_date", ["pro_auget.pyx", "date.c"])
],
cmdclass = {'build_ext': build_ext}
)
=====================================
It is probably a very stupid error, but I understand too few things to
find it out.
Thanks a lot for your help.
--
Jean-Baptiste Richet
AREAS
_________________________________
Association régionale pour l'étude
et l'amélioration des sols
2, avenue Foch
F-76460 Saint Valéry en Caux
tél : +33 2 35 97 25 12
fax : +33 2 35 97 25 73
_________________________________
More information about the Pyrex
mailing list