Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/cdefs.py
Show All 30 Lines | def get_srcdir(): | ||||
if contains_src(srcdir): | if contains_src(srcdir): | ||||
return srcdir | return srcdir | ||||
# Try to work it based out on main module | # Try to work it based out on main module | ||||
import sys | import sys | ||||
mainmod = sys.modules['__main__'] | mainmod = sys.modules['__main__'] | ||||
mainmod_path = getattr(mainmod, '__file__', '') | mainmod_path = getattr(mainmod, '__file__', '') | ||||
if mainmod_path and mainmod_path.endswith('.py'): | if mainmod_path and mainmod_path.endswith('.py'): | ||||
maybe_top = mainmod_path | maybe_top = os.path.realpath(mainmod_path) | ||||
while maybe_top != '/': | while maybe_top != '/': | ||||
maybe_top = os.path.abspath(os.path.dirname(maybe_top)) | maybe_top = os.path.abspath(os.path.dirname(maybe_top)) | ||||
if contains_src(maybe_top): | if contains_src(maybe_top): | ||||
return maybe_top | return maybe_top | ||||
# No luck, give up. | # No luck, give up. | ||||
return None | return None | ||||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |