[Distutils] Improving distutils' script and GUI app handling

Phillip J. Eby pje at telecommunity.com
Sat Sep 17 19:17:59 CEST 2005

At 10:00 PM 9/16/2005 +0100, Paul Moore wrote:
>On 9/16/05, Trent Mick <trentm at activestate.com> wrote:
> > > The only missing piece so far, for me at least, is that it's not
> > > possible to use dotted module names with the -m option:
> > >
> > > p24 -m ctypes.wrap.h2xml windows.h
> >
> > That's too bad. I didn't know "-m" didn't support that... but then I
> > haven't really used it that much yet.
>There's a patch on SF to implement that (1043356 ) and a corresponding
>PEP (338), but I don't know what's required to get it added.
>Another annoyance with -m is that it doesn't support modules in
>zipfiles (e.g., zipped eggs).

Really, the only reasonable way to solve both problems is something like 
'python -m run foo.bar ....'.  That is, have a bootstrap module to do the 
rest.  (Or alternately, have -m fallback to using the bootstrap module if 
it's unsuccessful.)

However, after reflection, I think now that -m probably only really makes 
sense for stdlib modules, since projects using setuptools can now get all 
the benefits of -m without any of the drawbacks, without even writing any 
__name__=='__main__' code.  For example defining an entry point thus:

      h2xml = ctypes.wrap.h2xml:main

automatically creates 'h2xml.exe' on Windows and a #!-prefixed 'h2xml' 
script on any other platform.  (Using the current CVS version of 
setuptools, that is.)

More information about the Distutils-SIG mailing list