[Distutils] console scripts in distutils

Robert Kern robert.kern at gmail.com
Sat Feb 14 23:23:33 CET 2009


On 2009-02-14 06:26, Tarek Ziadé wrote:
> Hello
>
> I really like the way setuptools wraps scripts depending on the platform.
>
> http://peak.telecommunity.com/DevCenter/setuptools#automatic-script-creation
>
> I am not talking about the entry_point feature, but the way it creates
> executables.
>
> What would people think about making that feature go into distutils
> itself to enhance the current script behavior?
>
> http://bugs.python.org/issue870479

I have a couple of issues with this feature as implemented in setuptools. I 
think they should be addressed if the feature makes its way into the stdlib:

1. The pkg_resources import can make startup time quite large. For small 
command-line utilities like my grin tool and DivMod's PyFlakes, this can make 
them unusable. If you bring the feature into the stdlib, please pay attention to 
the overhead of locating the real script however you end up doing it.

2. In the generated script, please use "if __name__ == '__main__':" to block out 
the executable bits. Currently, multiprocessing does not work on Windows when 
the application is started by a console_script. Because Windows does not have a 
true fork, multiprocessing will start up clean Python subprocesses that import 
the __main__ of the parent process.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco



More information about the Distutils-SIG mailing list