Python C extenstion and __init__.py
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Python C extenstion and __init__.py

From: <mwidj@yahoo.com>
Date: Tue Jun 28 2005 - 22:45:53 CEST

I'm building python extension for some solaris specific functions. My
setup.py looks like this:

setup.py:

from distutils.core import setup, Extension

sol_ex = Extension('sun.solaris',
         ['src/solarismodule.c',
         ])

setup (name = "solaris",
       version = "0.1",
       description = "Solaris specifics system calls module",
       ext_modules = [ sol_ex ],

After doing the 'python setup.py build' successfuly, I setup a test
script that looks like the following :

test.py:
import sun.solaris

After setting the PYTHONPATH to ./build/lib.solaris-2.9-sun4u-2.3 and
running the test.py, I got the following:

Traceback (most recent call last):
  File "test.py", line 1, in ?
    import sun.solaris
ImportError: No module named sun.solaris

It turns out that in addition to solaris.so, I also need __init__.py
(manually created) in ./build/lib.solaris-2.9-sun4u-2.3 to make the
extension works.

My question is how do I automate the creation (in setup.py) of
__init__.py so that when I build the extension, it will also creates
__init__.py in the build directory?

Thanks
Received on Sat Oct 15 03:56:12 2005