Skip to content

Instantly share code, notes, and snippets.

@soldni
Last active August 29, 2015 14:00
Show Gist options
  • Save soldni/7a93107cac59734f4384 to your computer and use it in GitHub Desktop.
Save soldni/7a93107cac59734f4384 to your computer and use it in GitHub Desktop.
import os
import sys
# BEGIN PYTHONPATH FIX #
# appends root of project if PYTHONPATH is not set;
# relies on the presence of .git in project root.
root_proj_path = os.getcwd()
root_flag = False
while not('.git' in os.listdir(root_proj_path)) and not(root_flag):
if root_proj_path == '/':
root_flag = True
root_proj_path = os.path.split(root_proj_path)[0]
print root_proj_path
if not(root_proj_path in sys.path) and not(root_flag):
sys.path.append(root_proj_path)
# END PYTHONPATH FIX #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment