prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Prevent installing both cirq and cirq-unstable.
  **Is your feature request related to a use case or problem? Please describe.**
  
  If `cirq-unstable` is installed in a virtualenv and you `pip install cirq`, the virtualenv gets into a bad state. This is because they are different packages with separate metadata, but they put the python code in the same location in a `cirq` folder in site-packages. So pip thinks both are installed but in fact only the most-recently installed package is "active".
  
  If you try to fix such a situation by uninstalling one package, the code gets removed but pip still thinks the other package is installed. The other package is now in a broken state (can't be imported, etc.). The only way to recover is to uninstall _both_ packages and then install one of them again.
  
  **Describe the solution you'd like**
  
  I'd like `pip install cirq` to fail if `cirq-unstable` is installed, and vice-versa. I did a quick glance at setuptools docs to see if there is some way to specify packages that _must not_ be present, but I couldn't see anything. It also doesn't seem to work to add a package requirement like `cirq != *`. I'm not sure if there's any other mechanism we can use to accomplish this.
  
  **What is the urgency from your perspective for this issue? Is it blocking important work?**
  
  P3 - I'm not really blocked by it, it is an idea I'd like to discuss / suggestion based on principle 
  
  We have internal workarounds for this to try to keep people's virtualenvs in a good state if they accidentally install both versions, but it'd be great if we could prevent the problem from happening at all.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `setup.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 io
  16 import os
  17 from setuptools import find_packages, setup
  18 
  19 # This reads the __version__ variable from cirq/_version.py
  20 __version__ = ''
  21 exec(open('cirq/_version.py').read())
  22 
  23 name = 'cirq'
  24 
  25 description = (
  26     'A framework for creating, editing, and invoking '
  27     'Noisy Intermediate Scale Quantum (NISQ) circuits.'
  28 )
  29 
  30 # README file as long_description.
  31 long_description = io.open('README.rst', encoding='utf-8').read()
  32 
  33 # If CIRQ_UNSTABLE_VERSION is set then we use cirq-unstable as the name of the package
  34 # and update the version to this value.
  35 if 'CIRQ_UNSTABLE_VERSION' in os.environ:
  36     name = 'cirq-unstable'
  37     __version__ = os.environ['CIRQ_UNSTABLE_VERSION']
  38     long_description = (
  39         "**This is a development version of Cirq and may be "
  40         "unstable.**\n\n**For the latest stable release of Cirq "
  41         "see**\n`here <https://pypi.org/project/cirq>`__.\n\n" + long_description
  42     )
  43 
  44 # Read in requirements
  45 requirements = open('requirements.txt').readlines()
  46 requirements = [r.strip() for r in requirements]
  47 contrib_requirements = open('cirq/contrib/contrib-requirements.txt').readlines()
  48 contrib_requirements = [r.strip() for r in contrib_requirements]
  49 dev_requirements = open('dev_tools/conf/pip-list-dev-tools.txt').readlines()
  50 dev_requirements = [r.strip() for r in dev_requirements]
  51 
  52 cirq_packages = ['cirq'] + ['cirq.' + package for package in find_packages(where='cirq')]
  53 
  54 # Sanity check
  55 assert __version__, 'Version string cannot be empty'
  56 
  57 setup(
  58     name=name,
  59     version=__version__,
  60     url='http://github.com/quantumlib/cirq',
  61     author='The Cirq Developers',
  62     author_email='cirq@googlegroups.com',
  63     python_requires=('>=3.6.0'),
  64     install_requires=requirements,
  65     extras_require={
  66         'contrib': contrib_requirements,
  67         'dev_env': dev_requirements + contrib_requirements,
  68     },
  69     license='Apache 2',
  70     description=description,
  71     long_description=long_description,
  72     packages=cirq_packages,
  73     package_data={
  74         'cirq': ['py.typed'],
  75         'cirq.google.api.v1': ['*.proto', '*.pyi'],
  76         'cirq.google.api.v2': ['*.proto', '*.pyi'],
  77         'cirq.protocols.json_test_data': ['*'],
  78     },
  79 )
  80
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/setup.py b/setup.py
  --- a/setup.py
  +++ b/setup.py
  @@ -30,11 +30,13 @@
   # README file as long_description.
   long_description = io.open('README.rst', encoding='utf-8').read()
   
  -# If CIRQ_UNSTABLE_VERSION is set then we use cirq-unstable as the name of the package
  -# and update the version to this value.
  -if 'CIRQ_UNSTABLE_VERSION' in os.environ:
  -    name = 'cirq-unstable'
  -    __version__ = os.environ['CIRQ_UNSTABLE_VERSION']
  +# If CIRQ_PRE_RELEASE_VERSION is set then we update the version to this value.
  +# It is assumed that it ends with one of `.devN`, `.aN`, `.bN`, `.rcN` and hence
  +# it will be a pre-release version on PyPi. See
  +# https://packaging.python.org/guides/distributing-packages-using-setuptools/#pre-release-versioning
  +# for more details.
  +if 'CIRQ_PRE_RELEASE_VERSION' in os.environ:
  +    __version__ = os.environ['CIRQ_PRE_RELEASE_VERSION']
       long_description = (
           "**This is a development version of Cirq and may be "
           "unstable.**\n\n**For the latest stable release of Cirq "
  
verification_info: {"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -30,11 +30,13 @@\n # README file as long_description.\n long_description = io.open('README.rst', encoding='utf-8').read()\n \n-# If CIRQ_UNSTABLE_VERSION is set then we use cirq-unstable as the name of the package\n-# and update the version to this value.\n-if 'CIRQ_UNSTABLE_VERSION' in os.environ:\n-    name = 'cirq-unstable'\n-    __version__ = os.environ['CIRQ_UNSTABLE_VERSION']\n+# If CIRQ_PRE_RELEASE_VERSION is set then we update the version to this value.\n+# It is assumed that it ends with one of `.devN`, `.aN`, `.bN`, `.rcN` and hence\n+# it will be a pre-release version on PyPi. See\n+# https://packaging.python.org/guides/distributing-packages-using-setuptools/#pre-release-versioning\n+# for more details.\n+if 'CIRQ_PRE_RELEASE_VERSION' in os.environ:\n+    __version__ = os.environ['CIRQ_PRE_RELEASE_VERSION']\n     long_description = (\n         \"**This is a development version of Cirq and may be \"\n         \"unstable.**\\n\\n**For the latest stable release of Cirq \"\n", "issue": "Prevent installing both cirq and cirq-unstable.\n**Is your feature request related to a use case or problem? Please describe.**\r\n\r\nIf `cirq-unstable` is installed in a virtualenv and you `pip install cirq`, the virtualenv gets into a bad state. This is because they are different packages with separate metadata, but they put the python code in the same location in a `cirq` folder in site-packages. So pip thinks both are installed but in fact only the most-recently installed package is \"active\".\r\n\r\nIf you try to fix such a situation by uninstalling one package, the code gets removed but pip still thinks the other package is installed. The other package is now in a broken state (can't be imported, etc.). The only way to recover is to uninstall _both_ packages and then install one of them again.\r\n\r\n**Describe the solution you'd like**\r\n\r\nI'd like `pip install cirq` to fail if `cirq-unstable` is installed, and vice-versa. I did a quick glance at setuptools docs to see if there is some way to specify packages that _must not_ be present, but I couldn't see anything. It also doesn't seem to work to add a package requirement like `cirq != *`. I'm not sure if there's any other mechanism we can use to accomplish this.\r\n\r\n**What is the urgency from your perspective for this issue? Is it blocking important work?**\r\n\r\nP3 - I'm not really blocked by it, it is an idea I'd like to discuss / suggestion based on principle \r\n\r\nWe have internal workarounds for this to try to keep people's virtualenvs in a good state if they accidentally install both versions, but it'd be great if we could prevent the problem from happening at all.\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 io\nimport os\nfrom setuptools import find_packages, setup\n\n# This reads the __version__ variable from cirq/_version.py\n__version__ = ''\nexec(open('cirq/_version.py').read())\n\nname = 'cirq'\n\ndescription = (\n    'A framework for creating, editing, and invoking '\n    'Noisy Intermediate Scale Quantum (NISQ) circuits.'\n)\n\n# README file as long_description.\nlong_description = io.open('README.rst', encoding='utf-8').read()\n\n# If CIRQ_UNSTABLE_VERSION is set then we use cirq-unstable as the name of the package\n# and update the version to this value.\nif 'CIRQ_UNSTABLE_VERSION' in os.environ:\n    name = 'cirq-unstable'\n    __version__ = os.environ['CIRQ_UNSTABLE_VERSION']\n    long_description = (\n        \"**This is a development version of Cirq and may be \"\n        \"unstable.**\\n\\n**For the latest stable release of Cirq \"\n        \"see**\\n`here <https://pypi.org/project/cirq>`__.\\n\\n\" + long_description\n    )\n\n# Read in requirements\nrequirements = open('requirements.txt').readlines()\nrequirements = [r.strip() for r in requirements]\ncontrib_requirements = open('cirq/contrib/contrib-requirements.txt').readlines()\ncontrib_requirements = [r.strip() for r in contrib_requirements]\ndev_requirements = open('dev_tools/conf/pip-list-dev-tools.txt').readlines()\ndev_requirements = [r.strip() for r in dev_requirements]\n\ncirq_packages = ['cirq'] + ['cirq.' + package for package in find_packages(where='cirq')]\n\n# Sanity check\nassert __version__, 'Version string cannot be empty'\n\nsetup(\n    name=name,\n    version=__version__,\n    url='http://github.com/quantumlib/cirq',\n    author='The Cirq Developers',\n    author_email='cirq@googlegroups.com',\n    python_requires=('>=3.6.0'),\n    install_requires=requirements,\n    extras_require={\n        'contrib': contrib_requirements,\n        'dev_env': dev_requirements + contrib_requirements,\n    },\n    license='Apache 2',\n    description=description,\n    long_description=long_description,\n    packages=cirq_packages,\n    package_data={\n        'cirq': ['py.typed'],\n        'cirq.google.api.v1': ['*.proto', '*.pyi'],\n        'cirq.google.api.v2': ['*.proto', '*.pyi'],\n        'cirq.protocols.json_test_data': ['*'],\n    },\n)\n", "path": "setup.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 io\nimport os\nfrom setuptools import find_packages, setup\n\n# This reads the __version__ variable from cirq/_version.py\n__version__ = ''\nexec(open('cirq/_version.py').read())\n\nname = 'cirq'\n\ndescription = (\n    'A framework for creating, editing, and invoking '\n    'Noisy Intermediate Scale Quantum (NISQ) circuits.'\n)\n\n# README file as long_description.\nlong_description = io.open('README.rst', encoding='utf-8').read()\n\n# If CIRQ_PRE_RELEASE_VERSION is set then we update the version to this value.\n# It is assumed that it ends with one of `.devN`, `.aN`, `.bN`, `.rcN` and hence\n# it will be a pre-release version on PyPi. See\n# https://packaging.python.org/guides/distributing-packages-using-setuptools/#pre-release-versioning\n# for more details.\nif 'CIRQ_PRE_RELEASE_VERSION' in os.environ:\n    __version__ = os.environ['CIRQ_PRE_RELEASE_VERSION']\n    long_description = (\n        \"**This is a development version of Cirq and may be \"\n        \"unstable.**\\n\\n**For the latest stable release of Cirq \"\n        \"see**\\n`here <https://pypi.org/project/cirq>`__.\\n\\n\" + long_description\n    )\n\n# Read in requirements\nrequirements = open('requirements.txt').readlines()\nrequirements = [r.strip() for r in requirements]\ncontrib_requirements = open('cirq/contrib/contrib-requirements.txt').readlines()\ncontrib_requirements = [r.strip() for r in contrib_requirements]\ndev_requirements = open('dev_tools/conf/pip-list-dev-tools.txt').readlines()\ndev_requirements = [r.strip() for r in dev_requirements]\n\ncirq_packages = ['cirq'] + ['cirq.' + package for package in find_packages(where='cirq')]\n\n# Sanity check\nassert __version__, 'Version string cannot be empty'\n\nsetup(\n    name=name,\n    version=__version__,\n    url='http://github.com/quantumlib/cirq',\n    author='The Cirq Developers',\n    author_email='cirq@googlegroups.com',\n    python_requires=('>=3.6.0'),\n    install_requires=requirements,\n    extras_require={\n        'contrib': contrib_requirements,\n        'dev_env': dev_requirements + contrib_requirements,\n    },\n    license='Apache 2',\n    description=description,\n    long_description=long_description,\n    packages=cirq_packages,\n    package_data={\n        'cirq': ['py.typed'],\n        'cirq.google.api.v1': ['*.proto', '*.pyi'],\n        'cirq.google.api.v2': ['*.proto', '*.pyi'],\n        'cirq.protocols.json_test_data': ['*'],\n    },\n)\n", "path": "setup.py"}]}