[ python-Bugs-870479 ] Scripts need platform-dependent handling

SourceForge.net noreply at sourceforge.net
Thu Jul 1 21:52:06 EDT 2004


Bugs item #870479, was opened at 2004-01-05 06:00
Message generated for change (Comment added) made by mhammond
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=870479&group_id=5470

Category: Distutils
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Per Cederqvist (ceder)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: Scripts need platform-dependent handling

Initial Comment:
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.

----------------------------------------------------------------------

>Comment By: Mark Hammond (mhammond)
Date: 2004-07-02 11:52

Message:
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.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2004-07-02 11:02

Message:
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.

----------------------------------------------------------------------

Comment By: Mark Hammond (mhammond)
Date: 2004-07-02 10:41

Message:
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.

----------------------------------------------------------------------

Comment By: Per Cederqvist (ceder)
Date: 2004-01-06 05:44

Message:
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.

----------------------------------------------------------------------

Comment By: Paul Moore (pmoore)
Date: 2004-01-06 03:25

Message:
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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=870479&group_id=5470



More information about the Python-bugs-list mailing list