Python Forum

Full Version: get extensive package info with pip
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
pip show is only for installed packages while pip search does search pypi of uninstalled packages. However the results of pip search are kind of weak

metulburr@ubuntu:~$ pip search beautifulsoup4
beautifulsoup4-slurp (0.0.2)  - Slurp packages Beautifulsoup4 into command
                                line.
beautifulsoup4 (4.6.0)        - Screen-scraping library
  INSTALLED: 4.6.0 (latest)
parse-helper (0.1.16)         - Helpers to fetch & parse text on pages with
                                requests, lxml, & beautifulsoup4
soup_helpers (0.0.8)          - A simple set of BeautifulSoup4 unit test
                                helpers
What if i want to get info such as licenses, uploads, etc. Essentially the majority of info from https://pypi.python.org/pypi/beautifulsoup4
It doesnt even give you a link to click to get to pypi for more info. You have to go to pypi and search it out separately. Which basically makes pip search mostly pointless.

Am i just missing something or is pip search lacking?
I only tested pip search sometime and have not find it useful.
Only take out quick overview info of a package.
If look source code search.py,so dos it still use XMLRPC interface.
PyPi has a json API,you can try bs4 call

So i guess could write a own version to get more info.
I find search on web or PyPi site work fine for what i need.
Warehouse the new PyPi,is moving slowly forward.
Thats a good idea. I could rewrite pip's search, but assuming i would pull request to them, it would need to scrape pypi site with bare bones python libs. Sick

Ive never heard of warehouse. ARe they going to overhaul pip as well.
looking more into this....specifically at search to mimic, i have no idea what all this stuff is doing

from pip._vendor import pkg_resources
from pip._vendor.packaging.version import parse as parse_version
# NOTE: XMLRPC Client is not annotated in typeshed as on 2017-07-17, which is
#       why we ignore the type on this import
from pip._vendor.six.moves import xmlrpc_client  # type: ignore

from pip._internal.basecommand import SUCCESS, Command
from pip._internal.download import PipXmlrpcTransport
from pip._internal.exceptions import CommandError
from pip._internal.models import PyPI
from pip._internal.status_codes import NO_MATCHES_FOUND
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import get_terminal_size
So normally i would just parse out the json api, and print the results formatted nicely. Is that even possible here, or is there a method to stdout required for pip?

rambling as im thinking here...
Im also now quite curious on the use of virtual environments. How would you create an environment to use the testing pip? Im assuming you would have to create a virtual env for a new install python (linux) and replace pip with the test pip,but how..
(Jan-14-2018, 04:39 PM)metulburr Wrote: [ -> ]? Im assuming you would have to create a virtual env for a new install python (linux) and replace pip with the test pip,but how..
Not sure what you mean with test pip.
A virtual environment is like new Python installation,so there is also all source code for pip.
Inside the virtual environment you can test and mess up as much as you want.
As you can just delete and make new one,if all goes wrong.
i just compiled a new python install. But i am trying to modify the pip in there and link it to github, but it looks like when you download python it has the wheel uncompressed

metulburr@ubuntu:~/Python-3.6.4/Lib/ensurepip/_bundled$ ls
pip-9.0.1-py2.py3-none-any.whl  setuptools-28.8.0-py2.py3-none-any.whl
other than that i cant find where pip resides locally in the python install.

metulburr@ubuntu:~/Python-3.6.4$ ls | grep pip
metulburr@ubuntu:~/Python-3.6.4$ 
$ which pip
This will point to the executable.
but that is my systems pip, i want to use and modify the one that came with 3.6.4. I didnt install python, i only compiled it.
Try python3 -c "import pip; print(pip)"
Pages: 1 2