[Distutils] Wheels and console script entry point wrappers (Was: Replacing pip.exe with a Python script)
oscar.j.benjamin at gmail.com
Tue Jul 16 17:40:18 CEST 2013
On 16 July 2013 16:22, Paul Moore <p.f.moore at gmail.com> wrote:
> On 16 July 2013 16:09, Oscar Benjamin <oscar.j.benjamin at gmail.com> wrote:
>> However, if you also want the program name to be invokable from e.g.
>> subprocess with shell=False or from git-bash or Cygwin or many other
>> things then neither .bat files nor PATHEXT are sufficient. Wrapper
>> .exes are necessary to ensure that this works properly.
> Yes. I have been convinced that ultimately, wrapper exes are the only
> "transparent" means of writing command-line applications on Windows.
> Because of this, I'd quite like it if wrapper functionality were added to
> the py launcher (most of the functionality is already present, it would
> probably be a pretty small change) so that we had a "one obvious way" of
> writing wrappers. I may try to put together a patch for CPython to this
I don't know whether or not you intend to have wrappers also work for
Python 2.7 (in a third-party package perhaps) but there is a slightly
subtle point to watch out for when non-ASCII characters in sys.argv
come into play.
Python 2.x uses GetCommandLineA and 3.x uses GetCommandLineW. A
wrapper to launch 2.x should use GetCommandLineA and CreateProcessA to
ensure that the 8-bit argument strings are passed through unaltered.
To launch 3.x it should use the W versions. If not then the MSVC
runtime (or the OS?) will convert between the 8-bit and 16-bit
encodings using its own lossy routines.
More information about the Distutils-SIG