question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a more detailed --tree-json-full output option

See original GitHub issue

What you were trying to do (and why)

Output the dependency tree in JSON format.

What happened (including command output)

Compare

$ pipgrip --tree-json pipgrip
{"pipgrip": {"anytree": {"six>=1.9.0": {}}, "click": {}, "enum34": {}, "packaging>=17": {"pyparsing>=2.0.2": {}, "six": {}}, "pip>=7.1.0": {}, "pkginfo>=1.4.2": {}, "setuptools>=38.3": {}, "typing": {}, "wheel": {}}}

to

$ pipgrip --tree-ascii pipgrip
pipgrip (0.5.0)
|-- anytree (2.8.0)
|   +-- six>=1.9.0 (1.15.0)
|-- click (7.1.2)
|-- enum34 (1.1.10)
|-- packaging>=17 (20.4)
|   |-- pyparsing>=2.0.2 (2.4.7)
|   +-- six (1.15.0)
|-- pip>=7.1.0 (20.1.1)
|-- pkginfo>=1.4.2 (1.5.0.1)
|-- setuptools>=38.3 (44.1.1)
|-- typing (3.7.4.3)
+-- wheel (0.34.2)

to see that e.g. the wheel version “0.34.2” is missing from JSON output while it’s present in ASCII output.

What you expected to happen

Each JSON node probably should have two properties, version and dependencies, where version is the use version of the package itself, and dependencies a list of its dependencies (where each dependency is of the same type as the parent node).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ddelangecommented, Aug 4, 2020

@sschuberth nit incorporated! the example above can still be obtained by additionally passing --sort.

[{'name': 'keras',
  'extras_name': 'keras',
  'version': '2.2.2',
  'pip_string': 'keras==2.2.2',
  'dependencies': [{'name': 'h5py',
                    'extras_name': 'h5py',
                    'version': '2.10.0',
                    'pip_string': 'h5py',
                    'dependencies': [{'name': 'numpy',
                                      'extras_name': 'numpy',
                                      'version': '1.19.1',
                                      'pip_string': 'numpy>=1.7'},
                                     {'name': 'six',
                                      'extras_name': 'six',
                                      'version': '1.15.0',
                                      'pip_string': 'six'}]},
                   {'name': 'keras-applications',
                    'extras_name': 'keras-applications',
                    'version': '1.0.4',
                    'pip_string': 'keras-applications==1.0.4',
                    'dependencies': [{'name': 'h5py',
                                      'extras_name': 'h5py',
                                      'version': '2.10.0',
                                      'pip_string': 'h5py',
                                      'dependencies': [{'name': 'numpy',
                                                        'extras_name': 'numpy',
                                                        'version': '1.19.1',
                                                        'pip_string': 'numpy>=1.7'},
                                                       {'name': 'six',
                                                        'extras_name': 'six',
                                                        'version': '1.15.0',
                                                        'pip_string': 'six'}]},
                                     {'name': 'keras',
                                      'extras_name': 'keras',
                                      'version': '2.2.2',
                                      'pip_string': 'keras>=2.1.6',
                                      'cyclic': True},
                                     {'name': 'numpy',
                                      'extras_name': 'numpy',
                                      'version': '1.19.1',
                                      'pip_string': 'numpy>=1.9.1'}]},
                   {'name': 'keras-preprocessing',
                    'extras_name': 'keras-preprocessing',
                    'version': '1.0.2',
                    'pip_string': 'keras-preprocessing==1.0.2',
                    'dependencies': [{'name': 'keras',
                                      'extras_name': 'keras',
                                      'version': '2.2.2',
                                      'pip_string': 'keras>=2.1.6',
                                      'cyclic': True},
                                     {'name': 'numpy',
                                      'extras_name': 'numpy',
                                      'version': '1.19.1',
                                      'pip_string': 'numpy>=1.9.1'},
                                     {'name': 'scipy',
                                      'extras_name': 'scipy',
                                      'version': '1.5.2',
                                      'pip_string': 'scipy>=0.14',
                                      'dependencies': [{'name': 'numpy',
                                                        'extras_name': 'numpy',
                                                        'version': '1.19.1',
                                                        'pip_string': 'numpy>=1.14.5'}]},
                                     {'name': 'six',
                                      'extras_name': 'six',
                                      'version': '1.15.0',
                                      'pip_string': 'six>=1.9.0'}]},
                   {'name': 'numpy',
                    'extras_name': 'numpy',
                    'version': '1.19.1',
                    'pip_string': 'numpy>=1.9.1'},
                   {'name': 'pyyaml',
                    'extras_name': 'pyyaml',
                    'version': '5.3.1',
                    'pip_string': 'pyyaml'},
                   {'name': 'scipy',
                    'extras_name': 'scipy',
                    'version': '1.5.2',
                    'pip_string': 'scipy>=0.14',
                    'dependencies': [{'name': 'numpy',
                                      'extras_name': 'numpy',
                                      'version': '1.19.1',
                                      'pip_string': 'numpy>=1.14.5'}]},
                   {'name': 'six',
                    'extras_name': 'six',
                    'version': '1.15.0',
                    'pip_string': 'six>=1.9.0'}]}]
1reaction
sschuberthcommented, Jul 30, 2020

that better?

Much better 😃

what would you suggest in the Keras case in the README? cyclic attr will be there, so just empty array under the dependencies key just like for depencency-less packages?

Good question. Yes, I think setting a cyclic attribute to true and therefore omitting the dependencies attributes (to distinguish from packages without dependencies) is a good approach.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"ls dependencies" should have an option to maintain the tree ...
Currently, "ls dependencies" just outputs a flat list of package ... Add a more detailed --tree-json-full output option ddelange/pipgrip#34.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found