-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
Doesn't work with extras_require and tests_require #107
Comments
Hi, I didn't get what you exactly mean by "handle" extra/test dependencies. It would be helpful if you could please add just the line diff between expected and actual output. |
The example shows 20 packages. But 18 of them were installed using pip install -e pywikibot[extras] (or pip install -r requirements.txt) (as extra dependencies of pywikibot) and therefore should be marked as dependencies of pywikibot. They are not. They are marked as explicitly installed packages, which they are not. extras_require and test_require are parts of pip specification, both containing dependencies similar to install_require (which contains the dependencies pipdeptree can work with). This issue is a huge limitation as it does not mark dependencies as dependencies and therefore the tree is not correct. |
Ok, got it now. Thanks for the clarification. pipdeptree uses pip's internals to build the graph. Will have to check if pip exposes additional metadata for extras and test dependencies. Only in that case, it can be supported. |
The from pip._internal.utils.misc import get_installed_distributions
help(get_installed_distributions()[13].requires) Each get_installed_distributions()[13].requires()[2].extras It should be possible to use these to store extras information in the tree somehow. For a smaller test case, installing jira gives the following deptree:
Jira actually depends on |
@AWhetter: This is helpful. Thanks! |
@naiquevin Note that since Python 3.8 you can use
@AWhetter |
Is there an alternative that supports this? |
We can use graphviz’ digraph structs {
node [shape=record]
edge [color="#00000077"]
api [label="{ <base> api | { <test> test | <dev> dev | <testing> testing }}"]
server [label="{ <base> server | { <test> test | <dev> dev | <testing> testing }}"]
utils [label="{ <base> utils | { <test> test | <dev> dev }}"]
pytest [label="<base> pytest"]
api:base -> utils:base
server:base -> utils:base
api:testing -> server:testing
utils:test -> pytest:base
api:test -> pytest:base
server:test -> pytest:base
server:testing -> pytest:base
} Here, each packages’ pipdeptree just ignores that $ pipdeptree -p api[testing] --graph-output=dot | xdot /dev/stdin |
There's an open PR for supporting extra requirements - #138 , which basically builds on top of another PR #132. I haven't been able to spend much time on it after the initial work. IIRC, most changes are done but I don't want to haste the release of it as there's a chance of introducing regressions. Let me rebase that branch with latest master over this weekend so that it's at least usable on experimental basis. |
I just ran into this issue today. My use case is actually in a python script, so i'll take a look at EDIT: Nevermind, I'm still on 3.7 👎 so I can't. |
You can use |
Do you plan to fix this issue? |
I doubt if I can get to this anytime soon due to other commitments. The
code is there on another branch but master branch has deviated now. And the
changes are not trivial so it will take some time and effort to rebase.
On Tue, 1 Mar 2022 at 6:41 AM, ralphie0112358 ***@***.***> wrote:
Do you plan to fix this issue?
—
Reply to this email directly, view it on GitHub
<#107 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEOZHHCB5PSRDAHX5IBYXDU5QML3ANCNFSM4FZREJDA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
~ Vineet
|
A PR trying to address this would be welcome! tests_require is not supported but extra should be. |
Workaround of tox-dev/pipdeptree#107
There's similar issue with format-nongpl = [
"fqdn",
"idna",
"isoduration",
"jsonpointer>1.13",
"rfc3339-validator",
"rfc3986-validator>0.1.0",
"uri_template",
"webcolors>=1.11",
] so you have a lot of extra top-level dependencies in the output: $ pipdeptree -u -d 0
fqdn==1.5.1
isoduration==20.11.0
jsonpointer==2.4
jupyterlab==4.0.2
uri-template==1.3.0
webcolors==1.13 Note that only jupyterlab here is the only real top-level dependency. |
I have been trying to ponder a way to approach this, but after looking around I don't think it is possible yet to implement this? What I would expect when I output a dependency tree that contains extras is to only provide output of extras that have been installed. However, there doesn't yet seem to be a way to determine if an extra has been installed in the environment. There has been on and off discussions about this in pypa/packaging-problems#215 and in the pages linked in the issue. One naive approach I came up with was "if all the dependencies for an extra are present in the environment, then the extra must be installed". There are problems with this, however. This discussion provides a good example of what could go wrong. I'll continue to look for new updates about this, but I'm open to other ideas! |
I mean, it would already be helpful to have just explicitly requested extras, so for starters, the answer to the question posed in the thread you linked would be “no”: pip install uvicorn
pip install websockets # Is uvicorn[websockets] considered installed? We could add a |
Thanks for your insight! Handling explicitly-requested extras is something I believe we can do. I'll work on this during my free time. |
I was a bit surprised, that pipdeptree can not handle either extra, or test dependencies. See for example:
Expected:
Current:
The text was updated successfully, but these errors were encountered: