[Distutils] setuptools: bug in run_script

Ian Bicking ianb at colorstudy.com
Sun Sep 25 20:36:07 CEST 2005


Ian Bicking wrote:
> Ian Bicking wrote:
> 
>>Ben Bangert encountered a problem where
>>pkg_resources.WorkingSet.run_script didn't work; from line 407:
>>
>>        self.require(requires)[0].run_script(script_name, ns)
>>
>>If all the packages are already loaded for some reason, then
>>self.require() returns [].
> 
> 
> Looking at it, I think self.require(requires)[0] would only work if the
> package was installed multi-version.  When all the packages are
> activated by default, of course require() should return nothing.

Nevermind that.  The problem is the generated scripts:

#!/usr/local/bin/python
# EASY-INSTALL-SCRIPT: 'PasteScript==0.1dev-r3260','paster'
__requires__ = 'PasteScript==0.1dev-r3260'
import pkg_resources
pkg_resources.run_script('PasteScript==0.1dev-r3260', 'paster')


The __requires__ variable causes pkg_resources to require that package.
 So later when .run_script() is called, the package has already been
loaded, and .requires() returns [], and it fails.  I actually don't know
what situation it would work in.  But I also realize setuptools has had
a hard time updating my scripts, so I didn't notice it myself.

While we're at it, the explicit version in these scripts causes me no
end of problems.  Since scripts are generally not installed in a
multi-version manner (only one script by a particular name can be access
on $PATH), it seems they should have versionless requires, thus getting
the newest version.  Or, at least, they should load the "active"
version, whatever that is (typically the newest version).



More information about the Distutils-SIG mailing list