naiquevin/pipdeptree — pull request #10 by msabramo (2014-06-13 18:41:14+00:00)
Title: Fix infinite recursion for circular dependency

Infinite recursion occurs if package A depends on package B and package B depends on package A.

For example:

I happen to have two internal packages on our internal package index that depend on each other (circular dependency).

Running `pipdeptree` in this virtualenv results in:

```python
File "/opt/ci/build/jobs/ProfileSvc/workspace/TOXENV/py27/.tox/py27/local/lib/python2.7/site-packages/pipdeptree.py", line 156, in aux
for d in pkg_deps]))
File "/opt/ci/build/jobs/ProfileSvc/workspace/TOXENV/py27/.tox/py27/local/lib/python2.7/site-packages/pipdeptree.py", line 156, in aux
for d in pkg_deps]))
File "/opt/ci/build/jobs/ProfileSvc/workspace/TOXENV/py27/.tox/py27/local/lib/python2.7/site-packages/pipdeptree.py", line 156, in aux
for d in pkg_deps]))
File "/opt/ci/build/jobs/ProfileSvc/workspace/TOXENV/py27/.tox/py27/local/lib/python2.7/site-packages/pipdeptree.py", line 156, in aux
for d in pkg_deps]))
File "/opt/ci/build/jobs/ProfileSvc/workspace/TOXENV/py27/.tox/py27/local/lib/python2.7/site-packages/pipdeptree.py", line 146, in aux
name = pkg.project_name if dist is None else non_top_pkg_str(pkg, dist)
File "/opt/ci/build/jobs/ProfileSvc/workspace/TOXENV/py27/.tox/py27/local/lib/python2.7/site-packages/pipdeptree.py", line 57, in non_top_pkg_name
vers.append(('installed', pkg.version))
RuntimeError: maximum recursion depth exceeded
```

The infinite recursion is occurring here:

https://github.com/naiquevin/pipdeptree/blob/master/pipdeptree.py#L155

To fix this, I introduce a `pkgs_processed` set, which keeps track of the packages that we've already determined dependencies for so we don't keep redoing this ad-infinitum.