[Distutils] Installing scripts

Fred L. Drake, Jr. fdrake at acm.org
Thu Jul 1 23:27:16 EDT 2004


On Thursday 01 July 2004 09:59 pm, Mark Hammond wrote:
 > Tim just pointed this thread out to me, so I thought I would try and keep
 > it alive :)

Good timing!  I'be been thinking about this just this evening.

 > How about something like:
 >
 > strip_extensions = {"posix": "txt py pyw", "darwin": "txt" }
 >
 > Where strip_extensions is a dictionary, keyed by the platform name (either
 > sys.platform or os.name - whatever makes sense.  The value is the list of
 > extensions that should be stripped.

So how do you spell "I want the extension stripped from this one file on one 
platform, and that's it."?  I'm also confused by your inclusion of "txt"; 
does this apply to all file copies, just scripts, or some magically 
determined set of file copies?

I think the answer is that we want something similar to the Extension class 
for scripts, to give us a "bag" for script-specific options.  I don't see any 
reason to extend extension-stripping beyond scripts.

If we have a Script class that parallels Extension, that could encapsute some 
of the script-specific options.  Listing scripts with just paths instead of 
Script instances would cause the current behavior to be used (which should 
also be what's used for just Script('path/scriptname.py')).

That would allow something like this in setup.py:

from distutils.core import setup, Script

setup(name='Some Python Utilities',
      packages=['mytools'],
      scripts=[Script('bin/dostuff.py', strip_extension=1),
               Script('bin/morestuff.py', strip_extension=1, sbin=1),
               ],
      )

Additional keywords might be used to mark a script to be installed only on 
certain platforms.  This could be used to install different scripts under the 
same name on different platforms (for example, a Mac OS X-specific script on 
Mac OS X, and a Tkinter script on Windows and other Unix systems).

I've not determined what just the right interface would be between Script and 
the build_scripts and install_scripts commands; still thinking about that.


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>




More information about the Distutils-SIG mailing list