How should multiple (related) projects be arranged (structured) and configured so that they can share code, have a related package structure and enable proper unittesting, and ensuring no namespace collisions
ToddLMorgan
ToddLMorgan at gmail.com
Fri Apr 21 10:35:28 EDT 2006
Thanks everyone for their assistance.
I have managed to achieve all that I set out to do:
- separation between src and test folders
- now successfully sharing code between projects
- running unittest s and suites
- avoiding namespace collisions
The solution involved the following (if anyone else is interested)
- ammending all my __init__.py packages so that they included the
following:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
as per Peter Otten's suggestion
- refactoring all the code so that the imports and froms conformed to
the new package structure (a.b.c.common, a.b.c.app1 etc) and physically
moving all the required files
- ammending the PYTHONPATH so that the src and test directories for
each project is included at the time of running
ie
PYTHONPATH=COMMON/src;COMMON/test;APP1/src;APP1/test;APP2/src;APP2/test
Of course the /test entries are only required for testing and not
runtime but you get the idea.
I understand that flatter package structures are apparently the python
way (http://dirtsimple.org/2004/12/python-is-not-java.html) but I like
a nice little small little related package of functionality when I am l
carving up a complex problem so I'm happy to incur any extra
performance penalty in dict lookups.
thanks again
Todd
More information about the Python-list
mailing list