Newbie Developing a Python Extension

Jeremy cping at dso.org.sg
Fri Nov 24 08:59:12 CET 2006


Hi,

I have been working on Linux 2.6.9 to adapt a C++ module to work as a Python
extension with the following setup.py file:

from distutils.core import setup, Extension

sm=Extension(
 'tdma',
 define_macros=[('__USE_POSIX199309','1')],
 include_dirs=['/usr/include','/usr/include/python2.3'],
 library_dirs=['/usr/lib'],
 sources=['Bitstrea.cpp','bytequeu.cpp','debug.cpp','dlist.cpp',
  'GrPort.cpp','IoPort.cpp','LMEmu.cpp','LMEmuPdu.cpp',
  'MacPyIf.cpp','per_os_clk.cpp','timer.cpp'])

setup(name='MySm',
 version='0.1.0',
 description='TDMA MAC',
 ext_modules=[sm])

The extension uses the POSIX call clock_gettime() and things seem fine when
generating the tdma.so file. However, when running the Python program, at a 
line 'from tdma import init,txdn,txup,...', I get an error message saying 
'ImportError: /home/.../tdma.so: undefined symbol: clock_gettime'.

What is wrong here? Is the from-import statement right?

Why is it, when I use 'import sm' or 'from sm import...', I get the message 
'ImportError: No module named sm'?

Thanks,
Jeremy 





More information about the Python-list mailing list