You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the issues of this repo and believe that this is not a duplicate.
Issue
When I use 'poetry init' and get to the step for searching packages, it looks like huge mess: https://imgur.com/a/WA9CcnJ
Maybe we can get this list sorted alphabetically? Or/except maybe display packages that are most likely what I look for (because the name is exactly what i typed) on the bottom, so I don't have to scroll the list in search for its number.
Reacted by neitsa, Samuel Meuli, Alexey, ggulyastm, Paul Meinhardt, Maksim Kalmykov, Zhuyi Xue, Mattwmaster58, Conor Sheehan, barakreif and 37 more
I found this to be a minor issue with poetry init, too. One easy improvement that could be made would be to always rank any exact match at the top.
Further improvements are certainly possible (perhaps Poetry could somehow leverage the search result rankings returned by https://pypi.org/), but just placing exact matches at the top would be a nice improvement by itself.
Not at the top - at the bottom (like https://github.com/Jguer/yay is doing) so we don't have to scroll for best matches but see them instantly where the cursor is (on the bottom that is).
I'd sort dependencies alphabetically even in pyproject.toml, I find that helps with merging branches if they both have new entries added
Reacted by Samuel Meuli, Richard Xia, festinuz, drunkwcodes, Arun Babu Neelicattu, John Freeman, Hemanta, Boris Feld, Victor, Mattwmaster58 and 35 more
I took a crack at trying to fix this to learn a bit more about Poetry's guts and contribute to a tool that's made my work a bit easier. I think I may have discovered another issue that relates to specifying packages interactively, and is potentially solved by sorting.
When I go through a poetry init flow in an empty directory and specify either Django or django I can't actually get either one picked up by https://github.com/sdispater/poetry/blob/f4803e91bca440e6f4af6ad54e396d01c024a76f/poetry/console/commands/init.py#L189-L193. I believe this happens because the choice method of cleo.Command only allows what's returned in the array of choices to be selected from. And, the array of responses when using either of those search terms doesn't include [dD]jango. Digging more, I tried using xmlrpc.client.ServerProxy to query PyPi by xmlrpc.client.ServerProxy("https://pypi.python.org/pypi").search({'name': 'django'}, "or")[0] which returned (what I'm looking for)
{'name': 'Django',
'summary': 'A high-level Python Web framework that encourages rapid development and clean, pragmatic design.',
'version': '2.2.4',
'_pypi_ordering': False}
It deletes the entry of some package from pyproject.toml and adds it in the end. I would expect the pyproject to stay the same
Reacted by nate giraldi, samypr100, Riccardo Albertazzi, Ed Rivas, Samantha Hughes, Chad Saunders, David Lechner, Simon Gurcke, Jakub Stępak, Benjamin Green and 12 more
Until this gets implemented, I've been using the toml-sort package:
poetry add -D toml-sort
poetry run toml-sort pyproject.toml --all --in-place
The downside is that it sorts the entire file and not just the dependencies, but that was an acceptable trade-off for me. You should also be careful because it seems to remove comments if they're on a new line by themselves.
Reacted by edatpb, Andrew C, Erkin, Kyle King and Jesse Hu
Reacted by Andrew C, Maxim Vinogradov, Erkin and Jesse Hu
I don't know if it solves the problem, because I stopped using interactive package searching/additions in poetry. Nowadays I just poetry add PKG and that's it.
As for me we can close this ticket.
Activity
nchammas commentedon Jul 17, 2018
I found this to be a minor issue with
poetry init, too. One easy improvement that could be made would be to always rank any exact match at the top.Further improvements are certainly possible (perhaps Poetry could somehow leverage the search result rankings returned by https://pypi.org/), but just placing exact matches at the top would be a nice improvement by itself.
tkossak commentedon Jul 17, 2018
Not at the top - at the bottom (like https://github.com/Jguer/yay is doing) so we don't have to scroll for best matches but see them instantly where the cursor is (on the bottom that is).
sdispater commentedon Jul 17, 2018
I agree that it is a usability issue. The idea of putting the more relevant packages at the bottom seems a good improvement to start with.
rafalkrupinski commentedon Feb 24, 2019
I'd sort dependencies alphabetically even in pyproject.toml, I find that helps with merging branches if they both have new entries added
n8sty commentedon Aug 29, 2019
I took a crack at trying to fix this to learn a bit more about Poetry's guts and contribute to a tool that's made my work a bit easier. I think I may have discovered another issue that relates to specifying packages interactively, and is potentially solved by sorting.
When I go through a
poetry initflow in an empty directory and specify eitherDjangoordjangoI can't actually get either one picked up by https://github.com/sdispater/poetry/blob/f4803e91bca440e6f4af6ad54e396d01c024a76f/poetry/console/commands/init.py#L189-L193. I believe this happens because thechoicemethod ofcleo.Commandonly allows what's returned in the array of choices to be selected from. And, the array of responses when using either of those search terms doesn't include[dD]jango. Digging more, I tried usingxmlrpc.client.ServerProxyto query PyPi byxmlrpc.client.ServerProxy("https://pypi.python.org/pypi").search({'name': 'django'}, "or")[0]which returned (what I'm looking for)So, I think @nchammas 's suggestion above about using the search result ordering from PyPi potentially solves this problem. For reference, I'm using the latest version of master https://github.com/sdispater/poetry/tree/f4803e91bca440e6f4af6ad54e396d01c024a76f. I'm happy to try and throw a fix together assuming it's not already in the works.
Vozf commentedon Nov 10, 2020
I also believe that alphabetical storage is the best choice as it is done by npm
For example when I do
It deletes the entry of some package from pyproject.toml and adds it in the end. I would expect the pyproject to stay the same
VikashKothary commentedon Apr 13, 2022
Until this gets implemented, I've been using the
toml-sortpackage:The downside is that it sorts the entire file and not just the dependencies, but that was an acceptable trade-off for me. You should also be careful because it seems to remove comments if they're on a new line by themselves.
andrei-shabanski commentedon Sep 1, 2022
Since Poetry 1.2 introduces the plugin system, this kind of job can be delegated to plugins. That's what I did
https://pypi.org/project/poetry-plugin-sort/ sorts dependencies every time after running
add,remove, orinitcommands. To install the plugin run:Note that it's a beta. Please, let me know how it works if someone will try it
VikashKothary commentedon Sep 3, 2022
You didn't link your repository so I did it for you: https://github.com/andrei-shabanski/poetry-plugin-sort.
Also your PyPI link didn't work for me: https://pypi.org/project/poetry-plugin-sort/.
I look forward to checking it out.
rafalkrupinski commentedon Oct 24, 2022
@tkossak Does Andrei's plug-in solves the problem? Can the issue be closed?
tkossak commentedon Oct 27, 2022
I don't know if it solves the problem, because I stopped using interactive package searching/additions in poetry. Nowadays I just
poetry add PKGand that's it.As for me we can close this ticket.
dimbleby commentedon Jan 22, 2023
poetry has shown only 10 results for some years now - 2e579c7 - this should probably be closed
github-actions commentedon Feb 29, 2024
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.