[Distutils] Replacing pip.exe with a Python script

Paul Moore p.f.moore at gmail.com
Wed Jul 17 15:33:15 CEST 2013


On 17 July 2013 14:13, Thomas Heller <theller at ctypes.org> wrote:

> Am 15.07.2013 19:26, schrieb Donald Stufft:
>
>  Maybe this is a crazy idea, but would a windows only extension work?
>> .pye(executable) Then just associate .pye with the launcher. Python
>> won't see .pye as importable so there's no shadow issues.
>>
>
> pip.bat?
>

That's my cue to cry :-)

If you missed my earlier comments about bat files, then no - bat files have
a significant number of failings that make them unsuitable for this sort of
thing. The simplest example I can give is that bat files don't nest. So if
the "pip" command is implemented as a bat file, and you have a script to
build your virtualenv that looks like this:

@echo off
virtualenv foo
foo\scripts\activate
pip install wibble
echo Complete!

then the final message would never be executed as the pip bat file would
not return to its caller. (Actually, the activate command is also a bat
file, so pip would never be executed either, but you get my point). That's
the worst sort of silent failure, and I have spent significant time in the
past debugging scripts that fell foul of this behaviour.

To fix this you have to use "call pip install wibble". And once you admit
the possibility that certain commands could be implemented as bat files you
have to either check everything, or use "call" everywhere, even when not
necessary (e.g. "call python") just to be safe.

If you don't think this problem is sufficient, I can offer more :-(

I'm afraid exe files as wrappers are probably the only viable option. The
basic reason is that the OS recognises exe files in all context, with no
special configuration needed. This is not true of any other file type. So
anything else will have corner cases that will give unexpected results.

Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20130717/f00ed736/attachment-0001.html>


More information about the Distutils-SIG mailing list