[Distutils] Unexpected VersionConflict

PJ Eby pje at telecommunity.com
Sat Aug 10 17:52:27 CEST 2013


On Fri, Aug 9, 2013 at 5:41 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On 10 August 2013 04:06, PJ Eby <pje at telecommunity.com> wrote:
>> Probably a better way would be to change the version resolution
>> algorithm to be less "greedy", and simply rule out unacceptable
>> versions as the process goes along, then picking the most recent
>> versions left when everything necessary has been eliminated.
>> (Ideally, such an algorithm would still track which distributions had
>> the conflicting requirements, though.)
>
> The part I find most surprising is the fact that pkg_resources ignores
> sys.path order entirely when choosing between multiple acceptable
> versions.

Technically, it doesn't ignore it: if a distribution is listed in
sys.path, it takes precedence over any distribution listed later, or
that has to be found *in* a directory on sys.path, and will in fact
cause a VersionConflict if you ask for a version spec that it doesn't
match.

However, where the distributions aren't listed in sys.path, but merely
*found in a directory on sys.path*, then sys.path has no bearing.  It
would make things a lot more complicated, and not just in an
"implementation is hard to explain" kind of way.

(In principle, you could write an Environment subclass that had a
different precedence, but I'm not sure what benefit you would gain
from the added complexity.  The core version resolution algorithm
wouldn't be affected, though, since it delegates the "find me
something I haven't already got on sys.path" operation to an
Environment instance's best_match() method.)


More information about the Distutils-SIG mailing list