python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.76k stars 2.27k forks source link

Display why package was installed #1906

Closed shenek closed 3 years ago

shenek commented 4 years ago

Feature Request

As a poetry user I would like to find out why is this dependency used (by which packages it is required).

JS's dependency manager yarn contains a why subcommand which does basically what I mentioned above. see https://yarnpkg.com/lang/en/docs/cli/why/

This feature would be quite helpful in poetry as well. Because it could be quite uncomfortable to figure out why the package was installed using poetry show --tree.

Or perhaps adding a filter to poetry show would be useful.

$ poetry show --tree
black 19.10b0 The uncompromising code formatter.
├── appdirs *
├── attrs >=18.1.0
├── click >=6.5
├── pathspec >=0.6,<1
├── regex *
├── toml >=0.9.4
└── typed-ast >=1.4.0
cachecontrol 0.12.6 httplib2 caching for requests
├── lockfile >=0.9
├── msgpack >=0.5.2
└── requests *
    ├── certifi >=2017.4.17 
    ├── chardet >=3.0.2,<3.1.0 
    ├── idna >=2.5,<2.9 
    └── urllib3 >=1.21.1,<1.25 
cachy 0.3.0 Cachy provides a simple yet effective caching library.
cleo 0.7.6 Cleo allows you to create beautiful and testable command-line interfaces.
└── clikit >=0.4.0,<0.5.0
    ├── enum34 >=1.1,<2.0 
    ├── pastel >=0.1.0,<0.2.0 
    ├── pylev >=1.3,<2.0 
    └── typing >=3.6,<4.0 
clikit 0.4.1 CliKit is a group of utilities to build beautiful and testable command line interfaces.
├── enum34 >=1.1,<2.0
├── pastel >=0.1.0,<0.2.0
├── pylev >=1.3,<2.0
└── typing >=3.6,<4.0
functools32 3.2.3-2 Backport of the functools module from Python 3.2.3 for use on 2.7 and PyPy.
glob2 0.6 Version of the glob module that can capture patterns and supports recursive wildcards
html5lib 1.0.1 HTML parser based on the WHATWG HTML specification
├── six >=1.9
└── webencodings *
httpretty 0.9.7 HTTP client mock for Python
└── six *
importlib-metadata 1.1.3 Read metadata from Python packages
├── configparser >=3.5
├── contextlib2 *
└── zipp >=0.5
    └── more-itertools * 
        └── six >=1.0.0,<2.0.0 
jsonschema 3.2.0 An implementation of JSON Schema validation for Python
├── attrs >=17.4.0
├── functools32 *
├── importlib-metadata *
│   ├── configparser >=3.5 
│   ├── contextlib2 * 
│   └── zipp >=0.5 
│       └── more-itertools * 
│           └── six >=1.0.0,<2.0.0 
├── pyrsistent >=0.14.0
│   └── six * 
├── setuptools *
└── six >=1.11.0
keyring 18.0.1 Store and access your passwords safely.
├── entrypoints *
│   └── configparser >=3.5 
├── pywin32-ctypes <0.1.0 || >0.1.0,<0.1.1 || >0.1.1
└── secretstorage <3
    └── cryptography * 
        ├── cffi >=1.8,<1.11.3 || >1.11.3 
        │   └── pycparser * 
        ├── enum34 * 
        ├── ipaddress * 
        └── six >=1.4.1 
keyring 20.0.1 Store and access your passwords safely.
├── importlib-metadata *
│   ├── configparser >=3.5 
│   ├── contextlib2 * 
│   └── zipp >=0.5 
│       └── more-itertools * 
│           └── six >=1.0.0,<2.0.0 
├── pywin32-ctypes <0.1.0 || >0.1.0,<0.1.1 || >0.1.1
└── secretstorage *
    └── cryptography * 
        ├── cffi >=1.8,<1.11.3 || >1.11.3 
        │   └── pycparser * 
        ├── enum34 * 
        ├── ipaddress * 
        └── six >=1.4.1 
markdown-include 0.5.1 This is an extension to Python-Markdown which provides an "include" function, similar to that found in LaTeX (and also the C pre-processor and Fortran). I originally wrote it for my FORD Fortran auto-documentation generator.
└── markdown *
mkdocs 1.0.4 Project documentation with Markdown.
├── click >=3.3
├── jinja2 >=2.7.1
│   └── markupsafe >=0.23 
├── livereload >=2.5.1
│   ├── six * 
│   └── tornado * 
├── markdown >=2.3.1
├── pyyaml >=3.10
└── tornado >=5.0
pathlib2 2.3.5 Object-oriented filesystem paths
├── scandir *
└── six *
pexpect 4.7.0 Pexpect allows easy control of interactive console applications.
└── ptyprocess >=0.5
pkginfo 1.5.0.1 Query metadatdata from sdists / bdists / installed packages.
pre-commit 1.18.3 A framework for managing and maintaining multi-language pre-commit hooks.
├── aspy.yaml *
│   └── pyyaml * 
├── cfgv >=2.0.0
│   └── six * 
├── identify >=1.0.0
├── importlib-metadata *
│   ├── configparser >=3.5 
│   ├── contextlib2 * 
│   └── zipp >=0.5 
│       └── more-itertools * 
│           └── six >=1.0.0,<2.0.0 
├── importlib-resources *
│   ├── pathlib2 * 
│   │   ├── scandir * 
│   │   └── six * 
│   └── typing * 
├── nodeenv >=0.11.1
├── pyyaml *
├── six *
├── toml *
└── virtualenv >=15.2
pre-commit 1.21.0 A framework for managing and maintaining multi-language pre-commit hooks.
├── aspy.yaml *
│   └── pyyaml * 
├── cfgv >=2.0.0
│   └── six * 
├── futures *
├── identify >=1.0.0
├── importlib-metadata *
│   ├── configparser >=3.5 
│   ├── contextlib2 * 
│   └── zipp >=0.5 
│       └── more-itertools * 
│           └── six >=1.0.0,<2.0.0 
├── importlib-resources *
│   ├── pathlib2 * 
│   │   ├── scandir * 
│   │   └── six * 
│   └── typing * 
├── nodeenv >=0.11.1
├── pyyaml *
├── six *
├── toml *
└── virtualenv >=15.2
pygments 2.3.1 Pygments is a syntax highlighting package written in Python.
pygments 2.5.2 Pygments is a syntax highlighting package written in Python.
pygments-github-lexers 0.0.5 Pygments Github custom lexers.
└── pygments >=2.0.2
pymdown-extensions 6.0 Extension pack for Python Markdown.
└── markdown >=3.0.1
pymdown-extensions 6.2.1 Extension pack for Python Markdown.
├── markdown >=3.0.1
└── pep562 *
pyparsing 2.4.6 Python parsing module
pyrsistent 0.14.11 Persistent/Functional/Immutable data structures
└── six *
pytest 4.6.9 pytest: simple powerful testing with Python
├── atomicwrites >=1.0
├── attrs >=17.4.0
├── colorama *
├── colorama <=0.4.1
├── funcsigs >=1.0
├── importlib-metadata >=0.12
│   ├── configparser >=3.5 
│   ├── contextlib2 * 
│   └── zipp >=0.5 
│       └── more-itertools * 
│           └── six >=1.0.0,<2.0.0 
├── more-itertools >=4.0.0,<6.0.0
│   └── six >=1.0.0,<2.0.0 
├── more-itertools >=4.0.0
│   └── six >=1.0.0,<2.0.0 
├── packaging *
│   ├── pyparsing >=2.0.2 
│   └── six * 
├── pathlib2 >=2.2.0
│   ├── scandir * 
│   └── six * 
├── pluggy >=0.12,<1.0
│   └── importlib-metadata >=0.12 
│       ├── configparser >=3.5 
│       ├── contextlib2 * 
│       └── zipp >=0.5 
│           └── more-itertools * 
│               └── six >=1.0.0,<2.0.0 
├── py >=1.5.0
├── six >=1.10.0
└── wcwidth *
pytest-cov 2.8.1 Pytest plugin for measuring coverage.
├── coverage >=4.4
└── pytest >=3.6
    ├── atomicwrites >=1.0 
    ├── attrs >=17.4.0 
    ├── colorama * 
    ├── colorama <=0.4.1 (circular dependency aborted here)
    ├── funcsigs >=1.0 
    ├── importlib-metadata >=0.12 
    │   ├── configparser >=3.5 
    │   ├── contextlib2 * 
    │   └── zipp >=0.5 
    │       └── more-itertools * 
    │           └── six >=1.0.0,<2.0.0 
    ├── more-itertools >=4.0.0,<6.0.0 (circular dependency aborted here)
    ├── more-itertools >=4.0.0 (circular dependency aborted here)
    ├── packaging * 
    │   ├── pyparsing >=2.0.2 
    │   └── six * (circular dependency aborted here)
    ├── pathlib2 >=2.2.0 
    │   ├── scandir * 
    │   └── six * (circular dependency aborted here)
    ├── pluggy >=0.12,<1.0 
    │   └── importlib-metadata >=0.12 (circular dependency aborted here)
    ├── py >=1.5.0 
    ├── six >=1.10.0 (circular dependency aborted here)
    └── wcwidth * 

vs

poetry show --tree --why typing
cleo 0.7.6 Cleo allows you to create beautiful and testable command-line interfaces.
└── clikit >=0.4.0,<0.5.0
    └── typing >=3.6,<4.0 
clikit 0.4.1 CliKit is a group of utilities to build beautiful and testable command line interfaces.
└── typing >=3.6,<4.0
pre-commit 1.18.3 A framework for managing and maintaining multi-language pre-commit hooks.
├── importlib-resources *
    └── typing * 
pre-commit 1.21.0 A framework for managing and maintaining multi-language pre-commit hooks.
├── importlib-resources *
    └── typing * 
tomlkit 0.5.8 Style preserving TOML library
└── typing >=3.6,<4.0
typing 3.7.4.1 Type Hints for Python
snejus commented 4 years ago

Tried to tackle this a different way in #2351

@shenek What would you think of providing these details in the poetry show <package> command output?

image

lyz-code commented 2 years ago

Is this feature released? I don't see the dependencies nor the required by when I use poetry show X

snejus commented 2 years ago

I've just made this gist public: https://gist.github.com/snejus/85b47dca884a5aca2646dfbde79e9c92

While you're waiting for this functionality to be released, feel free to use it: it's a poetry.lock parser written in shell: deps <package> should give you what you need, in several milliseconds.

rwijtvliet commented 1 year ago

I landed here after trying to find out, which dependency ultimately caused my package to be uninstallable (see here) Is there a way to use this script without having an actual poetry.lock file yet? Maybe from the poetry install --dry-run -vvv output?

github-actions[bot] commented 8 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.