[Distutils] Replacing pip.exe with a Python script

Nick Coghlan ncoghlan at gmail.com
Thu Jul 18 00:21:14 CEST 2013

On 18 Jul 2013 05:13, "Paul Moore" <p.f.moore at gmail.com> wrote:
> On 17 July 2013 19:55, Steve Dower <Steve.Dower at microsoft.com> wrote:
>> > 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
>> > configuration needed. This is not true of any other file type. So
anything else
>> > will have corner cases that will give unexpected results.
>> No reason to be afraid of this, exe wrappers are totally the best option.
>> As for updating .exes while they're running, the best approach is to
rename the running one (e.g. 'pip.exe' -> 'pip.exe.deleteme') in the same
folder and either:
>> * delete any existing .deleteme files on next run, or
>> * delete an existing pip.exe.deleteme file immediately before trying to
rename to it
>> Any other approach will also have corner cases, but this will be the
most reliable in the context of multiple users/permissions/environment
> Cool. I'm not happy about the clutter of '.deleteme' files, and I'll
still look for a way to delete them straight after the upgrade process
terminates, but I may have to settle for lazy deletion.

Call them ".previous" and it looks less ugly, in my opinion. You can also
just try deletion first and only if that fails do the renaming trick. EAFP
and all that :)


> The problem issue remaining is recognising when we need to do this. In
terms of code paths, pip install -U pip is no different from (for example)
pip install -U flask. But it needs to be handled specially just because
it's pip. And it *doesn't* need to be handled specially if it's "python -m
pip install -U pip". That's not a Windows issue, though, I was just using
the Windows issue to put off having to think about it :-)
> One thought, while I have a Windows expert's attention ;-) Is there a way
(I'm not too bothered how complex it might be) of doing the equivalent of
Unix exec in Windows? That is, start a new process and then have my initial
process exit *without* the shell (or whatever started the first process)
getting control back until the child completes? I'm assuming not, as
otherwise solving the issue would be as easy as exec-ing "python -m pip"
from the wrapper. But no harm in asking :-)
> Paul
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> http://mail.python.org/mailman/listinfo/distutils-sig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20130718/70e43454/attachment-0001.html>

More information about the Distutils-SIG mailing list