Commit Graph

228 Commits

Author SHA1 Message Date
Vineet Naik e66b95f494 Mark old code as deprecated
It will be removed when the test cases in 'test_integration.py' will
be completely covered in 'test_pipdeptree.py' using Mocks.
2020-04-14 19:15:52 +05:30
Vineet Naik c26603865d Implement 'ReversedPackageDAG.reverse' method
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.
2020-04-14 19:15:52 +05:30
Vineet Naik f970732c3b Extend the graphviz output format to support reverse flag
Earlier the graphviz output format didn't work if called with the
reverse flag. This is now fixed.

This commit also handles the case of more than one packages having
conflicting versions of the same dependency. In such cases, the edges
between dependency and the parent pkg will be labelled as per the
required version_spec of the respective dependency.
2020-04-14 19:15:52 +05:30
Vineet Naik 8766baa89a Refactored code to correct nomenclature and remove redundant code
- '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
2020-04-14 19:14:49 +05:30
Vineet Naik 917c880eeb Fix the behaviour of --reverse and --packages options together
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.
2020-04-12 13:27:59 +05:30
Vineet Naik a3033fc4f6 Run only unit tests on travis
TODO: In subsequent commits, new style integration tests will also be
onboarded on travis.
2020-04-12 12:13:14 +05:30
Vineet Naik ec1ee96963 Write new style integration tests
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.
2020-04-12 11:40:33 +05:30
Vineet Naik e7da6b3b50 Fix a bug that caused frozen output to be incorrectly rendered 2020-04-11 17:38:47 +05:30
Vineet Naik 67bba61be9 Improve graphviz output to differentiate missing dependencies
The missing dependencies will now be displayed with 'dashed' nodes and
edges.

This commit also fixes the problem of duplicate nodes being displayed
in the graph, which would happen when the 'project_name' attribute of
'ReqPackage' and the corresponding 'DistPackage' obj different. Now we
are using the 'key' attribute which is guaranteed to be the same for
both objects.
2019-11-09 13:53:19 +05:30
Vineet Naik 9e2bec8b27 Prevent missing dependencies from crashing the script
This was a regression introduced in the recent refactoring changes.
2019-11-09 13:51:01 +05:30
Vineet Naik 7c43fe85db Refactor code to render already filtered and/or reversed tree
- Replaced the function 'render_tree' with 'render_text' which prints
  text representation of an alredy filtered and/or reversed tree to
  stdout

- Modify main code to print warnings for conflicting and/or cyclic
  dependencies only if user has not selected an output type other than
  default (text) - for eg. json, json_tree etc.
2019-10-27 17:50:16 +05:30
Vineet Naik 1cb347c35b Check for conflicts in 'show_only' and 'exclude' after handling case
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.
2019-10-27 16:07:52 +05:30
Vineet Naik 29f78ca989 Inherit the Tree class from Mapping (abstract base class)
This allows us to use tree directly in existing functions that expect
a dict as input.
2019-10-27 15:53:46 +05:30
Vineet Naik 3b6fad3111 Remove an unnecessary if statement 2019-09-20 09:14:17 +05:30
Vineet Naik bb5b354319 Merge remote-tracking branch 'origin/master' into v2beta
* origin/master:
  Fix missing 'setuptools' requirement
2019-07-27 11:25:35 +05:30
Vineet Naik 4f06f6d866 Merge branch 'sinoroc-fix-missing-setuptools'
* sinoroc-fix-missing-setuptools:
  Fix missing 'setuptools' requirement
2019-07-27 11:21:39 +05:30
sinoroc f76ef35ee8 Fix missing 'setuptools' requirement
The package 'pkg_resources' is part of the 'setuptools' project. The
project 'pip' (in its current version) vendors setuptools.

Since 'pipdeptree' currently uses pip's private internal API already,
we might as well use pip's vendored pkg_resources. This, of course,
might break if pip's internals change in a later version.

GitHub: naiquevin/pipdeptree#119
2019-07-17 20:32:55 +02:00
Vineet Naik 906e05147b Define Tree and ReverseTree classes representing dependency tree 2019-07-17 00:33:33 +05:30
Vineet Naik 4b74f7b4fe Rename 'test_pipdeptree.py' to 'test_integration.py'
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.
2019-07-13 13:28:22 +05:30
Vineet Naik 5622312f78 Bump version to 0.13.2 2019-01-23 18:04:44 +05:30
Vineet Naik 41e838c4b1 Fix FrozenRequirement.to_dist to support pip 19.0
In pip 19.0 the function signature of FrozenRequirement.to_dist has
been changed. The last argument 'depedency_links' is now removed as
depedency support has been removed in pip 19.0.

Fixes #113.

Pull request removing dependency links support:
https://github.com/pypa/pip/pull/6060

