Silence broken pipe error

if .installed.txt is out of date, cmp will bail out early.  This will
cause expand_reqs.py to run into a broken pipe error.  This is
perfectly normal pipe semantics, but printing the traceback and error
to the log adds noise, so we silence the error.

There is a possibility of silencing legitimate errors, but the chance
and cost are low:

1. Its easy to test expand_reqs.py by hand.
2. The failure mode is that we always detect that the virtualenv is
   out of date.  This increases run time by a number of seconds;
   undesirable, but not fatal.
3. expand_reqs.py is simple and has unit tests, so it should be
   relatively stable and any bugs would be easy to find and fix.
4. The other possibilities for failures (e.g., disk failure) will be
   noisy and detectable elsewhere.
5. We can add metrics in the future to make such errors easy to
   notice.

BUG=chromium:673842
TEST=Run chromite run_tests with out of date .installed.txt

Change-Id: Iee0e3e47975257a49bab755d03af67240ae5b997
Reviewed-on: https://chromium-review.googlesource.com/419362
Commit-Ready: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: David Riley <davidriley@chromium.org>
1 file changed
tree: de67c68b0bde06cc8908296ed02c4203d156bcfd
  1. pip_packages/
  2. create_venv
  3. expand_reqs.py
  4. README.md
  5. venv_command
README.md

infra_virtualenv README

This repository provides a common Python virtualenv interface that infra code (such as chromite) can depend on. At this point, it is experimental and not yet used in production.

Virtualenv users should create a requirements.txt file listing the packages that they need and use the wrapper scripts (described below) to create the virtualenv and run commands within it.

To add packages to this repository, run:

$ pip wheel -w path/to/pip_packages -r path/to/requirements.txt

Commit the changes and make a CL.

For example for chromite, from within chromite/virtualenv, run:

$ pip wheel -w pip_packages -r requirements.txt

Wrapper scripts

This repository contains two scripts for working with Python virtualenvs.

venv_command runs a command in a virtualenv environment. This is more convenient than having to start a shell and source bin/activate. For example, to start Python inside the virtualenv:

$ venv_command path/to/venv python

create_venv creates or updates a virtualenv using a requirements.txt file.

$ create_venv path/to/venv path/to/requirements.txt

Here’s a complete example:

$ echo mock=2.0.0 > requirements.txt
$ ./create_venv venv requirements.txt
$ ./venv_command venv python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mock
>>>