[Python-Dev] Setting project home path the best way

Christian Tismer tismer at stackless.com
Sun Nov 11 21:31:08 CET 2012

Hi friends,

I have a project that has its root somewhere on my machine. 
This project has many folders and contains quite some modules. 

There is a common root of the module tree, and I want to use
- either absolute imports
- relative imports with '.'


- I want to run any module inside the heirarchy from the command-line

- this should work, regardless what my 'cwd' is

- this should work with or without virtualenv. 

So far, things work fine with virtualenv, because sys.executable is in the project module tree. 

Without virtualenv, this is not so. But I hate to make settings like PYTHONPATH, because these are not permanent. .  


How should I define my project root dir in a unique way, without setting an environment variable?
What is the lest intrusive way to spell that?


I'd like to make things work correctly and unambigously when I call a script
inside the module heirarchy. Things are not fixed: there exist many checkouts
In the file system, and each should know where to search its home/root in the tree. 

Is this elegantly possible to deduce from the actually executed script file?

Cheers - chris

Sent from my Ei4Steve

More information about the Python-Dev mailing list