prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  tf2.2-rc1 gast requirement
  Hi,
  
  gpflow 2.0.0-rc1 has gast requirement 0.2.2.
  
  TensorFlow has gast requirement 0.3.3 from 2.2-rc1, which is incompatible with gpflow requirement.
  
  Best Regards,
  
  Marco
  
  --- 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 #!/usr/bin/env python
  2 # -*- coding: utf-8 -*-
  3 
  4 # pylint: skip-file
  5 
  6 import os
  7 import sys
  8 from pathlib import Path
  9 
  10 from pkg_resources import parse_version
  11 from setuptools import find_packages, setup
  12 
  13 is_py37 = sys.version_info.major == 3 and sys.version_info.minor == 7
  14 on_rtd = os.environ.get('READTHEDOCS', None) == 'True'  # copied from the docs
  15 
  16 # Dependencies of GPflow
  17 requirements = [
  18     'numpy>=1.10.0',
  19     'scipy>=0.18.0',
  20     'multipledispatch>=0.4.9',
  21     'tabulate',
  22     'gast==0.2.2',
  23 ]
  24 
  25 if not is_py37:
  26     requirements.append("dataclasses")
  27 
  28 if not on_rtd:
  29     requirements.append("tensorflow-probability>=0.9")
  30 
  31 min_tf_version = '2.1.0'
  32 tf_cpu = 'tensorflow'
  33 tf_gpu = 'tensorflow-gpu'
  34 
  35 # Only detect TF if not installed or outdated. If not, do not do not list as
  36 # requirement to avoid installing over e.g. tensorflow-gpu
  37 # To avoid this, rely on importing rather than the package name (like pip).
  38 
  39 try:
  40     # If tf not installed, import raises ImportError
  41     import tensorflow as tf
  42     if parse_version(tf.__version__) < parse_version(min_tf_version):
  43         # TF pre-installed, but below the minimum required version
  44         raise DeprecationWarning("TensorFlow version below minimum requirement")
  45 except (ImportError, DeprecationWarning):
  46     # Add TensorFlow to dependencies to trigger installation/update
  47     if not on_rtd:
  48         # Do not add TF if we are installing GPflow on readthedocs
  49         requirements.append(tf_cpu)
  50 
  51 with open(str(Path(".", "VERSION").absolute())) as version_file:
  52     version = version_file.read().strip()
  53 
  54 packages = find_packages('.', exclude=["tests"])
  55 
  56 setup(name='gpflow',
  57       version=version,
  58       author="James Hensman, Alex Matthews",
  59       author_email="james.hensman@gmail.com",
  60       description="Gaussian process methods in TensorFlow",
  61       license="Apache License 2.0",
  62       keywords="machine-learning gaussian-processes kernels tensorflow",
  63       url="http://github.com/GPflow/GPflow",
  64       packages=packages,
  65       include_package_data=True,
  66       install_requires=requirements,
  67       extras_require={'Tensorflow with GPU': [tf_gpu]},
  68       python_requires=">=3.6",
  69       classifiers=[
  70           'License :: OSI Approved :: Apache Software License',
  71           'Natural Language :: English',
  72           'Operating System :: MacOS :: MacOS X',
  73           'Operating System :: Microsoft :: Windows',
  74           'Operating System :: POSIX :: Linux',
  75           'Programming Language :: Python :: 3.6',
  76           'Topic :: Scientific/Engineering :: Artificial Intelligence'
  77       ])
  78
  ```
  --- 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
  @@ -18,8 +18,7 @@
       'numpy>=1.10.0',
       'scipy>=0.18.0',
       'multipledispatch>=0.4.9',
  -    'tabulate',
  -    'gast==0.2.2',
  +    'tabulate'
   ]
   
   if not is_py37:
  @@ -32,6 +31,22 @@
   tf_cpu = 'tensorflow'
   tf_gpu = 'tensorflow-gpu'
   
  +
  +# for latest_version() [see https://github.com/GPflow/GPflow/issues/1348]:
  +def latest_version(package_name):
  +    import json
  +    from urllib import request
  +    import re
  +
  +    url = f"https://pypi.python.org/pypi/{package_name}/json"
  +    data = json.load(request.urlopen(url))
  +    # filter out rc and beta releases and, more generally, any releases that
  +    # do not contain exclusively numbers and dots.
  +    versions = [parse_version(v) for v in data["releases"].keys() if re.match("^[0-9.]+$", v)]  
  +    versions.sort()
  +    return versions[-1]  # return latest version
  +
  +
   # Only detect TF if not installed or outdated. If not, do not do not list as
   # requirement to avoid installing over e.g. tensorflow-gpu
   # To avoid this, rely on importing rather than the package name (like pip).
  @@ -47,6 +62,9 @@
       if not on_rtd:
           # Do not add TF if we are installing GPflow on readthedocs
           requirements.append(tf_cpu)
  +        gast_requirement = 'gast>=0.2.2,<0.3' if latest_version('tensorflow') < parse_version('2.2') else 'gast>=0.3.3'
  +        requirements.append(gast_requirement)
  +        
   
   with open(str(Path(".", "VERSION").absolute())) as version_file:
       version = version_file.read().strip()
  
verification_info: {"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -18,8 +18,7 @@\n     'numpy>=1.10.0',\n     'scipy>=0.18.0',\n     'multipledispatch>=0.4.9',\n-    'tabulate',\n-    'gast==0.2.2',\n+    'tabulate'\n ]\n \n if not is_py37:\n@@ -32,6 +31,22 @@\n tf_cpu = 'tensorflow'\n tf_gpu = 'tensorflow-gpu'\n \n+\n+# for latest_version() [see https://github.com/GPflow/GPflow/issues/1348]:\n+def latest_version(package_name):\n+    import json\n+    from urllib import request\n+    import re\n+\n+    url = f\"https://pypi.python.org/pypi/{package_name}/json\"\n+    data = json.load(request.urlopen(url))\n+    # filter out rc and beta releases and, more generally, any releases that\n+    # do not contain exclusively numbers and dots.\n+    versions = [parse_version(v) for v in data[\"releases\"].keys() if re.match(\"^[0-9.]+$\", v)]  \n+    versions.sort()\n+    return versions[-1]  # return latest version\n+\n+\n # Only detect TF if not installed or outdated. If not, do not do not list as\n # requirement to avoid installing over e.g. tensorflow-gpu\n # To avoid this, rely on importing rather than the package name (like pip).\n@@ -47,6 +62,9 @@\n     if not on_rtd:\n         # Do not add TF if we are installing GPflow on readthedocs\n         requirements.append(tf_cpu)\n+        gast_requirement = 'gast>=0.2.2,<0.3' if latest_version('tensorflow') < parse_version('2.2') else 'gast>=0.3.3'\n+        requirements.append(gast_requirement)\n+        \n \n with open(str(Path(\".\", \"VERSION\").absolute())) as version_file:\n     version = version_file.read().strip()\n", "issue": "tf2.2-rc1 gast requirement\nHi,\r\n\r\ngpflow 2.0.0-rc1 has gast requirement 0.2.2.\r\n\r\nTensorFlow has gast requirement 0.3.3 from 2.2-rc1, which is incompatible with gpflow requirement.\r\n\r\nBest Regards,\r\n\r\nMarco\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# pylint: skip-file\n\nimport os\nimport sys\nfrom pathlib import Path\n\nfrom pkg_resources import parse_version\nfrom setuptools import find_packages, setup\n\nis_py37 = sys.version_info.major == 3 and sys.version_info.minor == 7\non_rtd = os.environ.get('READTHEDOCS', None) == 'True'  # copied from the docs\n\n# Dependencies of GPflow\nrequirements = [\n    'numpy>=1.10.0',\n    'scipy>=0.18.0',\n    'multipledispatch>=0.4.9',\n    'tabulate',\n    'gast==0.2.2',\n]\n\nif not is_py37:\n    requirements.append(\"dataclasses\")\n\nif not on_rtd:\n    requirements.append(\"tensorflow-probability>=0.9\")\n\nmin_tf_version = '2.1.0'\ntf_cpu = 'tensorflow'\ntf_gpu = 'tensorflow-gpu'\n\n# Only detect TF if not installed or outdated. If not, do not do not list as\n# requirement to avoid installing over e.g. tensorflow-gpu\n# To avoid this, rely on importing rather than the package name (like pip).\n\ntry:\n    # If tf not installed, import raises ImportError\n    import tensorflow as tf\n    if parse_version(tf.__version__) < parse_version(min_tf_version):\n        # TF pre-installed, but below the minimum required version\n        raise DeprecationWarning(\"TensorFlow version below minimum requirement\")\nexcept (ImportError, DeprecationWarning):\n    # Add TensorFlow to dependencies to trigger installation/update\n    if not on_rtd:\n        # Do not add TF if we are installing GPflow on readthedocs\n        requirements.append(tf_cpu)\n\nwith open(str(Path(\".\", \"VERSION\").absolute())) as version_file:\n    version = version_file.read().strip()\n\npackages = find_packages('.', exclude=[\"tests\"])\n\nsetup(name='gpflow',\n      version=version,\n      author=\"James Hensman, Alex Matthews\",\n      author_email=\"james.hensman@gmail.com\",\n      description=\"Gaussian process methods in TensorFlow\",\n      license=\"Apache License 2.0\",\n      keywords=\"machine-learning gaussian-processes kernels tensorflow\",\n      url=\"http://github.com/GPflow/GPflow\",\n      packages=packages,\n      include_package_data=True,\n      install_requires=requirements,\n      extras_require={'Tensorflow with GPU': [tf_gpu]},\n      python_requires=\">=3.6\",\n      classifiers=[\n          'License :: OSI Approved :: Apache Software License',\n          'Natural Language :: English',\n          'Operating System :: MacOS :: MacOS X',\n          'Operating System :: Microsoft :: Windows',\n          'Operating System :: POSIX :: Linux',\n          'Programming Language :: Python :: 3.6',\n          'Topic :: Scientific/Engineering :: Artificial Intelligence'\n      ])\n", "path": "setup.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# pylint: skip-file\n\nimport os\nimport sys\nfrom pathlib import Path\n\nfrom pkg_resources import parse_version\nfrom setuptools import find_packages, setup\n\nis_py37 = sys.version_info.major == 3 and sys.version_info.minor == 7\non_rtd = os.environ.get('READTHEDOCS', None) == 'True'  # copied from the docs\n\n# Dependencies of GPflow\nrequirements = [\n    'numpy>=1.10.0',\n    'scipy>=0.18.0',\n    'multipledispatch>=0.4.9',\n    'tabulate'\n]\n\nif not is_py37:\n    requirements.append(\"dataclasses\")\n\nif not on_rtd:\n    requirements.append(\"tensorflow-probability>=0.9\")\n\nmin_tf_version = '2.1.0'\ntf_cpu = 'tensorflow'\ntf_gpu = 'tensorflow-gpu'\n\n\n# for latest_version() [see https://github.com/GPflow/GPflow/issues/1348]:\ndef latest_version(package_name):\n    import json\n    from urllib import request\n    import re\n\n    url = f\"https://pypi.python.org/pypi/{package_name}/json\"\n    data = json.load(request.urlopen(url))\n    # filter out rc and beta releases and, more generally, any releases that\n    # do not contain exclusively numbers and dots.\n    versions = [parse_version(v) for v in data[\"releases\"].keys() if re.match(\"^[0-9.]+$\", v)]  \n    versions.sort()\n    return versions[-1]  # return latest version\n\n\n# Only detect TF if not installed or outdated. If not, do not do not list as\n# requirement to avoid installing over e.g. tensorflow-gpu\n# To avoid this, rely on importing rather than the package name (like pip).\n\ntry:\n    # If tf not installed, import raises ImportError\n    import tensorflow as tf\n    if parse_version(tf.__version__) < parse_version(min_tf_version):\n        # TF pre-installed, but below the minimum required version\n        raise DeprecationWarning(\"TensorFlow version below minimum requirement\")\nexcept (ImportError, DeprecationWarning):\n    # Add TensorFlow to dependencies to trigger installation/update\n    if not on_rtd:\n        # Do not add TF if we are installing GPflow on readthedocs\n        requirements.append(tf_cpu)\n        gast_requirement = 'gast>=0.2.2,<0.3' if latest_version('tensorflow') < parse_version('2.2') else 'gast>=0.3.3'\n        requirements.append(gast_requirement)\n        \n\nwith open(str(Path(\".\", \"VERSION\").absolute())) as version_file:\n    version = version_file.read().strip()\n\npackages = find_packages('.', exclude=[\"tests\"])\n\nsetup(name='gpflow',\n      version=version,\n      author=\"James Hensman, Alex Matthews\",\n      author_email=\"james.hensman@gmail.com\",\n      description=\"Gaussian process methods in TensorFlow\",\n      license=\"Apache License 2.0\",\n      keywords=\"machine-learning gaussian-processes kernels tensorflow\",\n      url=\"http://github.com/GPflow/GPflow\",\n      packages=packages,\n      include_package_data=True,\n      install_requires=requirements,\n      extras_require={'Tensorflow with GPU': [tf_gpu]},\n      python_requires=\">=3.6\",\n      classifiers=[\n          'License :: OSI Approved :: Apache Software License',\n          'Natural Language :: English',\n          'Operating System :: MacOS :: MacOS X',\n          'Operating System :: Microsoft :: Windows',\n          'Operating System :: POSIX :: Linux',\n          'Programming Language :: Python :: 3.6',\n          'Topic :: Scientific/Engineering :: Artificial Intelligence'\n      ])\n", "path": "setup.py"}]}