From: Ben Darnell Date: Tue, 19 Jul 2011 04:25:59 +0000 (-0700) Subject: Make "python -m tornado.autoreload" run with a consistent sys.path. X-Git-Tag: v2.1.0~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d31f1c636444e09291bc6b3543bc276b35845cd;p=thirdparty%2Ftornado.git Make "python -m tornado.autoreload" run with a consistent sys.path. --- diff --git a/tornado/autoreload.py b/tornado/autoreload.py index b34ace885..7c3ddb5cf 100644 --- a/tornado/autoreload.py +++ b/tornado/autoreload.py @@ -197,4 +197,12 @@ def main(): if __name__ == "__main__": + # If this module is run with "python -m tornado.autoreload", the current + # directory is automatically prepended to sys.path, but not if it is + # run as "path/to/tornado/autoreload.py". The processing for "-m" rewrites + # the former to the latter, so subsequent executions won't have the same + # path as the original. Modify os.environ here to ensure that the + # re-executed process will have the same path. + if sys.path[0] == '': + os.environ["PYTHONPATH"] = ".:" + os.environ.get("PYTHONPATH", "") main()