diff options
Diffstat (limited to 'setuptools/launch.py')
| -rw-r--r-- | setuptools/launch.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/setuptools/launch.py b/setuptools/launch.py new file mode 100644 index 00000000..68cce681 --- /dev/null +++ b/setuptools/launch.py @@ -0,0 +1,28 @@ +""" +Launch the Python script on the command line after +setuptools is bootstrapped via import. +""" + +# Note that setuptools gets imported implicitly by the +# invocation of this script using python -m setuptools.launch + +import tokenize +import sys + + +def load(): + """ + Load the script in sys.argv[1] and run it as if it had + been invoked naturally. + """ + globals()['__file__'] = sys.argv[1] + sys.argv[:] = sys.argv[1:] + + open_ = getattr(tokenize, 'open', open) + script = open_(__file__).read() + norm_script = script.replace('\\r\\n', '\\n') + return compile(norm_script, __file__, 'exec') + + +if __name__ == '__main__': + exec(load()) |
