[Distutils] setuptools: Bug in requirement loading

Phillip J. Eby pje at telecommunity.com
Wed Nov 2 20:38:09 CET 2005


At 12:17 PM 11/2/2005 -0600, Ian Bicking wrote:
>(got a little truncated, but ignoring that.)  If "dist is None", i.e.,
>no egg for the requirement is yet loaded, the egg is loaded with
>"self.by_key.get(req.key)".  req.key doesn't have any version
>information, it's just the package name.

Eep.  That is indeed a bug.


>If I change the second "if dist is None" to "if dist is None or dist not
>in req" then at least I get a version conflict.  But I thought
>setuptools 0.6a7 was able to load an egg besides the default version.

It is able to, as long as the egg is one required by the __main__ 
program.  There is special startup logic that checks for VersionConflict on 
application start, and then fudges things to work around it.  It is not, 
however, an all-purpose facility to allow loading non-default 
versions.  That would involve more complex refactoring and isn't something 
I'll attempt in a minor release.  (Indeed, I suspect that supporting it 
properly would require a rethink of the entire WorkingSet API and 
implementation, and perhaps a fair bit of hooking into Python's import 
machinery besides.)


>Actually, I'm now confused how anything but the default version can be
>loaded.

Yeah, that's the bug all right.


>I'm having a hard time figuring out how I didn't notice this before.

Me too!  I'm guessing this was introduced when I made some changes to 
resolve() to avoid unnecessary directory scans.  resolve() was previously 
not even looking to see if the working set already contained a matching 
distribution.

Anyway, the simplest fix should be to change the 'elif dist not in req' to 
'if dist not in req'.



More information about the Distutils-SIG mailing list