Skip to content
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

poetry init does not find the package if the search string is capitalized #5035

Closed
3 tasks done
cu opened this issue Jan 13, 2022 · 4 comments · Fixed by #5076
Closed
3 tasks done

poetry init does not find the package if the search string is capitalized #5035

cu opened this issue Jan 13, 2022 · 4 comments · Fixed by #5076
Labels
area/cli Related to the command line area/ux Features and improvements related to the user experience kind/bug Something isn't working as expected

Comments

@cu
Copy link

cu commented Jan 13, 2022

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Pop OS 21.04
  • Poetry version: 1.1.12
  • Link of a Gist with the contents of your pyproject.toml file:

Issue

In the package selection part of the poetry init wizard, package selection only works reliably if you use a fully lowercase search string. If you capitalize the search string, a package matching that string will not show up in the results.

Say I want to add Flask as a dependency. The package name on this project is capitalized on PyPI. If I search for flask, the package will show up in the results. If I search for Flask, it will not.

$ poetry init -vvv

This command will guide you through creating your pyproject.toml config.

Package name [notes]:  
Version [0.1.0]:  
Description []:  
Author [<censored>, n to skip]:  
License []:  
Compatible Python versions [^3.9]:  

Would you like to define your main dependencies interactively? (yes/no) [yes] 
You can specify a package in the following forms:
  - A single name (requests)
  - A name and a constraint (requests@^2.23.0)
  - A git url (git+https://github.com/python-poetry/poetry.git)
  - A git url with a revision (git+https://github.com/python-poetry/poetry.git#develop)
  - A file path (../my-package/my-package.whl)
  - A directory (../my-package/)
  - A url (https://example.com/packages/my-package-0.1.0.tar.gz)

Search for package to add (or leave blank to continue): Flask
Found 20 packages matching Flask

Enter package # to add, or the complete package name if it is not listed: 
 [0] Flask-Zipper
 [1] Flask-DB
 [2] flask-beans
 [3] Flask-Sessions
 [4] Flask-SimpleACL
 [5] flask-blacklist
 [6] Flask-Shelve
 [7] flask_wifiqr
 [8] Flask-Account
 [9] Flask-OpenID
 > 
@cu cu added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jan 13, 2022
@finswimmer
Copy link
Member

Hello @cu,

thanks for reporting.

The problem are in these lines:

matches_names = [p.name for p in matches]
exact_match = constraint["name"] in matches_names
if exact_match:
choices.append(
matches[matches_names.index(constraint["name"])].pretty_name
)

We should use the canonical name of constraint["name"] to find in "exact" match in the list of results. Because we don't do it now, the result for "Flask" isn't put in front of the result list we present to the user. Together with the fact that the result list is cut down to 10 result this package is hide.

fin swimmer

@finswimmer finswimmer added area/cli Related to the command line Good First Issue area/ux Features and improvements related to the user experience and removed status/triage This issue needs to be triaged labels Jan 13, 2022
@evanrittenhouse
Copy link
Contributor

evanrittenhouse commented Jan 19, 2022

@finswimmer mind if I take this one? I've forked and am starting development, but if it's already assigned, don't want to step on any toes

@finswimmer
Copy link
Member

Hey @evanrittenhouse,

yes, feel free to start working on it 👍

fin swimmer

Copy link

github-actions bot commented Mar 2, 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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/cli Related to the command line area/ux Features and improvements related to the user experience kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants