-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a more detailed --tree-json-full output option #34
Comments
Hey @sschuberth, I thought about data structure as well, and decided to avoid structures where each node has multiple attributes, as it makes recursing unnecessarily painful for most use-cases. Also, combining the stated version ranges in the tree (a static statement) with exact version pins (dynamic, dependent on runtime) in the dependency tree for a package feels wrong. However, for the exact version pins, I added Anytree supports dict export, with all attributes of the Node nested inside like you suggested. That would be something like: from anytree.exporter import DictExporter
from collections import OrderedDict
exporter = DictExporter(dictcls=OrderedDict, attriter=sorted)
tree_dict_full = exporter.export(tree_root)["__root__"]["children"] and then for the new flag something like https://github.com/ddelange/pipgrip/blob/0.5.0/src/pipgrip/cli.py#L380-L383: elif tree_json_full:
output = dumps(tree_dict_full, sort_keys=sort) The Default Node attribute is the package name (e.g.
Check out https://github.com/ddelange/pipgrip/blob/0.5.0/src/pipgrip/cli.py#L119 and https://github.com/ddelange/pipgrip/blob/0.5.0/src/pipgrip/cli.py#L135 to compare to the current outputs of A PR is very welcome! |
Thanks for pointing out the new However, in general I believe the new plethora of tree-related options to be confusing, and probably unnecessary. For example, I regard Similarly, I still believe Just FYI, in the context of the OSS Review Toolkit project I requested something similar for Haskell's Stack, and the JSON format looks like this. |
Interesting take on it, probably merged too soon ;) Thanks for the wisdom, yes I can relate to that, also probably json wouldn't be used by anything that can't subsequently cherry pick the relevant info for them. I'm quite swamped currently, but I'll leave this open and once these changes are sorted, do either a 1.0.0 listing breaking changes to So without breaking changes, that would be:
Proposed addition: $ pipgrip --json --tree 'aiobotocore[awscli,boto3]~=0.1' 'urllib3<1.25.10'
[
{
"aiobotocore[awscli,boto3]~=0.1rc1": {
"name": "aiobotocore",
"extras_name": "aiobotocore[awscli,boto3]",
"pip_string": "aiobotocore[awscli,boto3]~=0.1rc1",
"version": "0.12.0",
"extras": ["awscli", "boto3"],
"dependencies": [...]
}
},
{"urllib3<1.25.10": {...}}
] that better? |
also, @sschuberth, 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? |
Much better 😃
Good question. Yes, I think setting a |
This is (prettyprinted) output for
|
That basically looks good to me! Many just one nit, personally I'd prefer this order of attributes: |
@sschuberth nit incorporated! the example above can still be obtained by additionally passing
|
Thanks, that's looking good, although I have to admit I see no value in sorting the JSON attributes. |
yes, generally JSON is order agnostic but the addition was small so I went for it 😄 thanks for all the feedback! |
* ✨ Add detailed json tree (--json --tree) Closes #34 * ♻️ Add default sorting to --tree --json, yet obey --sort
What you were trying to do (and why)
Output the dependency tree in JSON format.
What happened (including command output)
Compare
to
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
anddependencies
, whereversion
is the use version of the package itself, anddependencies
a list of its dependencies (where each dependency is of the same type as the parent node).The text was updated successfully, but these errors were encountered: