Skip to content

Instantly share code, notes, and snippets.

@MattDietz
Created July 24, 2013 17:51
Show Gist options
  • Save MattDietz/6072825 to your computer and use it in GitHub Desktop.
Save MattDietz/6072825 to your computer and use it in GitHub Desktop.
Finding python tree root
import os
import sys
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
os.pardir,
os.pardir))
if os.path.exists(os.path.join(possible_topdir, '<project name>', '__init__.py')):
sys.path.insert(0, possible_topdir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment