[Distutils] Extension modules and python modules

Chris Burns cburns1@swarthmore.edu
Mon Mar 24 21:30:02 2003


Hi,

Sorry if this has been answered before:  I looked through the archives
but couldn't find exactly the same problem I'm encountering.

I'm trying to put together a distribution that has a C extension as well
as a python module that wraps the extension, giving it a friendlier
interface (call the first  _spam.so  and the second spam.py:  spam.py
imports _spam.so).  I've gotten the setup.py script to correctly compile
and install, but when I try to make a binary distribution (bdist or 
bdist_rpm), it doesn't include the C extension, just the python module.  
This is such a basic thing (and common), I must be missing something really 
basic.  I'd appreciate any help.  My setup.py is included below.  I'm using 
python 2.2.2.

Chris


#!/usr/bin/env python
from distutils.core import setup, Extension
from distutils.sysconfig import get_python_inc
from distutils.sysconfig import get_python_lib
import os

num_lib_dir = os.path.join(get_python_lib(plat_specific=1), "Numeric")
num_inc_dir = os.path.join(get_python_inc(plat_specific=1), "Numeric")

ext = Extension("_spam", ["spam.c"],
                 include_dirs=[num_inc_dir], 
                 library_dirs=[num_lib_dir])

setup(name="spam",
      version="0.5",
      description="Spam Library",
      author="Chris Burns",
      ext_modules=[ext],
      py_modules=['spam'])


--
Chris Burns
Visiting Assistant Professor
Dept. of physics and astronomy, Swarthmore College
cburns1@swarthmore.edu      http://hven.swarthmore.edu/~burns