While this method is not being used in the script, it's been added for
completeness and to ensure that the APIs of all the classes involved
are clean.
Also, the 'DistPackage.as_required_by' method has been renamed to
'DistPackage.as_parent_of' for clarity.
Tests have been added and modified.
- 'Tree' was used for class representing a direct acyclic
graph (DAG). It has now been appropriately renamed to 'PackageDAG'
- The 'ReverseTree' has been renamed to 'ReversedPackageDAG'
- The optional arg 'base' in the constructor and the instance
attribute havee been removed as they are nowhere being used
- Local variables are renamed, comments are modified and tests are
updated to reflect the above changes
The Tree class is completely agnostic of any notion of a dependency
tree. So it's filter and reverse methods purely work on the given
datastructure which is a map. So the combination of '--reverse' and
'--packages' options require the reverse method to be called before
filter. If done the other way, when reverse is called, it will have
only partial tree resulting in incorrect behaviour in the context of
this script.
Added documentation on the tree class and it's methods accordingly.
The earlier approach for integration tests was unreliable as it used
pickled objects from virtualenvs, which didn't work with all the pip
internal code and would often require tests to be fixed.
In this new approach, a combination of bash and python scripts drive
the tests. Test virtualenvs are setup on demand with support for
varying python and pip versions. As a result, the test
environment (python 3.6) can be completely different from the test
environment ie. the env in which pipdeptree is tested.
TODO: Get the new approach working with travis and remove old
integration tests.
Earlier, in the Tree.filter method, we were checking for conflicts in
'show_only' and 'exclude' sets before normalizing all values to lower
case as a result of which it would miss values that were in both the
sets but in different cases.
This is now fixed by checking for conflicts after normalizing all the
values in both sets to lowercase first.
So that a new 'test_pipdeptree.py' can be added for unit tests (with
mocking etc.).
Integration test suite will still be run during 'make test' but the
state of the test suite is pretty bad at present. In future, we might
replace it with a complete approach for easy maintenance.
The dependencies in test setup were old and in spite of the versions
being pinned, the test results were not consistent locally and
travis.
Note: This is an attempted fix (to be verified only after tests are
run on travis)
* 'pip.get_installed_distributions' doesn't include some packages such
as 'pip', 'setuptools' etc. so the installed versions for these is not
available. This change tries to guess the installed version by
importing the module and checking if the version is defined in
'__version__' variable.
* Another related change is that the 'required' and 'installed' versions
will be shown for all intermediate packages. When 'required' is not
specified, it will show 'None' and when 'installed' is not available,
it will show '?'. This is to keep the output consistent with the confusing deps
output.
* Fix indentation in output.
Kind of fixes#46.
This is done by:
* Forcing tox to install pip version >=8.0.2 inside the virtualenv
* Commenting out a failing assertion. The reason for this failure is
that the pkgs loaded from the pickled file lose a bit of information
w.r.t editable packages. This will be fixed properly in soon.
The primary reason behind refactoring the code is to be able to make it
straightforward to implement the --reverse mode (ie. instead of showing
package and their sub-deps, it will show the sub-deps and the packages
that need them).
As a part of this change, wrapper classes have been added for
Distribution and Requirements instances that pip returns. These wrapper
classes have handle the rendering of the pkg as a root (top level) and a
branch (non-top level) accordingly. As a result the same function
`render_tree` can be used for --reverse mode.
This change doesn't include the --reverse mode implementation. It will
be added in the subsequent commit.
This commit decouples the test virtualenv creation from tox and simplify
it for running both locally and on travis-ci. Creation of the test
virtualenvs now happen via Makefile target 'test-env' which will create
2 virtualenvs in the dir tests/virtualenvs and also dump their
respective package data in .pickle files that will be used by the tests.
Also, builds on travis now no longer depend on tox but reuses some of
the Makefile targets for test virtualenv creation/cleanup.
This makes the output of pipdeptree (with freeze flag) pip friendly
ie. the output can be saved in a requirements.txt file. At the same time
it's human readable due to indentations for sub-dependencies.
There is however one gotcha! In case pip finds a dependency multiple
times in the requirements.txt file, it fails. So the user will need to
take care about this when dumping the output in requirements.txt.
Fixes#31.
The pickle files for test virtualenv data were created using an older
version of pip. As tox started using the newer version of pip, these
files were obsolete and it lead to failure of tests run via tox. This is
now fixed by regenerating the pickle files for pip ver. 6.0.8
c70525bb84 broke Python 2.6 compatibility
by using a dict comprehension, which is a Python 2.7 feature. I replaced
it with calling dict with a generator expression, which looks almost as
good and it works in Python 2.6.