We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
check.sh fails on clean master
Just merged master and ran check.sh and it is failing due to tensorflow

```
(cirq) [dabacon:cirq:~/git/cirq]$./continuous-integration/check.sh 
run: ('virtualenv', '--quiet', '-p', '/usr/bin/python3.5', '/tmp/test-cirq-kp5mfrah/.test_virtualenv')
run: ('/tmp/test-cirq-kp5mfrah/.test_virtualenv/bin/pip', 'install', '--quiet', '-r', '/tmp/test-cirq-kp5mfrah/requirements.txt')
run: ('/tmp/test-cirq-kp5mfrah/.test_virtualenv/bin/pip', 'install', '--quiet', '-r', '/tmp/test-cirq-kp5mfrah/dev_tools/conf/pip-list-dev-tools.txt')

Running pylint
Finished pylint


Running typecheck
Finished typecheck


Running pytest

==================================== ERRORS ====================================
_______ ERROR collecting cirq/contrib/tpu/circuit_to_tensorflow_test.py ________
ImportError while importing test module '/tmp/test-cirq-kp5mfrah/cirq/contrib/tpu/circuit_to_tensorflow_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
cirq/contrib/tpu/__init__.py:75: in <module>
    from cirq.contrib.tpu.circuit_to_tensorflow import (
cirq/contrib/tpu/circuit_to_tensorflow.py:20: in <module>
    import tensorflow as tf
E   ImportError: No module named 'tensorflow'

----------- coverage: platform linux, python 3.5.3-final-0 -----------
Coverage annotated source written next to source

!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
1 error in 34.82 seconds
Finished pytest
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `dev_tools/env_tools.py`
Content:
```
1 # Copyright 2018 The Cirq Developers
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     https://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 import os
16 import shutil
17 import sys
18 from typing import Optional, Iterable, Callable, cast
19 
20 from dev_tools import shell_tools, git_env_tools
21 from dev_tools.github_repository import GithubRepository
22 from dev_tools.prepared_env import PreparedEnv
23 
24 
25 def get_unhidden_ungenerated_python_files(directory: str) -> Iterable[str]:
26     """Iterates through relevant python files within the given directory.
27 
28     Args:
29         directory: The top-level directory to explore.
30 
31     Yields:
32         File paths.
33     """
34     for dirpath, dirnames, filenames in os.walk(directory, topdown=True):
35         if os.path.split(dirpath)[-1].startswith('.'):
36             dirnames.clear()
37             continue
38 
39         for filename in filenames:
40             if filename.endswith('.py') and not filename.endswith('_pb2.py'):
41                 yield os.path.join(dirpath, filename)
42 
43 
44 def create_virtual_env(venv_path: str,
45                        requirements_paths: Iterable[str],
46                        python_path: str,
47                        verbose: bool) -> None:
48     """Creates a new virtual environment and then installs dependencies.
49 
50     Args:
51         venv_path: Where to put the virtual environment's state.
52         requirements_paths: Location of requirements files to -r install.
53         python_path: The python binary to use.
54         verbose: When set, more progress output is produced.
55     """
56     shell_tools.run_cmd('virtualenv',
57                         None if verbose else '--quiet',
58                         '-p',
59                         python_path,
60                         venv_path,
61                         out=sys.stderr)
62     pip_path = os.path.join(venv_path, 'bin', 'pip')
63     for req_path in requirements_paths:
64         shell_tools.run_cmd(pip_path,
65                             'install',
66                             None if verbose else '--quiet',
67                             '-r',
68                             req_path,
69                             out=sys.stderr)
70 
71 
72 def prepare_temporary_test_environment(
73         destination_directory: str,
74         repository: GithubRepository,
75         pull_request_number: Optional[int],
76         verbose: bool,
77         env_name: str = '.test_virtualenv',
78         python_path: str = '/usr/bin/python3.5',
79         commit_ids_known_callback: Callable[[PreparedEnv], None] = None
80 ) -> PreparedEnv:
81     """Prepares a temporary test environment at the (existing empty) directory.
82 
83     Args:
84         destination_directory: The location to put files. The caller is
85             responsible for deleting the directory, whether or not this method
86              succeeds or fails.
87         repository: The github repository to download content from, if a pull
88             request number is given.
89         pull_request_number: If set, test content is fetched from github.
90             Otherwise copies of local files are used.
91         verbose: When set, more progress output is produced.
92         env_name: The name to use for the virtual environment.
93         python_path: Location of the python binary to use within the
94             virtual environment.
95         commit_ids_known_callback: A function to call when the actual commit id
96             being tested is known, before the virtual environment is ready.
97 
98     Returns:
99         Commit ids corresponding to content to test/compare.
100     """
101     # Fetch content.
102     if pull_request_number is not None:
103         env = git_env_tools.fetch_github_pull_request(
104             destination_directory=destination_directory,
105             repository=repository,
106             pull_request_number=pull_request_number,
107             verbose=verbose)
108     else:
109         env = git_env_tools.fetch_local_files(
110             destination_directory=destination_directory,
111             verbose=verbose)
112 
113     if commit_ids_known_callback is not None:
114         commit_ids_known_callback(env)
115 
116     # Create virtual environment.
117     base_path = cast(str, env.destination_directory)
118     env_path = os.path.join(base_path, env_name)
119     req_path = os.path.join(base_path, 'requirements.txt')
120     req_path_2 = os.path.join(base_path,
121                               'dev_tools',
122                               'conf',
123                               'pip-list-dev-tools.txt')
124     create_virtual_env(venv_path=env_path,
125                        python_path=python_path,
126                        requirements_paths=[req_path, req_path_2],
127                        verbose=verbose)
128 
129     return PreparedEnv(github_repo=env.repository,
130                        actual_commit_id=env.actual_commit_id,
131                        compare_commit_id=env.compare_commit_id,
132                        destination_directory=env.destination_directory,
133                        virtual_env_path=env_path)
134 
135 
136 def derive_temporary_python2_environment(
137         destination_directory: str,
138         python3_environment: PreparedEnv,
139         verbose: bool,
140         env_name: str = '.test_virtualenv_py2',
141         python_path: str = "/usr/bin/python2.7") -> PreparedEnv:
142     """Creates a python 2.7 environment starting from a prepared python 3 one.
143 
144     Args:
145         destination_directory: Where to put the python 2 environment.
146         python3_environment: The prepared environment to start from.
147         verbose: When set, more progress output is produced.
148         env_name: The name to use for the virtualenv directory.
149         python_path: The python binary to use.
150 
151     Returns:
152         A description of the environment that was prepared.
153     """
154 
155     shutil.rmtree(destination_directory)
156     input_directory = cast(str, python3_environment.destination_directory)
157     os.chdir(input_directory)
158     conversion_script_path = os.path.join(
159         input_directory,
160         'dev_tools',
161         'python2.7-generate.sh')
162     shell_tools.run_cmd('bash',
163                         conversion_script_path,
164                         destination_directory,
165                         input_directory,
166                         python3_environment.virtual_env_path,
167                         out=sys.stderr)
168     os.chdir(destination_directory)
169 
170     # Create virtual environment.
171     env_path = os.path.join(destination_directory, env_name)
172     # (These files are output by dev_tools/python2.7-generate.sh.)
173     req_path = os.path.join(destination_directory, 'requirements.txt')
174     req_path_2 = os.path.join(destination_directory, 'pip-list-test-tools.txt')
175     create_virtual_env(venv_path=env_path,
176                        python_path=python_path,
177                        requirements_paths=[req_path, req_path_2],
178                        verbose=verbose)
179 
180     return PreparedEnv(github_repo=python3_environment.repository,
181                        actual_commit_id=python3_environment.actual_commit_id,
182                        compare_commit_id=python3_environment.compare_commit_id,
183                        destination_directory=destination_directory,
184                        virtual_env_path=env_path)
185
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/dev_tools/env_tools.py b/dev_tools/env_tools.py
--- a/dev_tools/env_tools.py
+++ b/dev_tools/env_tools.py
@@ -117,13 +117,18 @@
     base_path = cast(str, env.destination_directory)
     env_path = os.path.join(base_path, env_name)
     req_path = os.path.join(base_path, 'requirements.txt')
