python-exec / src /

Full commit
# vim:fileencoding=utf-8:ft=python
# (c) 2012 Michał Górny
# Released under the terms of the 2-clause BSD license.
# This is not the script you are looking for. This is just a wrapper.
# The actual scripts of this application were installed with -python*,
# -pypy* or -jython* suffixes. You are most likely looking for one
# of those.

from __future__ import with_statement
import os.path, sys

# XXX: avoid sys.executable if possible
epython = os.path.basename(sys.executable)
self = sys.argv[0] + '-' + epython

__file__ = self
sys.argv[0] = self

	kwargs = {}
	if sys.version_info[0] >= 3:
		import tokenize

		# need to provide encoding
		with open(self, 'rb') as f:
			kwargs['encoding'] = tokenize.detect_encoding(f.readline)[0]

	with open(self, 'r', **kwargs) as f:
		data =
except IOError:
	sys.stderr.write('This Python implementation (%s) is not supported by the script.\n'
			% epython)