aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/launch.py
blob: 68cce68112fd237945f474a2fca6b6a1a8892f27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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())