diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2016-01-24 10:07:40 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2016-01-24 10:07:40 -0500 |
commit | e7f9dab06dc2515fe11e7f31ea948eed5e141470 (patch) | |
tree | eec9669a863418b59b9329648cd0ac7b6ba9d9ab /setuptools/launch.py | |
parent | 3b7b733ca9f2e3193426682ae6357b3f29307aa2 (diff) | |
download | external_python_setuptools-e7f9dab06dc2515fe11e7f31ea948eed5e141470.tar.gz external_python_setuptools-e7f9dab06dc2515fe11e7f31ea948eed5e141470.tar.bz2 external_python_setuptools-e7f9dab06dc2515fe11e7f31ea948eed5e141470.zip |
Add 'launch' hook, based on pip.utils.setuptools_build
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()) |