Show why package is required#2086
Conversation
|
This is dope |
|
Excited! |
|
Thanks for your contribution! Overall, I am on board with the idea :-) However, I think, as it is, the output is not clear enough. For the "non-tree" display, we could output complete sentences that describe why the package is required. For the "tree" display, we could highlight the required package in the tree for better visibility. Here is a proof of concept: |
|
This looks awesome, and I would love to have it! Re: @sdispater's suggestion, I can take or leave the phrasing or the highlighting; I think the meaning of the output is already quite clear given the context. However, I'd like to note that (1) I like that it specifies the root project as a direct dependent when applicable and (2) specified version ranges are more useful than resolved versions in many cases, but showing both seems good too. Why does |
* extends show command with `--why` flag * with `poetry show --why <package>` it displays a list of packages which need <package> to be installed (including indirect deps) * with `poetry show --tree --why <package>` it displays a tree of packages which need <package> to be installed (including indirect deps)
|
Hi, @sdispater @seansfkelley Cheers |
|
That makes sense; the formatting changes can be a different change. I didn't know |
|
Maintainers, could this be merged and released please? |
|
If anyone's looking for a solution, I have a couple of helpers that parse the It shows the output more or less instantly ./deps pytest 0.07s user 0.02s system 196% cpu 0.045 total
poetry show pytest 2.35s user 0.10s system 99% cpu 2.456 totalFeel free to use it! Best to _RED='\\\\e[1;31m&\\\\e[0m'
_GREEN='\\\\e[1;32m&\\\\e[0m'
_YELLOW='\\\\e[1;33m&\\\\e[0m'
_format () {
tr -d '"' |
sed "s/ \+>[^ ]* \+<.*/$_YELLOW/" | # ~ / ^ / < >= ~ a window
sed "s/ \+>[^ ]* *$/$_GREEN/" | # >= no upper limit
sed "/>/ !s/<.*$/$_RED/" | # < ~ upper limit
sed "/>\|</ !s/ .*/ $_RED/" # == ~ locked version
}
_requires () {
sed -n "/^name = \"$1\"/I,/\[\[package\]\]/{
/\[package.dep/,/^$/{
/^[^[]/ {
s/= {version = \(\"[^\"]*\"\).*/, \1/p;
s/ =/,/gp
}}}" poetry.lock |
sed "/,.*,/!s/</,</; s/^[^<]\+$/&,/" |
column -t -s , | _format
}
_required_by () {
sed -n "/\[metadata\]/,//d;
/\[package\]\|\[package\.depen/,/^$/H;
/^name\|^$1 = /Ip" poetry.lock |
sed -n "/^$1/I{x;G;p};h" |
sed 's/.*"\(.*\)".*/\1/' |
sed '$!N;s/\n/ /' |
column -t | _format
}
deps() {
echo
echo -e "\e[1mREQUIRES\e[0m"
_requires "$1" | xargs -i echo -e "\t{}"
echo
echo -e "\e[1mREQUIRED BY\e[0m"
_required_by "$1" | xargs -i echo -e "\t{}"
echo
}
deps $1 |
|
|
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |


Pull Request Check List
Add a flag
--whytopoetry show. User should see a filtered output why the package is required.Example (run on poetry repo):
or
closes: #1906