There are many suggestions on the web what the structure of the Python project can/shall be, e.g. What is the best project structure for a Python application?.
"proj-dir"
+- doc
+- apidoc
+- scripts
+- "src-dir"
+- tests
It seems that many people in the Python world prefer the "src-dir" and "proj-dir" to be equal (or very similar). However, the scripts and tests will surely have to import some modules from src-dir, so either I have to
- run all scripts and tests when proj-dir as my current working dir, or
- the PYTHONPATH must contain the proj-dir, right?
Or, is there any other possibility which I overlook now?
Suppose I have such structure and have set up the PYTHONPATH correctly. Now I commit the project into VCS and another developer checks the project out. On his machine the PYTHONPATH will not be set properly and the imports in scripts and in tests will not work.
- Is there any possibility to somehow make the PYTHONPATH definition part of the project, so that it can be part of the version control?
- Is there a different project structure that would allow me to make checkout and start using the project without modifying the PYTHONPATH?
- Is to solution suggested here: Python - How to PYTHONPATH with a complex directory structure? (i.e. to include a short sys.path modifying snippet in every script and test) the right one?
- Would a site module http://docs.python.org/2/library/site.html be of any help?
- What is your workflow when developing a project with a similar structure?