-    req_path_2 = os.path.join(base_path,
-                              'dev_tools',
-                              'conf',
-                              'pip-list-dev-tools.txt')
+    dev_req_path = os.path.join(base_path,
+                                'dev_tools',
+                                'conf',
+                                'pip-list-dev-tools.txt')
+    contrib_req_path = os.path.join(base_path,
+                                    'cirq',
+                                    'contrib',
+                                    'contrib-requirements.txt')
+    rev_paths = [req_path, dev_req_path, contrib_req_path]
     create_virtual_env(venv_path=env_path,
                        python_path=python_path,
-                       requirements_paths=[req_path, req_path_2],
+                       requirements_paths=rev_paths,
                        verbose=verbose)
 
     return PreparedEnv(github_repo=env.repository,
@@ -171,10 +176,16 @@
     env_path = os.path.join(destination_directory, env_name)
     # (These files are output by dev_tools/python2.7-generate.sh.)
     req_path = os.path.join(destination_directory, 'requirements.txt')
-    req_path_2 = os.path.join(destination_directory, 'pip-list-test-tools.txt')
+    dev_req_path = os.path.join(destination_directory,
+                                'pip-list-test-tools.txt')
+    contrib_req_path = os.path.join(destination_directory,
+                                    'cirq',
+                                    'contrib',
+                                    'contrib-requirements.txt')
+    req_paths = [req_path, dev_req_path, contrib_req_path]
     create_virtual_env(venv_path=env_path,
                        python_path=python_path,
-                       requirements_paths=[req_path, req_path_2],
+                       requirements_paths=req_paths,
                        verbose=verbose)
 
     return PreparedEnv(github_repo=python3_environment.repository,

{"golden_diff": "diff --git a/dev_tools/env_tools.py b/dev_tools/env_tools.py\n--- a/dev_tools/env_tools.py\n+++ b/dev_tools/env_tools.py\n@@ -117,13 +117,18 @@\n     base_path = cast(str, env.destination_directory)\n     env_path = os.path.join(base_path, env_name)\n     req_path = os.path.join(base_path, 'requirements.txt')\n-    req_path_2 = os.path.join(base_path,\n-                              'dev_tools',\n-                              'conf',\n-                              'pip-list-dev-tools.txt')\n+    dev_req_path = os.path.join(base_path,\n+                                'dev_tools',\n+                                'conf',\n+                                'pip-list-dev-tools.txt')\n+    contrib_req_path = os.path.join(base_path,\n+                                    'cirq',\n+                                    'contrib',\n+                                    'contrib-requirements.txt')\n+    rev_paths = [req_path, dev_req_path, contrib_req_path]\n     create_virtual_env(venv_path=env_path,\n                        python_path=python_path,\n-                       requirements_paths=[req_path, req_path_2],\n+                       requirements_paths=rev_paths,\n                        verbose=verbose)\n \n     return PreparedEnv(github_repo=env.repository,\n@@ -171,10 +176,16 @@\n     env_path = os.path.join(destination_directory, env_name)\n     # (These files are output by dev_tools/python2.7-generate.sh.)\n     req_path = os.path.join(destination_directory, 'requirements.txt')\n-    req_path_2 = os.path.join(destination_directory, 'pip-list-test-tools.txt')\n+    dev_req_path = os.path.join(destination_directory,\n+                                'pip-list-test-tools.txt')\n+    contrib_req_path = os.path.join(destination_directory,\n+                                    'cirq',\n+                                    'contrib',\n+                                    'contrib-requirements.txt')\n+    req_paths = [req_path, dev_req_path, contrib_req_path]\n     create_virtual_env(venv_path=env_path,\n                        python_path=python_path,\n-                       requirements_paths=[req_path, req_path_2],\n+                       requirements_paths=req_paths,\n                        verbose=verbose)\n \n     return PreparedEnv(github_repo=python3_environment.repository,\n", "issue": "check.sh fails on clean master\nJust merged master and ran check.sh and it is failing due to tensorflow\r\n\r\n```\r\n(cirq) [dabacon:cirq:~/git/cirq]$./continuous-integration/check.sh \r\nrun: ('virtualenv', '--quiet', '-p', '/usr/bin/python3.5', '/tmp/test-cirq-kp5mfrah/.test_virtualenv')\r\nrun: ('/tmp/test-cirq-kp5mfrah/.test_virtualenv/bin/pip', 'install', '--quiet', '-r', '/tmp/test-cirq-kp5mfrah/requirements.txt')\r\nrun: ('/tmp/test-cirq-kp5mfrah/.test_virtualenv/bin/pip', 'install', '--quiet', '-r', '/tmp/test-cirq-kp5mfrah/dev_tools/conf/pip-list-dev-tools.txt')\r\n\r\nRunning pylint\r\nFinished pylint\r\n\r\n\r\nRunning typecheck\r\nFinished typecheck\r\n\r\n\r\nRunning pytest\r\n\r\n==================================== ERRORS ====================================\r\n_______ ERROR collecting cirq/contrib/tpu/circuit_to_tensorflow_test.py ________\r\nImportError while importing test module '/tmp/test-cirq-kp5mfrah/cirq/contrib/tpu/circuit_to_tensorflow_test.py'.\r\nHint: make sure your test modules/packages have valid Python names.\r\nTraceback:\r\ncirq/contrib/tpu/__init__.py:75: in <module>\r\n    from cirq.contrib.tpu.circuit_to_tensorflow import (\r\ncirq/contrib/tpu/circuit_to_tensorflow.py:20: in <module>\r\n    import tensorflow as tf\r\nE   ImportError: No module named 'tensorflow'\r\n\r\n----------- coverage: platform linux, python 3.5.3-final-0 -----------\r\nCoverage annotated source written next to source\r\n\r\n!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!\r\n1 error in 34.82 seconds\r\nFinished pytest\r\n```\n", "before_files": [{"content": "# Copyright 2018 The Cirq Developers\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport os\nimport shutil\nimport sys\nfrom typing import Optional, Iterable, Callable, cast\n\nfrom dev_tools import shell_tools, git_env_tools\nfrom dev_tools.github_repository import GithubRepository\nfrom dev_tools.prepared_env import PreparedEnv\n\n\ndef get_unhidden_ungenerated_python_files(directory: str) -> Iterable[str]:\n    \"\"\"Iterates through relevant python files within the given directory.\n\n    Args:\n        directory: The top-level directory to explore.\n\n    Yields:\n        File paths.\n    \"\"\"\n    for dirpath, dirnames, filenames in os.walk(directory, topdown=True):\n        if os.path.split(dirpath)[-1].startswith('.'):\n            dirnames.clear()\n            continue\n\n        for filename in filenames:\n            if filename.endswith('.py') and not filename.endswith('_pb2.py'):\n                yield os.path.join(dirpath, filename)\n\n\ndef create_virtual_env(venv_path: str,\n                       requirements_paths: Iterable[str],\n                       python_path: str,\n                       verbose: bool) -> None:\n    \"\"\"Creates a new virtual environment and then installs dependencies.\n\n    Args:\n        venv_path: Where to put the virtual environment's state.\n        requirements_paths: Location of requirements files to -r install.\n        python_path: The python binary to use.\n        verbose: When set, more progress output is produced.\n    \"\"\"\n    shell_tools.run_cmd('virtualenv',\n                        None if verbose else '--quiet',\n                        '-p',\n                        python_path,\n                        venv_path,\n                        out=sys.stderr)\n    pip_path = os.path.join(venv_path, 'bin', 'pip')\n    for req_path in requirements_paths:\n        shell_tools.run_cmd(pip_path,\n                            'install',\n                            None if verbose else '--quiet',\n                            '-r',\n                            req_path,\n                            out=sys.stderr)\n\n\ndef prepare_temporary_test_environment(\n        destination_directory: str,\n        repository: GithubRepository,\n        pull_request_number: Optional[int],\n        verbose: bool,\n        env_name: str = '.test_virtualenv',\n        python_path: str = '/usr/bin/python3.5',\n        commit_ids_known_callback: Callable[[PreparedEnv], None] = None\n) -> PreparedEnv:\n    \"\"\"Prepares a temporary test environment at the (existing empty) directory.\n\n    Args:\n        destination_directory: The location to put files. The caller is\n            responsible for deleting the directory, whether or not this method\n             succeeds or fails.\n        repository: The github repository to download content from, if a pull\n            request number is given.\n        pull_request_number: If set, test content is fetched from github.\n            Otherwise copies of local files are used.\n        verbose: When set, more progress output is produced.\n        env_name: The name to use for the virtual environment.\n        python_path: Location of the python binary to use within the\n            virtual environment.\n        commit_ids_known_callback: A function to call when the actual commit id\n            being tested is known, before the virtual environment is ready.\n\n    Returns:\n        Commit ids corresponding to content to test/compare.\n    \"\"\"\n    # Fetch content.\n    if pull_request_number is not None:\n        env = git_env_tools.fetch_github_pull_request(\n            destination_directory=destination_directory,\n            repository=repository,\n            pull_request_number=pull_request_number,\n            verbose=verbose)\n    else:\n        env = git_env_tools.fetch_local_files(\n            destination_directory=destination_directory,\n            verbose=verbose)\n\n    if commit_ids_known_callback is not None:\n        commit_ids_known_callback(env)\n\n    # Create virtual environment.\n    base_path = cast(str, env.destination_directory)\n    env_path = os.path.join(base_path, env_name)\n    req_path = os.path.join(base_path, 'requirements.txt')\n    req_path_2 = os.path.join(base_path,\n                              'dev_tools',\n                              'conf',\n                              'pip-list-dev-tools.txt')\n    create_virtual_env(venv_path=env_path,\n                       python_path=python_path,\n                       requirements_paths=[req_path, req_path_2],\n                       verbose=verbose)\n\n    return PreparedEnv(github_repo=env.repository,\n                       actual_commit_id=env.actual_commit_id,\n                       compare_commit_id=env.compare_commit_id,\n                       destination_directory=env.destination_directory,\n                       virtual_env_path=env_path)\n\n\ndef derive_temporary_python2_environment(\n        destination_directory: str,\n        python3_environment: PreparedEnv,\n        verbose: bool,\n        env_name: str = '.test_virtualenv_py2',\n        python_path: str = \"/usr/bin/python2.7\") -> PreparedEnv:\n    \"\"\"Creates a python 2.7 environment starting from a prepared python 3 one.\n\n    Args:\n        destination_directory: Where to put the python 2 environment.\n        python3_environment: The prepared environment to start from.\n        verbose: When set, more progress output is produced.\n        env_name: The name to use for the virtualenv directory.\n        python_path: The python binary to use.\n\n    Returns:\n        A description of the environment that was prepared.\n    \"\"\"\n\n    shutil.rmtree(destination_directory)\n    input_directory = cast(str, python3_environment.destination_directory)\n    os.chdir(input_directory)\n    conversion_script_path = os.path.join(\n        input_directory,\n        'dev_tools',\n        'python2.7-generate.sh')\n    shell_tools.run_cmd('bash',\n                        conversion_script_path,\n                        destination_directory,\n                        input_directory,\n                        python3_environment.virtual_env_path,\n                        out=sys.stderr)\n    os.chdir(destination_directory)\n\n    # Create virtual environment.\n    env_path = os.path.join(destination_directory, env_name)\n    # (These files are output by dev_tools/python2.7-generate.sh.)\n    req_path = os.path.join(destination_directory, 'requirements.txt')\n    req_path_2 = os.path.join(destination_directory, 'pip-list-test-tools.txt')\n    create_virtual_env(venv_path=env_path,\n                       python_path=python_path,\n                       requirements_paths=[req_path, req_path_2],\n                       verbose=verbose)\n\n    return PreparedEnv(github_repo=python3_environment.repository,\n                       actual_commit_id=python3_environment.actual_commit_id,\n                       compare_commit_id=python3_environment.compare_commit_id,\n                       destination_directory=destination_directory,\n                       virtual_env_path=env_path)\n", "path": "dev_tools/env_tools.py"}], "after_files": [{"content": "# Copyright 2018 The Cirq Developers\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport os\nimport shutil\nimport sys\nfrom typing import Optional, Iterable, Callable, cast\n\nfrom dev_tools import shell_tools, git_env_tools\nfrom dev_tools.github_repository import GithubRepository\nfrom dev_tools.prepared_env import PreparedEnv\n\n\ndef get_unhidden_ungenerated_python_files(directory: str) -> Iterable[str]:\n    \"\"\"Iterates through relevant python files within the given directory.\n\n    Args:\n        directory: The top-level directory to explore.\n\n    Yields:\n        File paths.\n    \"\"\"\n    for dirpath, dirnames, filenames in os.walk(directory, topdown=True):\n        if os.path.split(dirpath)[-1].startswith('.'):\n            dirnames.clear()\n            continue\n\n        for filename in filenames:\n            if filename.endswith('.py') and not filename.endswith('_pb2.py'):\n                yield os.path.join(dirpath, filename)\n\n\ndef create_virtual_env(venv_path: str,\n                       requirements_paths: Iterable[str],\n                       python_path: str,\n                       verbose: bool) -> None:\n    \"\"\"Creates a new virtual environment and then installs dependencies.\n\n    Args:\n        venv_path: Where to put the virtual environment's state.\n        requirements_paths: Location of requirements files to -r install.\n        python_path: The python binary to use.\n        verbose: When set, more progress output is produced.\n    \"\"\"\n    shell_tools.run_cmd('virtualenv',\n                        None if verbose else '--quiet',\n                        '-p',\n                        python_path,\n                        venv_path,\n                        out=sys.stderr)\n    pip_path = os.path.join(venv_path, 'bin', 'pip')\n    for req_path in requirements_paths:\n        shell_tools.run_cmd(pip_path,\n                            'install',\n                            None if verbose else '--quiet',\n                            '-r',\n                            req_path,\n                            out=sys.stderr)\n\n\ndef prepare_temporary_test_environment(\n        destination_directory: str,\n        repository: GithubRepository,\n        pull_request_number: Optional[int],\n        verbose: bool,\n        env_name: str = '.test_virtualenv',\n        python_path: str = '/usr/bin/python3.5',\n        commit_ids_known_callback: Callable[[PreparedEnv], None] = None\n) -> PreparedEnv:\n    \"\"\"Prepares a temporary test environment at the (existing empty) directory.\n\n    Args:\n        destination_directory: The location to put files. The caller is\n            responsible for deleting the directory, whether or not this method\n             succeeds or fails.\n        repository: The github repository to download content from, if a pull\n            request number is given.\n        pull_request_number: If set, test content is fetched from github.\n            Otherwise copies of local files are used.\n        verbose: When set, more progress output is produced.\n        env_name: The name to use for the virtual environment.\n        python_path: Location of the python binary to use within the\n            virtual environment.\n        commit_ids_known_callback: A function to call when the actual commit id\n            being tested is known, before the virtual environment is ready.\n\n    Returns:\n        Commit ids corresponding to content to test/compare.\n    \"\"\"\n    # Fetch content.\n    if pull_request_number is not None:\n        env = git_env_tools.fetch_github_pull_request(\n            destination_directory=destination_directory,\n            repository=repository,\n            pull_request_number=pull_request_number,\n            verbose=verbose)\n    else:\n        env = git_env_tools.fetch_local_files(\n            destination_directory=destination_directory,\n            verbose=verbose)\n\n    if commit_ids_known_callback is not None:\n        commit_ids_known_callback(env)\n\n    # Create virtual environment.\n    base_path = cast(str, env.destination_directory)\n    env_path = os.path.join(base_path, env_name)\n    req_path = os.path.join(base_path, 'requirements.txt')\n    dev_req_path = os.path.join(base_path,\n                                'dev_tools',\n                                'conf',\n                                'pip-list-dev-tools.txt')\n    contrib_req_path = os.path.join(base_path,\n                                    'cirq',\n                                    'contrib',\n                                    'contrib-requirements.txt')\n    rev_paths = [req_path, dev_req_path, contrib_req_path]\n    create_virtual_env(venv_path=env_path,\n                       python_path=python_path,\n                       requirements_paths=rev_paths,\n                       verbose=verbose)\n\n    return PreparedEnv(github_repo=env.repository,\n                       actual_commit_id=env.actual_commit_id,\n                       compare_commit_id=env.compare_commit_id,\n                       destination_directory=env.destination_directory,\n                       virtual_env_path=env_path)\n\n\ndef derive_temporary_python2_environment(\n        destination_directory: str,\n        python3_environment: PreparedEnv,\n        verbose: bool,\n        env_name: str = '.test_virtualenv_py2',\n        python_path: str = \"/usr/bin/python2.7\") -> PreparedEnv:\n    \"\"\"Creates a python 2.7 environment starting from a prepared python 3 one.\n\n    Args:\n        destination_directory: Where to put the python 2 environment.\n        python3_environment: The prepared environment to start from.\n        verbose: When set, more progress output is produced.\n        env_name: The name to use for the virtualenv directory.\n        python_path: The python binary to use.\n\n    Returns:\n        A description of the environment that was prepared.\n    \"\"\"\n\n    shutil.rmtree(destination_directory)\n    input_directory = cast(str, python3_environment.destination_directory)\n    os.chdir(input_directory)\n    conversion_script_path = os.path.join(\n        input_directory,\n        'dev_tools',\n        'python2.7-generate.sh')\n    shell_tools.run_cmd('bash',\n                        conversion_script_path,\n                        destination_directory,\n                        input_directory,\n                        python3_environment.virtual_env_path,\n                        out=sys.stderr)\n    os.chdir(destination_directory)\n\n    # Create virtual environment.\n    env_path = os.path.join(destination_directory, env_name)\n    # (These files are output by dev_tools/python2.7-generate.sh.)\n    req_path = os.path.join(destination_directory, 'requirements.txt')\n    dev_req_path = os.path.join(destination_directory,\n                                'pip-list-test-tools.txt')\n    contrib_req_path = os.path.join(destination_directory,\n                                    'cirq',\n                                    'contrib',\n                                    'contrib-requirements.txt')\n    req_paths = [req_path, dev_req_path, contrib_req_path]\n    create_virtual_env(venv_path=env_path,\n                       python_path=python_path,\n                       requirements_paths=req_paths,\n                       verbose=verbose)\n\n    return PreparedEnv(github_repo=python3_environment.repository,\n                       actual_commit_id=python3_environment.actual_commit_id,\n                       compare_commit_id=python3_environment.compare_commit_id,\n                       destination_directory=destination_directory,\n                       virtual_env_path=env_path)\n", "path": "dev_tools/env_tools.py"}]}