pipx icon indicating copy to clipboard operation
pipx copied to clipboard

Add a SEARCH feature to Pipx

Open ghost opened this issue 3 years ago • 9 comments

How would this feature be useful? This feature will be useful for those who want to search for pypi packages from their terminals

Describe the solution you'd like The search feature will parse results from pypi.org and github.com with short descriptions for each

  • There will be three columns: Source | Name | Description pypi | rainbowstream | A smart and nice Twitter client on terminal
  • We can also add pipx search -l for parsing long descriptions
  • Also add pipx search -s git OR -s pypi for specifying the search source, by default the search will parse both sources results

What do you think of the concept ?

ghost avatar Dec 10 '21 11:12 ghost

Unfortunately PyPI does not currently expose an API that makes this simple, and IMO it is out of pipx’s design scope to build custom logic for this. The concept is good, but not viable.

uranusjr avatar Dec 10 '21 12:12 uranusjr

Maybe you can find insperation from this tool: https://pdm.fming.dev

ghost avatar Dec 10 '21 15:12 ghost

How pdm does it is exactly by implementing custom logic, which I already mentioned is out of scope.

uranusjr avatar Dec 10 '21 16:12 uranusjr

How pdm does it is exactly by implementing custom logic, which I already mentioned is out of scope.

Seems like something worth considering. All it would take is someone implementing it, or even copying pdm's logic. From a user perspective, it would be an improvement.

cs01 avatar Dec 10 '21 19:12 cs01

PDM does it by parsing the user-facing https://pypi.org/search/ page. The search term and other criteria are supplied by GET parameters. If I remember correctly, there is actually a library somewhere that does this so we don’t need to rewrite the HTML parser, but I’m not sure if it’s stable enough we can reasonably depend on.

uranusjr avatar Dec 11 '21 19:12 uranusjr

From a user perspective: the search feature is a huge improvement to the tool.

From a developper perspective: this can be tested in an experimental branch. Once stablized, it can be merged to the master branch. This feature is a major version bump, so it can be added to a future version 17.0.0

ghost avatar Dec 11 '21 19:12 ghost

After taking deeper look into how pdm works, I found similar functionalities between pdm and poetry about the search function. This is pdm config file

Home configuration (~/.pdm/config.toml):
  auto_global = False
  build_isolation = True
  cache_dir = ~/.cache/pdm
  check_update = True
  feature.install_cache = False
  parallel_install = True
  project_max_depth = 5
  pypi.json_api = False
  **pypi.url = https://pypi.org/simple**
  pypi.verify_ssl = True
  python.use_pyenv = True
  strategy.resolve_max_rounds = 10000
  strategy.save = minimum
  strategy.update = reuse
  use_venv = False

I think, for the new release of pipx, you can parse search results from https://pypi.org/simple, just like how pdm do it beautifully: pdm search pipx

pipx (0.16.5)                  - Install and Run Python Applications in Isolated Environments
pipx-in-pipx (1.0.1)           - pipipxx (pronounced pipx in pipx): Bootstrap your pipx with pipx.
pipipxx (1.0.1)                - pipipxx (pronounced pipx in pipx): Bootstrap your pipx with pipx.
pipxinpipx (0.0.2)             - Did you mean to install pipx-in-pipx?
pipipx (0.0.2)                 - Did you mean to install pipx-in-pipx?
jwa (2021.1)                   - pipx run jwa
pycowsay (0.0.0.1)             - 
llyfrau (0.3.0)                - Bookmark management
yocho.pyld-xtl (0.2.0a4)       - Extra tools for pyld
auto-gitignore (1.0.0)         - Create gitignore template with autocompletion.
yocho.rdflib-xtl (0.3.0)       - Extra tools for rdflib
aucampia.rdflib-xtl (0.6.0)    - Extra tools for rdflib
text2excel (0.4.2)             - Converts to Excel XLSX from a TSV or CSV text file.
nvsmi (0.4.2)                  - A (user-)friendly wrapper to nvidia-smi
renku-r-tools (0.0.4)          - A toolbox to work with R projects on Renku
slims-lisp (0.2.0)             - A high-level CLI for SlIMS REST API
4711 (0.0.2)                   - A collection of CLI tools for working with data structures, parsing and formatting
salt-extension (0.23.0)        - Tool to simplify the creation of a new salt extension
conan-client-remote-s3 (0.0.6) - Serverless Conan remote storing packages in S3 bucket
gitutor (0.6.5)                - A command line app that makes Git easy.

ghost avatar Dec 28 '21 21:12 ghost

PR welcome.

gaborbernat avatar Dec 02 '23 17:12 gaborbernat