This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients BreamoreBoy, Marcus.Smith, Saimadhav.Heblikar, dstufft, ncoghlan, paul.moore, peter.otten, rhettinger, steve.dower, terry.reedy
Date 2015-09-05.22:47:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1441493232.0.0.435871530279.issue23551@psf.upfronthosting.co.za>
In-reply-to
Content
Pip's rather extensive command-line API can also be used as a code API. The signature of pip.main is (args=None), where args = sys.argv[1:] if not passed. I presume this will not change. Reusing the command-list API had the advantage of reusing the existing docs, help output, and knowlege of how to use pip.

The API is to run 'status = pip.main(args)', where args is a list containing quoted versions of the command-line args, the same as one would pass to subprocess.Popen.  Output is strings written to stdout (and stderr), which can be captured with StringIO. While not as nice as getting, say, a list of strings from a list_command function, I consider this better than repeatedly calling Popen and getting encoded bytes (in whatever encoding) from pipes.

I tested this with list, show pip, help install, and install --upgrade pip.  After a shell restart,  import pip imported the new version. I am working on a wrapper for the pip.main call.
History
Date User Action Args
2015-09-05 22:47:12terry.reedysetrecipients: + terry.reedy, rhettinger, paul.moore, ncoghlan, peter.otten, BreamoreBoy, steve.dower, dstufft, Marcus.Smith, Saimadhav.Heblikar
2015-09-05 22:47:12terry.reedysetmessageid: <1441493232.0.0.435871530279.issue23551@psf.upfronthosting.co.za>
2015-09-05 22:47:11terry.reedylinkissue23551 messages
2015-09-05 22:47:11terry.reedycreate