[Python-Dev] Re: Utility scripts

Paul Moore p.f.moore at gmail.com
Mon Oct 4 22:03:24 CEST 2004

Tim Peters <tim.peters at gmail.com> writes:

> [Paul Moore]
>> ...
>> Can anyone test this on COMMAND.COM on Win9x?
> PATHEXT has no special meaning on 9x; you can set PATHEXT on 9x, but
> it has no effect.

Right. That means that this isn't a general Windows solution. On the
other hand, further experimentation seems to imply that all that
PATHEXT actually does is allow the ".py" to be omitted - I hadn't
realised that. So as things stand, putting a ".py" script, with a #!
line, into sys.prefix+'/scripts', and setting the executable bit on
Unix, is already a general way of installing a command - with two

1. The user must add the directory to his PATH
2. The command must be typed with the .py extension specified

So why do existing extensions not do this? Things like wxPython
and Twisted seem to jump through a lot of hoops for little benefit
beyond allowing users to omit the .py extension...

Maybe it would be worth adding a paragraph to section 3.4 of
"Distributing Python Modules" (the "Installing Scripts" section)
saying something like:

    Scripts should be given names with a .py extension. This allows
    them to be executed on both Unix and Windows systems (Windows uses
    the extension to locate the correct interpreter, in this case
    Python, in much the same way that Unix uses the #! line).

Of course, this will enrage Unix users who dislike file extensions :-)
Maybe having a user-specifiable option, something like --strip-ext, to
strip the .py extension from scripts when installing, would be useful.
(I recall something like this being discussed on the distutils-sig a
while back. Maybe this discussion should move there.)

>> - Change the Windows Python binary to add .py (and .pyw, maybe) to
> I don't like that.  The Python Windows installer doesn't add, or
> modify, any environment variables now.  It's anti-social to muck with
> them.

OK, that's the policy I was thinking of.

Be who you are and say what you feel, because those who mind don't
matter and those who matter don't mind. -- Dr. Seuss

More information about the Python-Dev mailing list