di / pip-api

An unofficial, importable pip API
https://pypi.org/p/pip-api
Apache License 2.0
110 stars 15 forks source link

Add usage examples to README #181

Closed reynoldsnlp closed 1 year ago

reynoldsnlp commented 1 year ago

It would be nice to see a couple usage examples in the README. Virtually everything in the source is named with a leading underscore, so it's not immediately clear where to start.

For example, what is the pip_api equivalent of pip install --upgrade requests?

di commented 1 year ago

All supported commands are listed here: https://github.com/di/pip-api#supported-commands.

Since the goal of this project is to provide an importable pip API, it's designed to be be used as a drop-in replacement for existing uses of pip's internal API, not to replace pip's command line API. This means that some things that are usually done on the command line aren't available here.

If your goal is to wrap command-line calls, you'd be better of calling them in a subprocess directly rather than trying to use this library (since this is just what this library ends up doing anyways). Something like:

subprocess.check_output("python", "-m", "pip", "install", "--upgrade", "requests")

If you're already using this library to replace imports from pip's internal API, and want to make sure subprocesses calls are run in the same way, you can do something like this:

import pip_api

pip_api._call.call("install", "--upgrade", "requests")

Note that this isn't technically a supported API for this library, but it's fairly unlikely to change (and I'd probably be OK with turning it into something officially supported).

reynoldsnlp commented 1 year ago

Thanks, @di ! Sorry I misunderstood what this project was for. I'll close this issue.