[Distutils] (How) do setuptools/distribute/pip handle circular dependencies?

Carl Meyer carl at oddbird.net
Sat Nov 10 00:22:17 CET 2012


Hi Vinay,

On 11/09/2012 03:56 PM, Vinay Sajip wrote:
> Vinay Sajip <vinay_sajip <at> yahoo.co.uk> writes:
> 
>> So, according to the declarations, each package depends on the other. Can
>> setuptools / distribute deal with this sort of situation? If so, how does
>> that work?
> 
> My question also applies to pip, of course. I know it uses setuptools /
> distribute under the covers, but I'm not sure if it has additional / different
> dependency resolution logic.

Pip has its own dependency resolution logic, it does not rely on
setuptools for that.

As Alex says, the "circular" case you mention is not hard; all it
requires is that you know what you're already installing and check new
requirements you come across against that list to see if they are
already satisfied. In pip this happens here:
https://github.com/pypa/pip/blob/develop/pip/req.py#L1091

More generally, I wouldn't really recommend pip's dependency resolution
logic as a model for new Python code in this area. There are some not
uncommon cases that it handles poorly; see
https://github.com/pypa/pip/issues/174 and
http://bugs.python.org/issue8927. (To be fair to pip, these cases aren't
trivial when you have to download and unpack an sdist before you can
find out anything about its dependencies, but I'd hope that with the new
metadata PEPs Python packaging code could get a bit smarter in this area.)

Carl


More information about the Distutils-SIG mailing list