Newbie building SWIG wrappers with distutils
Hello, I searched the list archives and found some mention of getting SWIG v1.3 working with distutils but I couldn't find anything on the results of that effort. I've got a set of python modules that I'm beginning to convert to C/C++ extensions and some C/C++ code I want to wrap for Python using SWIG v1.3. I can get the extensions to build and work on their own (MacOS X 10.2.4, MacPython 2.3b1) but I can't get a distutils module to build them. My package directory looks something like this: Lib/ Lib/moduleA.py Lib/moduleB.py Packages/ Packages/__init__.py Packages/moduleC/ Packages/moduleC/moduleC.i Packages/moduleC/Lib/__init__.py Packages/moduleC/Include/moduleC.h Packages/moduleC/Src/moduleC.c where moduleA, moduleB are currently pure python but which may eventually converted to wrappers around C code and moduleC is being built as an extension. Based on the docs and study of other setup.py scripts, my script looks something like: extra_compile_args=["-Ddarwin"] packages=["WTBlib"] package_dir={'WTBlib':"Lib"} include_dirs=[os.path.join('/usr','local','lib')] ext_modules=[] packages.append('WTBlib.moduleC') package_dir['WTBlib.moduleC']=os.path.join('Packages','moduleC','Lib') include_dirs.append(os.path.join('Packages','moduleC','Include')) ext_modules.append(Extension('moduleC', [os.path.join('Packages','moduleC','Src','moduleC.c'), os.path.join('Packages','moduleC','moduleC.i')], extra_compile_args = extra_compile_args, include_dirs=include_dirs)) setup(name='WTBlib',version = "0.1", packages = packages, package_dir = package_dir, description = "", include_dirs = include_dirs, ext_package = "WTBlib", ext_modules = ext_modules) Currently, it fails trying to build the SWIG wrapper. So I built the wrappers manually (moduleC_wrap.c and moduleC.py and modified setup.py accordingly. I expected it to build in site-packages something like: WTBlib/ WTBlib/moduleA.py WTBlib/moduleB.py WTBlib/moduleC/ WTBlib/moduleC/_moduleC.so WTBlib/moduleC/moduleC.py WTBlib/moduleC/__init__.py which I believe is what I want. However, after having to modify things like #include paths in the wrapper file I can finally get it to build something like: WTBlib/ WTBlib/__init__.py WTBlib/moduleA.py WTBlib/moduleB.py WTBlib/moduleC.so WTBlib/moduleC/ WTBlib/moduleC/moduleC.py WTBlib/moduleC/__init__.py which just doesn't work at all. Pretends to import but no guts in the routines. Part of my problem is clearly that I don't understand how each of the components entered into the setup.py gets transformed into a path for such things as file copy and compilation parameters. Is there a better source of info on that? What is the status of letting distutils build the wrapper files? Also, just what is the __init__.py file for and is there ever a reason to put routines in it? Thanks, Tom
participants (1)
-
W.T. Bridgman