You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
812B

  1. """
  2. Launch the Python script on the command line after
  3. setuptools is bootstrapped via import.
  4. """
  5. # Note that setuptools gets imported implicitly by the
  6. # invocation of this script using python -m setuptools.launch
  7. import tokenize
  8. import sys
  9. def run():
  10. """
  11. Run the script in sys.argv[1] as if it had
  12. been invoked naturally.
  13. """
  14. __builtins__
  15. script_name = sys.argv[1]
  16. namespace = dict(
  17. __file__=script_name,
  18. __name__='__main__',
  19. __doc__=None,
  20. )
  21. sys.argv[:] = sys.argv[1:]
  22. open_ = getattr(tokenize, 'open', open)
  23. with open_(script_name) as fid:
  24. script = fid.read()
  25. norm_script = script.replace('\\r\\n', '\\n')
  26. code = compile(norm_script, script_name, 'exec')
  27. exec(code, namespace)
  28. if __name__ == '__main__':
  29. run()