Do not generate *.pyc files.

Leftover *.pyc files are often problematic; for example, pytest
raises errors on running unit tests if a absolute path recorded in
*.pyc is different from its current apparent path, which is often
the case with our chroot build environment.

This change tells the Python interpreter not to generate *.pyc
files by passing -B option. Also, run_tests is updated not to
delete existing *.pyc files so that the command can be run inside
portage sandbox.

BUG=chromium:733103
TEST=CL:709174

Change-Id: Ibd5e2f2a707ef3bc9fa48c4acc2ed7ef7a8a228c
Reviewed-on: https://chromium-review.googlesource.com/711779
Commit-Ready: Shuhei Takahashi <nya@chromium.org>
Tested-by: Shuhei Takahashi <nya@chromium.org>
Reviewed-by: Shuhei Takahashi <nya@chromium.org>
diff --git a/bin/python_venv b/bin/python_venv
index 521295c..f57a450 100755
--- a/bin/python_venv
+++ b/bin/python_venv
@@ -70,4 +70,8 @@
 fi
 
 export PYTHONPATH="${extra_imports_dir}"
-exec "${venv_dir}/bin/python" "$@"
+
+# Always pass -B option to avoid generating *.pyc files. In particular,
+# on running unit tests on buildbots, *.pyc generation causes problems
+# because write-access to the repository is sandboxed.
+exec "${venv_dir}/bin/python" -B "$@"
diff --git a/bin/run_tests b/bin/run_tests
index ad43670..f1e841b 100755
--- a/bin/run_tests
+++ b/bin/run_tests
@@ -10,6 +10,4 @@
 
 cd "${bin_dir}/.."
 
-find . -name "*.pyc" -delete
-
 exec "${bin_dir}/python_venv" -m pytest "$@"