[Distutils] Replacing pip.exe with a Python script

Paul Moore p.f.moore at gmail.com
Wed Jul 17 21:12:56 CEST 2013


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
> special
> > 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 variables.
>

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.

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20130717/0f529eaa/attachment.html>


More information about the Distutils-SIG mailing list