Issue #10419, issue #6011: port 6ad356525381 fix from distutils to packaging

build_scripts command of packaging now handles correctly non-ASCII path (path
to the Python executable). Open and write the script in binary mode, but ensure
that the shebang is decodable from UTF-8 and from the encoding of the script.
2 files changed