A project written in python with some C extensions (not using SWIG etc). I am trying to figure out how to structure my project so that:
- imports work. Importing the shared objects
- I don't need to change PYTHONPATH (tried figuring it out and failed).
- In the future, distributing the project package will be easiest.
Current structure is, as suggested here:
Project\
docs\ # mainly documentation, right?
bin\ # empty
setup.py # setup for the project, as suggested in the above link
project\
__init__.py
module.py
tests\
bla_test.py
C\ # the package of C files
file.c
file.so
other_c_stuff.c
header.h
setup.py # setup to compile the C files and create .so files
build\ # contaisn a bunch of (hopefully) irrelevant stuf
It worked from PyDev but not from shell. Ideal answer would adress the following:
- A suggested structure for the project.
- How an import would be perfomed (from, say, the by modules in
tests
). - Should (can) I keep all the C files in a separate library?
- The build of the C files is done in which of the
setup.py
files (should I post them here?) - Is it possible to automatically build when necessary? How?
I tried relative imports - they don't work for me for some reason. I saw the accepted answet to this question. He says - do whatever. But I can't get the imports to work. I read this answer, but have no clue what's all the stuff he has (and I don't have). The accepted answer doesn't help me because, again, the imports fail. This blog posts gives good advice but, again, the imports!