Skip to content

sorting packages #312

Closed
Closed

Description

@tkossak
  • 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.

Activity

  1. nchammas commented on Jul 17, 2018

    @nchammas
    Contributor

    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.

  2. tkossak commented on Jul 17, 2018

    @tkossak
    Author

    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).

  3. sdispater commented on Jul 17, 2018

    @sdispater
    Member

    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.

  4. rafalkrupinski commented on Feb 24, 2019

    @rafalkrupinski

    I'd sort dependencies alphabetically even in pyproject.toml, I find that helps with merging branches if they both have new entries added

  5. added this to the 1.0 milestone on Mar 2, 2019
  6. n8sty commented on Aug 29, 2019

    @n8sty
    Contributor

    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}
    

    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.

  7. modified the milestones: 1.0, Future on Oct 4, 2019
  8. Vozf commented on Nov 10, 2020

    @Vozf

    I also believe that alphabetical storage is the best choice as it is done by npm
    For example when I do

    poetry remove some-package
    poetry add some-package
    

    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

  9. VikashKothary commented on Apr 13, 2022

    @VikashKothary

    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.

  10. andrei-shabanski commented on Sep 1, 2022

    @andrei-shabanski

    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, or init commands. To install the plugin run:

    poetry self add poetry-plugin-sort

    Note that it's a beta. Please, let me know how it works if someone will try it

  11. VikashKothary commented on Sep 3, 2022

    @VikashKothary

    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.

  12. rafalkrupinski commented on Oct 24, 2022

    @rafalkrupinski

    @tkossak Does Andrei's plug-in solves the problem? Can the issue be closed?

  13. tkossak commented on Oct 27, 2022

    @tkossak
    Author

    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.

  14. dimbleby commented on Jan 22, 2023

    @dimbleby
    Contributor

    poetry has shown only 10 results for some years now - 2e579c7 - this should probably be closed

  15. github-actions commented on Feb 29, 2024

    @github-actions

    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.

  16. locked as resolved and limited conversation to collaborators on Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cliRelated to the command linekind/featureFeature requests/implementations

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions