def fixup_pth_and_egg_link(home_dir, sys_path=None):
home_dir = os.path.normcase(os.path.abspath(home_dir))<EOL>if sys_path is None:<EOL><INDENT>sys_path = sys.path<EOL><DEDENT>for path in sys_path:<EOL><INDENT>if not path:<EOL><INDENT>path = '<STR_LIT:.>'<EOL><DEDENT>if not os.path.isdir(path):<EOL><INDENT>continue<EOL><DEDENT>path = os.path.normcase(os.path.abspath(path))<EOL>if not path.startswith(home_dir):<EOL><INDENT>logger.debug('<STR_LIT>' % path)<EOL>continue<EOL><DEDENT>for filename in os.listdir(path):<EOL><INDENT>filename = os.path.join(path, filename)<EOL>if filename.endswith('<STR_LIT>'):<EOL><INDENT>if not os.access(filename, os.W_OK):<EOL><INDENT>logger.warn('<STR_LIT>' % filename)<EOL><DEDENT>else:<EOL><INDENT>fixup_pth_file(filename)<EOL><DEDENT><DEDENT>if filename.endswith('<STR_LIT>'):<EOL><INDENT>if not os.access(filename, os.W_OK):<EOL><INDENT>logger.warn('<STR_LIT>' % filename)<EOL><DEDENT>else:<EOL><INDENT>fixup_egg_link(filename)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>
Makes .pth and .egg-link files use relative paths