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

a search --strict option to search only for an exact package name #7985

Closed
stonebig opened this issue Apr 5, 2020 · 5 comments
Closed

a search --strict option to search only for an exact package name #7985

stonebig opened this issue Apr 5, 2020 · 5 comments
Labels
C: search 'pip search' state: blocked Can not be done until something else is done type: feature request Request for a new feature

Comments

@stonebig
Copy link
Contributor

stonebig commented Apr 5, 2020

What's the problem this feature will solve?
I'm trying to get from pypi the given Summary of a package, programmatically
it's a bit what qypi does (but still from command line)

today, I need to:

  • !pip search "this_package"
  • get the answer from stdout
  • filter the first line that starts per "this_package ("
  • then takes what is after the first " - "
    ... a bit tricky

Describe the solution you'd like

  • having a pip search option that allows to gives back only for an exact match ("--strict" ?) (exact in PEP 503 meaning)
  • having an option to get directly programmatically a json / dict result, so I don't have to parse the result, would be awesome, but may not be in the pip idea.

Alternative Solutions
currently, I have to do that way, which has a bigger environmental impact than I would like

image

Additional context
I'm maintaining WinPython distribution.

@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Apr 5, 2020
@deveshks
Copy link
Contributor

deveshks commented Apr 5, 2020

This is something I can take a look at. For --strict flag, I think we can use some variant of the search api in Warehouse API

I assume that for the json/dict, representation, the output might be something like this for pip search peppercorn --format json

[
         {
		'Name': 'peppercorn',
		'Version': '0.6',
		'Description': 'A library for converting a token stream into a data structure for use in web form posts'
	},
	{
		'Name': 'pepperedform',
		'Version': '0.6.1',
		'Description': 'Helpers for using peppercorn with formprocess.'
	}
]

I will wait for other to chime in and provide their ideas before we continue.

@stonebig
Copy link
Contributor Author

stonebig commented Apr 8, 2020

In the mean time I discover that since Python-3.5+, we have the ".run" option, better than ".popen" in my use case.

import subprocess
process = subprocess.run( ["pip","search", "zezefefzefed" ,"--retries", "0"], stdout=subprocess.PIPE)  

@sbidoul sbidoul added C: search 'pip search' type: feature request Request for a new feature labels Apr 9, 2020
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Apr 9, 2020
@andrew-garner
Copy link

This feature would also be useful when trying to retrieve available versions for a given package. In the case of ansible when I run pip search ansible== with pip v20.2 I get back 100 hits, none of which are for the "ansible" package. If I know I have the exact package name then I'd like to be able to get the available versions which is what I'd hope this feature would do.

@uranusjr
Copy link
Member

uranusjr commented Aug 3, 2020

Somehow blocked by pypi/warehouse#284. The index needs to design an API first. There’s nothing pip can do at this time.

@uranusjr uranusjr added the state: blocked Can not be done until something else is done label Aug 3, 2020
@pradyunsg
Copy link
Member

pradyunsg commented Oct 7, 2022

Closing this since pip search is no longer usable on PyPI: #5216

We can revisit this if/when there's a new search API.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: search 'pip search' state: blocked Can not be done until something else is done type: feature request Request for a new feature
Projects
None yet
Development

No branches or pull requests

6 participants