[Distutils] EasyInstall: scripts

Ian Bicking ianb at colorstudy.com
Mon May 30 03:16:17 CEST 2005

Phillip J. Eby wrote:
> It might help if there were some kind of metadata for scripts, like to 
> indicate whether something is a command-line utility, a graphical 
> application, etc.  Then distutils could tweak the file extension and/or 
> build a custom launcher for it (like Fredrik Lundh's exemaker for 
> Windows) as appropriate for the platform.  That information could then 
> be added to EGG-INFO and/or EGG-SCRIPTS, and used by EasyInstall to do 
> script installation and uninstallation.

That's what I'd be inclined towards.  Like, this is what one script I 
have looks like:

#!/usr/bin/env python
import os
import sys

     here = __file__
except NameError:
     # Python 2.2
     here = sys.argv[0]

# For when running directly out of the svn checkout:
relative_paste = os.path.join(
     os.path.dirname(os.path.dirname(os.path.abspath(here))), 'paste')
if os.path.exists(relative_paste):
     sys.path.insert(0, os.path.dirname(relative_paste))

from paste import app_setup

I think this could be better expressed as:

'script_modules': {'paster': 'paste.app_setup.run'}

And that whole script I give above is just a platform (Unixy) way of 
building that script.

Of course command-line scripts don't translate as well to other 
operating systems and environments.  Really these "scripts" should be 
one instance of an executable, that has a fairly minimal interface 
(__call__(args)).  A richer interface might make the arguments 
introspectable, with possible platform-specific GUIs built around them, 
or even richer interfaces.  I don't know what those would look like, but 
it would be nice to leave room for those.

I know for a lot of developers, myself included, I could support 
multiple platforms *if* it's easy to build for these from the platform I 
use.  But if I have to use a Mac to build a Mac distribution (ditto 
Windows) then (being realistic) I don't distribute things built for the 
Mac.  For the most part this doesn't matter -- the libraries are still 
quite usable on other platforms -- but this does cause problems for scripts.

Ian Bicking  /  ianb at colorstudy.com  / http://blog.ianbicking.org

More information about the Distutils-SIG mailing list