|
|
|
|
|
import sys |
import os |
from os.path import dirname as opd, exists, join, basename, abspath |
|
def searchpy(current): |
while 1: |
last = current |
initpy = join(current, '__init__.py') |
if not exists(initpy): |
pydir = join(current, 'py') |
|
if exists(pydir) and exists(join(pydir, '__init__.py')): |
|
|
|
if current != sys.path[0]: |
print >>sys.stderr, "inserting into sys.path:", current |
sys.path.insert(0, current) |
return True |
current = opd(current) |
if last == current: |
return False |
|
if not searchpy(abspath(os.curdir)): |
if not searchpy(opd(abspath(sys.argv[0]))): |
if not searchpy(opd(__file__)): |
pass |
|
import py |
|
if __name__ == '__main__': |
print "py lib is at", py.__file__ |
|