[Distutils] How to handle launcher script importability?

Paul Moore p.f.moore at gmail.com
Tue Aug 13 18:33:36 CEST 2013


On 13 August 2013 16:58, PJ Eby <pje at telecommunity.com> wrote:

> > 5. Files in use can't be replaced. Because a Windows executable that's
> in use
> > is not allowed to be overwritten,
>
> But they can be renamed, and deleted afterwards.  For example, when
> updating, you can do the simple dance of:
>
> 1. delete scriptname.exe.deleteme if it exists
> 2. rename scriptname.exe to scriptname.exe.deleteme
> 3. replace scriptname.exe
> 4. try to delete the .deleteme file created in step 2, ignoring errors.
>
> And since this only needs to be done for the wrappers on installation
> tools themselves (pip, easy_install, etc.), it's not like a lot of
> people are going to have to write this code.


This works, but is an ugly, fragile workaround. It's *not* a huge problem,
it's just how executables work on Windows, and all installers have to deal
with this dance (it's why a lot of things need a reboot to complete
installation - the "delete on next reboot" API). But it's not *nice*.

I would never use exe wrappers for my own personal scripts - I *always*
write them as .py files and rely on PATHEXT. I only use exe wrappers for
commands installed as part of a Python package (pip.exe, nosetests.exe,
etc). That says something about how friendly they are as a general tool. On
the other hand, it also acts as a reminder that when used in a suitably
managed situation (stuff installed by pip/easy_install) the ugliness of exe
wrappers is hidden well enough to be a non-issue. So while Jason may be
persuaded to retain exe wrappers for setuptools, I doubt he'd want to use
them for his personal scripts (if I read his posts correctly). I know I
won't.

On another point you mention, Cygwin Python should be using Unix-style
shell script wrappers, not Windows-style exes, surely? The whole point of
Cygwin is that it emulates Unix, after all... So I don't see that as an
argument either way.

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


More information about the Distutils-SIG mailing list