[Distutils] scripts versus console_scripts

Reinout van Rees reinout at vanrees.org
Thu Sep 3 17:46:57 CEST 2009

On 2009-09-02, Jim Fulton <jim at zope.com> wrote:
> Note that, as Tarek reminded us, buildout lets you define entry points
> yourself. In fact, I happen to have done this for pyflakes myself a
> couple of weeks ago:
>   [pyflakes]
>   recipe = zc.recipe.egg
>   eggs = pyflakes
>   entry-points = pyflakes=pyflakes.scripts.pyflakes:main

That's much shorter than the one I've been using, which makes it seem less
painful.  Due to the way the docutils scripts are set up (without a clear
'main()' method), this is much more painful.

>> - Fix up buildout to also support scripts=[].  (I'm trying that one right
>>  now).
> For a long time, I maintained that this wasn't practical. I do think
> 90% (maybe a 100%) solution of possible.  It will require generating
> scripts that set up the path and then include the source of the
> original scripts.  This is rather ugly but probably doable.  Of
> course, there's also the pain that the script meta data isn't
> available cleanly, as you point out below.

I went from "probably an easy fix" to "ouch, distutils/setuptools makes this
impossible without resorting to ugly hacks" within one day...

>> - How do I access that 'scripts=[....]' which is sitting right there in my
>>  setup() call?  From buildout?  Buildout does something like:
>>       req = pkg_resources.Requirement.parse('my.package')
>>       dist = working_set.find('my.package')
>>  dist ends up as a pkg_resources.Distribution class, which doesn't seem to
>>  have anything with which to do "dist.scripts" or so.  Anyone know the magic
>>  call?  In easy_install there's a "self.distribution.scripts", but after 4
>>  levels of inheritance and a monkey patch I lost track where
>>  self.distribution comes from...
> Yeah, it's too bad that the meta data is lost.  It amazes me how
> willing distutils and setuptools are to toss meta data passed to
> setup.
> You could probably invoke the install command telling it to install
> the scripts in some place and then grab them, but that sounds nasty
> too.

And it is especially nasty as you'd have to do it for every egg in order to
discover whether they *have* a 'scripts=[...]'.  Unless you'd specify it.

What about making the problem explicit and doing something like:

recipe = zc.recipe.egg:distutils
eggs =
scripts =


Reinout van Rees - reinout at vanrees.org - http://reinout.vanrees.org
Software developer at http://www.thehealthagency.com
"Military engineers build missiles. Civil engineers build targets"

More information about the Distutils-SIG mailing list