Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > setup.py for an extension

Reply
Thread Tools

setup.py for an extension

 
 
Paulo da Silva
Guest
Posts: n/a
 
      03-21-2012
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.
 
Reply With Quote
 
 
 
 
Richard Thomas
Guest
Posts: n/a
 
      03-21-2012
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"])])
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
newWizards as an extension and extension point? Elhanan Java 0 01-23-2007 08:11 AM
How to convert a .txt file extension to a .xls file extension? Steve ASP .Net 3 08-25-2006 05:43 PM
New extension? saw extension .emf is it safe to open Jer Computer Support 5 10-08-2005 04:43 PM
C extension=> pow(2,1) gives DIFFERENT answers in different parts of C extension!?!?! Any ideas why? Christian Seberino Python 3 02-05-2004 04:36 AM
Unload extension modules when python22.dll unloads... [using C extension interpreter] Anand Python 3 11-08-2003 05:50 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57