ywangd / stash

StaSh - Shell for Pythonista
MIT License
1.92k stars 227 forks source link

XMLRPC error on pip search #510

Open sudocurse opened 1 month ago

sudocurse commented 1 month ago

I believe this is a known-ish issue but couldn't find anything on github tracking it- sorry if this is a duplicate report.

I used import requests as r; exec(r.get('https://bit.ly/get-stash').content) to install, relaunched pythonista and spawned a stash shell. Then tried to search with pip:

Tip: Use mc to access files in your Dropbox or on a FTP-Server
[~/Documents]$ pip
site-packages/stash/bin/pip.py:35: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.util import convert_path
Error: unknown command: None
stash: ^C
KeyboardInterrupt: Exit: 1

[~/Documents]$ pip search cowsay
stash: <class 'xmlrpc.client.Fault'>: <Fault -32500: "RuntimeError: PyPI no longer supports 'pip search' (or XML-RPC search). Please use https://pypi.org/search (via a browser) instead. See https://warehouse.pypa.io/api-reference/xml-rpc.html#deprecated-methods for more information.">
[~/Documents]$ selfupdate
Running selfupdate ...
Target: ywangd:master
Checking for new version ...
Already at latest version

Seems like this is a known issue that search still tries to use the deprecated xmlrpc endpoint- although I don't understand the comment in the search function.

Was the reasoning to maintain the ability to partial search? If so, since the endpoint is down, compatibility is already broken. Instead, can search simply return the results of _package_data?

Otherwise, as I believe the comment suggests, it seems like the solution would be to request https://pypi.org/simple/ or similar and grep.py or search over the response.