I want to create a git repo that can be used like this:
git clone $PROJECT_URL my_project
cd my_project
python some_dir/some_script.py
And I want some_dir/some_script.py to import from another_dir/some_module.py.
How can I accomplish this?
Some desired requirements, in order of decreasing importance to me:
- No - sys.pathmodifications from within any of the- .pyfiles. This leads to fragility when doing IDE-powered automated refactoring.
- No directory structure changes. The repo has been thoughtfully structured. 
- No changes to my environment. I don't want to add a hard-coded path to my - $PYTHONPATHfor instance, as that can result in unexpected behavior when I- cdto other directories and launch unrelated python commands.
- Minimal changes to the sequence of 3 commands above. I don't want a complicated workflow, I want to use tab-completion for - some_dir/some_script.py, and I don't want to spend keystrokes on extra python cmdline flags.
I see four solutions to my general problem described here, but none of them meet all of the above requirements.
If no solution is possible, then why are things this way? This seems like such a natural want, and the requirements I list seem perfectly reasonable. I'm aware of a religious argument in a 2007 email from Guido:
I'm -1 on this and on any other proposed twiddlings of the
__main__machinery. The only use case seems to be running scripts that happen to be living inside a module's directory, which I've always seen as an antipattern. To make me change my mind you'd have to convince me that it isn't.
But not sure if things have changed since then.
 
    