setup.py for an extension

P

Paulo da Silva

Hi all.

I have a python extension (bindings for a C lib - no swig) and I would
like to write a setup.py to build a source distribution pack.

The extension consists of 3 files:
foo.h
foo.c
foo.py
that are placed in a eclipse directory
/home/<user>/ECLIPSE/workspace/ext/src

foo.h+foo.c are to be compiled into _foo.so shared lib. _foo.so is
itself a module only called from foo.py.

The dir I wrote the setup.py is any arbitrary dir. I don't want to put
packaging stuff into the eclipse source.

I read the docs but have no idea on how to do this. Some tentatives I
did completely failed.

Any help?

Thanks in advance.
 
R

Richard Thomas

Assuming you have:
lib/__init__.py
lib/foo.py
lib/foo.c

Then:
from distutils.core import setup, Extension
setup(name="lib", packages=["lib"], ext_modules=[Extension("lib._foo", ["lib/foo.c"])])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top