We're building utilities to create portable test environments on a 
continuous integration and delivery platform (CircleCI). We want our 
packages to run on Python 2 and 3 (2.7 and 3.5, currently). We've developed 
build utilities that creates these environments, runs tests, and then saves 
the results. 
We use pip to create environments from requirements.txt files in the 
packages. But I'm finding it tricky to use pip and obtain good error 
handling. For example, this approach

        with open('requirements.txt', 'r') as file:
            reqs = [line.rstrip() for line in file.readlines()]
            pip.main(['install'] + reqs)

raises exceptions for lines in requirements.txt  that just contain comments.
Is there a recommended way to use pip, especially pip install, from within 
a program and obtain good error handling?


Reply via email to