classification
Title: Scripts need platform-dependent handling
Type: feature request Stage: test needed
Components: Distutils Versions: Python 3.1, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: tarek Nosy List: ajaksu2, ceder, fdrake, mhammond, pmoore, tarek, tim_one (7)
Priority: normal Keywords

Created on 2004-01-04 19:00 by ceder, last changed 2009-02-15 09:54 by tarek.

Messages (14)
msg19537 - (view) Author: Per Cederqvist (ceder) Date: 2004-01-04 19:00
When a  script is installed on Unix, it should be named
something like "mailman-discard", with no extension.
When it is installed on Windows, it should be named
"mailman-discard.py", so that it is associated with
Python.  I think that "scripts" should be smart enough
to handle this.

My suggestion is that "scripts" should be set to a list
of the scripts, including the extension, and that
distutils will remove the extension when it installs
programs on platforms where this is true:

    os.name == 'posix'

It is possible to override the install_scripts class to
get this behaviour, but if you want to make a binary
distribution you also have to override bdist_wininst,
et c, since the install_scripts class is used on the
host system while building a directory tree that will
later be installed on the target system. See this
example script:

http://cvs.lysator.liu.se/viewcvs/viewcvs.cgi/mailman-discard/setup.py?rev=1.2&cvsroot=mailman-discard&content-type=text/vnd.viewcvs-markup
 
Peter Åstrand also suggests that on Windows, you should
create a command file named "mailman-discard.cmd" and
put it in the same directory as the
"mailman-discard.py" file.  It should contain a single
line:

start %~dp0\mailman-discard.py

That way, you will be able to start the script from a
dos shell, and not just by double-clicking it in a file
browser.  It would be nice if Distutils created this
file automatically when installing on the win32 platform.
msg19538 - (view) Author: Paul Moore (pmoore) Date: 2004-01-05 16:25
Logged In: YES 
user_id=113328

Having a ".cmd" file isn't a good idea. For a start, it isn't 
Windows 9x compatible (and %~dp0 isn't available in 
command.com). Also, you need to include a way of passing 
any command line arguments on to the script. And 
finally, "start" probably isn't right. This will run the command 
in a new console window, rather than in the existing console.

A XXX.cmd file which just does @%~dp0\XXX.py %* is 
better, but I still don't think it's needed. Just adding ".py" to 
PATHEXT (which is something the user can do if they want, 
at the same time they add the Python scripts directory to 
their PATH) is enough, at least on NT/2000/XP.
msg19539 - (view) Author: Per Cederqvist (ceder) Date: 2004-01-05 18:44
Logged In: YES 
user_id=129207

You have convinced me that the ".cmd" file was a bad idea,
so let's forget I ever mentioned it.

I still think that the extension should be removed on POSIX
platforms, however.  However, if you have "foo.py" and
"foo.sh" they would both end up as "foo"; this should
produce a diagnostic.
msg19540 - (view) Author: Mark Hammond (mhammond) Date: 2004-07-02 00:41
Logged In: YES 
user_id=14198

The obvious issue is that we can't change the semantics for
packages already out there.  Existing package maintainers
will not want this change made for them automatically, and
it is not clear that this is the desirable default behaviour
anyway.  Therefore, this isn't going to be considered a 'bug'.

I think what you are asking for is a new feature - a way to
give distutils the behaviour you desire, but leaving the
default semantics alone.  I suggest you close this bug as
"wont fix", and add a new feature request.  After that, try
and get some support for your idea from someone willing or
able to submit a patch.
msg19541 - (view) Author: Tim Peters (tim_one) Date: 2004-07-02 01:02
Logged In: YES 
user_id=31435

Note this was an active topic on distutils-sig last week.  
Assigned to Fred in hopes that he can summarize current 
thinking as a comment here.
msg19542 - (view) Author: Mark Hammond (mhammond) Date: 2004-07-02 01:52
Logged In: YES 
user_id=14198

Thanks Tim - I found the thread - interesting, and funnily
enough covers the same issues!  I also note
www.python.org/sf/976869 which is where Fred has made a patch.

My summary: nothing should be done implicitly.  Whatever is
done must be explicitly specified by the packager.  However,
no one is sure exactly how to spell it yet.
msg19543 - (view) Author: Tim Peters (tim_one) Date: 2004-07-02 01:58
Logged In: YES 
user_id=31435

Yup, I agree, Mark.  Fred too.  This has hit heated 
temperatures at times in the Zope world, where Windows 
users need .py extensions for sane script life under cmd.exe, 
but somewhat over half of Unixish geeks go on like they're 
being raped if an informative extension assults their prissy 
eyeballs <wink>.
msg19544 - (view) Author: Fred L. Drake, Jr. (fdrake) Date: 2004-07-02 03:30
Logged In: YES 
user_id=3066

Here's an idea about how to spell this:

http://mail.python.org/pipermail/distutils-sig/2004-July/004073.html
msg55169 - (view) Author: Fred L. Drake, Jr. (fdrake) Date: 2007-08-23 18:08
Removing the assignment to me, since I'm not going to resolve the
fundamental disagreements about what "the right thing" is.  Someone else
can argue with the wrong-headed.
msg82018 - (view) Author: Daniel Diniz (ajaksu2) Date: 2009-02-14 12:08
Has a decision been made on this? What's the current behavior on Windows?
msg82030 - (view) Author: Tarek Ziadé (tarek) Date: 2009-02-14 12:23
What do you think about the way setuptools handles it ?


I'd be in favor of integrating setuptools wrapping mechanism in distutils.

(not the entry point part, just the way it generates .exe under windows
and executable script under Linux)

see
http://peak.telecommunity.com/DevCenter/setuptools#automatic-script-creation
msg82035 - (view) Author: Paul Moore (pmoore) Date: 2009-02-14 12:42
In principle I don't have a problem with the automatic generation of an
EXE (I assume it generates a shell script with no extension on Unix?)
but it should be done in such a way that the EXE is version-independent.
This is necessary to ensure that pure-python packages, when made into
bdist_wininst installers, continue to be version-independent. (At the
moment, distutils generates version-dependent bdist_wininst packages
*only* for C extensions. Setuptools generates version-dependent
installers all the time, which is a pain).

This may mean that a reimplementation is required, rather than copying
the setuptools code.
msg82147 - (view) Author: Tarek Ziadé (tarek) Date: 2009-02-15 09:53
more discussion here :
http://mail.python.org/pipermail/distutils-sig/2009-February/010980.html
msg82148 - (view) Author: Tarek Ziadé (tarek) Date: 2009-02-15 09:54
> I assume it generates a shell script with no extension on Unix?

Yes
History
Date User Action Args
2009-02-15 09:54:24tareksetmessages: + msg82148
2009-02-15 09:53:16tareksetmessages: + msg82147
2009-02-14 12:42:40pmooresetmessages: + msg82035
2009-02-14 12:23:32tareksetassignee: tarek
messages: + msg82030
versions: + Python 3.1
2009-02-14 12:08:46ajaksu2setnosy: + tarek, ajaksu2
stage: test needed
type: feature request
messages: + msg82018
versions: + Python 2.7, - Python 2.3
2007-08-23 18:08:36fdrakesetassignee: fdrake -> (no value)
messages: + msg55169
nosy: tim_one, mhammond, fdrake, pmoore, ceder
2004-01-04 19:00:26cedercreate