Commit removing the 'dependency_links' argument:
46ffb13f13
2019-01-23 17:54:44 +05:30
Vineet Naik 51af7dd8d2 Fix pip._internal import in tests
Missed fixing the import of 'get_installed_distributions' in tests in
the earlier commit.

Also fixed indentation
2018-10-08 19:29:51 +05:30
Vineet Naik 086039ebab Bump version to 0.13.1 2018-10-08 19:07:23 +05:30
Vineet Naik ba67474e41 Fix import to work with pip version 18.1
It also works with previous versions of pip.

The alias to 'get_installed_distributions' in 'pip._internal' module
was removed in pip commit db72d427c5538a29df182bf7a724c304ac323cf6

Ref:
db72d427c5

Fixes #105
2018-10-08 19:06:31 +05:30
Vineet Naik a7df38238e Bump version to 0.13.0 2018-07-01 19:54:17 +05:30
Vineet Naik d5c3ce7bf5 Update test setup dependencies
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)
2018-07-01 19:17:16 +05:30
Vineet Naik ee5eaf86ed
Merge pull request #97 from mail6543210/fix-78
Sorted version spec
2018-05-15 22:20:02 +05:30
Vineet Naik ba5d5e2fa0
Merge pull request #94 from ciarancourtney/master
#69 Add '--exclude' arg to exclude CSV list of packages and children from output
2018-05-15 22:19:16 +05:30
ciarancourtney d4bc9f487c tests: render_tree() expects exclude arg to be set, not list 2018-05-01 19:36:47 +01:00
ciarancourtney 1a15137510 restore arg-less main(), abstart args to _get_args() and monkeypatch in tests 2018-05-01 19:29:13 +01:00
ciarancourtney 1e075432e4 exclude should default to None like show_only 2018-05-01 19:27:59 +01:00
ciarancourtney 1bcd65dc3a Using --packages and --exclude together is fine as long as they are distinct
* pass args into main() to make testing easier
2018-04-22 11:39:22 +01:00
ciarancourtney eb886d9a2f Add test for --exclude and --reverse 2018-04-15 21:47:20 +01:00
ciarancourtney 6910831af2 Remove wheel from tests (auto-updates self) 2018-04-15 21:47:20 +01:00
ciarancourtney d22cffb19f upgrade gnureadline 6.3.3 > 6.3.8 to avoid install issues (has wheels for py27 > py36) 2018-04-15 21:47:20 +01:00
ciarancourtney 9f0e439226 [closes #69] Add '--exclude' arg to exclude CSV list of packages and children from output 2018-04-15 21:47:20 +01:00
Vineet Naik 2e9e511916 Release version 0.12.1 2018-04-15 12:05:36 +05:30
Vineet Naik e0cedb8ed0 Comment out flaky tests 2018-04-15 11:58:51 +05:30
Vineet Naik f32114130a Fix tests for render_json_tree
For easier debugging in case of failure
2018-04-15 10:50:40 +05:30
Vineet Naik 426a7c457d Add .pytest_cache dir to gitignore 2018-04-15 10:38:58 +05:30
Vineet Naik abb8a96441 Fix imports for pip version 10.0.0 and -f option
This was fixed to work with pip 10.0.0 in an earlier commit but import
import of 'FrozenRequirement' was still broken. It is only invoked
when running with '-f' option and is fixed in this commit.
2018-04-15 10:36:22 +05:30
Vineet Naik 3520b6749d Fix tests for render_json_tree
Packages such as 'pip', 'pipdeptree', 'setuptools' and 'wheel' are
implicitly installed during test setup and hence ignored when
comparing output.
2018-04-15 10:35:00 +05:30
Vineet Naik d79d4b7420 Pin dependencies of tox, pytest and pluggy
Pluggy 0.6.0 is compatible with both tox 3.0.0 and pytest 3.5.0, hence
explicitly specifying these. Otherwise test setup may unpredictably
break.
2018-04-15 10:33:34 +05:30
Vineet Naik 594da8056d Bump version to 0.12.0 2018-04-15 08:24:36 +05:30
mail6543210 ae3a5e169c Sorted version spec 2018-04-10 22:36:16 +08:00
Vineet Naik 6fcf1d70c9
Merge pull request #96 from emddudley/master
Fixed pip import to accomodate refactor in pip 10.0
2018-04-08 12:25:12 +05:30
M. Dudley 9c6031cdc7 Fixed pip import to accomodate refactor in pip 10.0 2018-04-03 10:29:09 -04:00
Vineet Naik 2dea43a3c4 Release version 0.11.0
* Bumped version
* Added changelog
* Updated README file
2018-02-24 11:58:17 +05:30
Vineet Naik fd70921804
Merge pull request #91 from haikoschol/json-tree
Add command line flag `--json-tree` (#86)
2018-02-24 11:37:19 +05:30
Haiko Schol 932ed4b5c3 Update psycopg2 version in one of the test environments
psycopg2 2.5.2 fails to install with PostgreSQL 10+.
2018-02-21 19:02:42 -06:00