prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Python2.7 dependency issue
  *cfn-lint version: 0.29.4*
  
  Hi,
  
  When installing a project that has cfn-lint as a dependency ([moto](https://github.com/spulec/moto)) using Python2.7, I'm getting this error:
  ```
  Searching for networkx~=2.1
  Reading https://pypi.org/simple/networkx/
  ...
  Best match: networkx 2.4
  ...
  NetworkX 2.3+ requires Python 3.5 or later (2.7 detected).
               
  For Python 2.7, please install version 2.2 using:
  
  $ pip install 'networkx==2.2'
  ```
  
  It looks like this is due to incorrect usage of the ~= operator in setup.py:
  ```
  'networkx~=2.4;python_version>="3.5"',
  'networkx~=2.1;python_version<"3.5"'
  ```
  
  This semantic has the same outcome for both python versions - use any version that's 2.x, but lower than 3.x.
  IMO, this should say:
  ```
  'networkx~=2.4;python_version>="3.5"',
  'networkx<=2.2;python_version<"3.5"'
  ```
  NetworkX 2.2 is the latest version that supports Python2: https://networkx.github.io/documentation/networkx-2.2/news.html
  
  Happy to create a PR for this, if it's an acceptable change?
  
  --- 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 """
  2 Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3 SPDX-License-Identifier: MIT-0
  4 """
  5 import codecs
  6 import re
  7 from setuptools import find_packages
  8 from setuptools import setup
  9 
  10 
  11 def get_version(filename):
  12     with codecs.open(filename, 'r', 'utf-8') as fp:
  13         contents = fp.read()
  14     return re.search(r"__version__ = ['\"]([^'\"]+)['\"]", contents).group(1)
  15 
  16 
  17 version = get_version('src/cfnlint/version.py')
  18 
  19 
  20 with open('README.md') as f:
  21     readme = f.read()
  22 
  23 setup(
  24     name='cfn-lint',
  25     version=version,
  26     description=('Checks CloudFormation templates for practices and behaviour \
  27 that could potentially be improved'),
  28     long_description=readme,
  29     long_description_content_type="text/markdown",
  30     keywords='aws, lint',
  31     author='kddejong',
  32     author_email='kddejong@amazon.com',
  33     url='https://github.com/aws-cloudformation/cfn-python-lint',
  34     package_dir={'': 'src'},
  35     package_data={'cfnlint': [
  36         'data/CloudSpecs/*.json',
  37         'data/AdditionalSpecs/*.json',
  38         'data/Serverless/*.json',
  39         'data/ExtendedSpecs/all/*.json',
  40         'data/ExtendedSpecs/ap-northeast-1/*.json',
  41         'data/ExtendedSpecs/ap-northeast-2/*.json',
  42         'data/ExtendedSpecs/ap-northeast-3/*.json',
  43         'data/ExtendedSpecs/ap-south-1/*.json',
  44         'data/ExtendedSpecs/ap-southeast-1/*.json',
  45         'data/ExtendedSpecs/ap-southeast-2/*.json',
  46         'data/ExtendedSpecs/ca-central-1/*.json',
  47         'data/ExtendedSpecs/eu-central-1/*.json',
  48         'data/ExtendedSpecs/eu-north-1/*.json',
  49         'data/ExtendedSpecs/eu-west-1/*.json',
  50         'data/ExtendedSpecs/eu-west-2/*.json',
  51         'data/ExtendedSpecs/eu-west-3/*.json',
  52         'data/ExtendedSpecs/sa-east-1/*.json',
  53         'data/ExtendedSpecs/us-east-1/*.json',
  54         'data/ExtendedSpecs/us-east-2/*.json',
  55         'data/ExtendedSpecs/us-gov-east-1/*.json',
  56         'data/ExtendedSpecs/us-gov-west-1/*.json',
  57         'data/ExtendedSpecs/us-west-1/*.json',
  58         'data/ExtendedSpecs/us-west-2/*.json',
  59         'data/ExtendedSpecs/cn-north-1/*.json',
  60         'data/ExtendedSpecs/cn-northwest-1/*.json',
  61         'data/CfnLintCli/config/schema.json'
  62     ]},
  63     packages=find_packages('src'),
  64     zip_safe=False,
  65     install_requires=[
  66         'pyyaml<=5.2;python_version=="3.4"',
  67         'pyyaml;python_version!="3.4"',
  68         'six~=1.11',
  69         'aws-sam-translator>=1.21.0',
  70         'jsonpatch;python_version!="3.4"',
  71         'jsonpatch<=1.24;python_version=="3.4"',
  72         'jsonschema~=3.0',
  73         'pathlib2>=2.3.0;python_version<="3.4"',
  74         'importlib_resources~=1.0.2;python_version<"3.7"',
  75         'networkx~=2.4;python_version>="3.5"',
  76         'networkx~=2.1;python_version<"3.5"'
  77     ],
  78     python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
  79     entry_points={
  80         'console_scripts': [
  81             'cfn-lint = cfnlint.__main__:main'
  82         ]
  83     },
  84     license='MIT no attribution',
  85     test_suite="unittest",
  86     classifiers=[
  87         'Development Status :: 5 - Production/Stable',
  88         'Intended Audience :: Developers',
  89         'License :: OSI Approved :: MIT License',
  90         'Natural Language :: English',
  91         'Operating System :: OS Independent',
  92         'Programming Language :: Python :: 2',
  93         'Programming Language :: Python :: 2.7',
  94         'Programming Language :: Python :: 3',
  95         'Programming Language :: Python :: 3.4',
  96         'Programming Language :: Python :: 3.5',
  97         'Programming Language :: Python :: 3.6',
  98         'Programming Language :: Python :: 3.7',
  99         'Programming Language :: Python :: 3.8',
  100     ],
  101 )
  102
  ```
  --- 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
  @@ -73,7 +73,7 @@
           'pathlib2>=2.3.0;python_version<="3.4"',
           'importlib_resources~=1.0.2;python_version<"3.7"',
           'networkx~=2.4;python_version>="3.5"',
  -        'networkx~=2.1;python_version<"3.5"'
  +        'networkx<=2.2;python_version<"3.5"'
       ],
       python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
       entry_points={
  
verification_info: {"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -73,7 +73,7 @@\n         'pathlib2>=2.3.0;python_version<=\"3.4\"',\n         'importlib_resources~=1.0.2;python_version<\"3.7\"',\n         'networkx~=2.4;python_version>=\"3.5\"',\n-        'networkx~=2.1;python_version<\"3.5\"'\n+        'networkx<=2.2;python_version<\"3.5\"'\n     ],\n     python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',\n     entry_points={\n", "issue": "Python2.7 dependency issue\n*cfn-lint version: 0.29.4*\r\n\r\nHi,\r\n\r\nWhen installing a project that has cfn-lint as a dependency ([moto](https://github.com/spulec/moto)) using Python2.7, I'm getting this error:\r\n```\r\nSearching for networkx~=2.1\r\nReading https://pypi.org/simple/networkx/\r\n...\r\nBest match: networkx 2.4\r\n...\r\nNetworkX 2.3+ requires Python 3.5 or later (2.7 detected).\r\n             \r\nFor Python 2.7, please install version 2.2 using:\r\n\r\n$ pip install 'networkx==2.2'\r\n```\r\n\r\nIt looks like this is due to incorrect usage of the ~= operator in setup.py:\r\n```\r\n'networkx~=2.4;python_version>=\"3.5\"',\r\n'networkx~=2.1;python_version<\"3.5\"'\r\n```\r\n\r\nThis semantic has the same outcome for both python versions - use any version that's 2.x, but lower than 3.x.\r\nIMO, this should say:\r\n```\r\n'networkx~=2.4;python_version>=\"3.5\"',\r\n'networkx<=2.2;python_version<\"3.5\"'\r\n```\r\nNetworkX 2.2 is the latest version that supports Python2: https://networkx.github.io/documentation/networkx-2.2/news.html\r\n\r\nHappy to create a PR for this, if it's an acceptable change?\n", "before_files": [{"content": "\"\"\"\nCopyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: MIT-0\n\"\"\"\nimport codecs\nimport re\nfrom setuptools import find_packages\nfrom setuptools import setup\n\n\ndef get_version(filename):\n    with codecs.open(filename, 'r', 'utf-8') as fp:\n        contents = fp.read()\n    return re.search(r\"__version__ = ['\\\"]([^'\\\"]+)['\\\"]\", contents).group(1)\n\n\nversion = get_version('src/cfnlint/version.py')\n\n\nwith open('README.md') as f:\n    readme = f.read()\n\nsetup(\n    name='cfn-lint',\n    version=version,\n    description=('Checks CloudFormation templates for practices and behaviour \\\nthat could potentially be improved'),\n    long_description=readme,\n    long_description_content_type=\"text/markdown\",\n    keywords='aws, lint',\n    author='kddejong',\n    author_email='kddejong@amazon.com',\n    url='https://github.com/aws-cloudformation/cfn-python-lint',\n    package_dir={'': 'src'},\n    package_data={'cfnlint': [\n        'data/CloudSpecs/*.json',\n        'data/AdditionalSpecs/*.json',\n        'data/Serverless/*.json',\n        'data/ExtendedSpecs/all/*.json',\n        'data/ExtendedSpecs/ap-northeast-1/*.json',\n        'data/ExtendedSpecs/ap-northeast-2/*.json',\n        'data/ExtendedSpecs/ap-northeast-3/*.json',\n        'data/ExtendedSpecs/ap-south-1/*.json',\n        'data/ExtendedSpecs/ap-southeast-1/*.json',\n        'data/ExtendedSpecs/ap-southeast-2/*.json',\n        'data/ExtendedSpecs/ca-central-1/*.json',\n        'data/ExtendedSpecs/eu-central-1/*.json',\n        'data/ExtendedSpecs/eu-north-1/*.json',\n        'data/ExtendedSpecs/eu-west-1/*.json',\n        'data/ExtendedSpecs/eu-west-2/*.json',\n        'data/ExtendedSpecs/eu-west-3/*.json',\n        'data/ExtendedSpecs/sa-east-1/*.json',\n        'data/ExtendedSpecs/us-east-1/*.json',\n        'data/ExtendedSpecs/us-east-2/*.json',\n        'data/ExtendedSpecs/us-gov-east-1/*.json',\n        'data/ExtendedSpecs/us-gov-west-1/*.json',\n        'data/ExtendedSpecs/us-west-1/*.json',\n        'data/ExtendedSpecs/us-west-2/*.json',\n        'data/ExtendedSpecs/cn-north-1/*.json',\n        'data/ExtendedSpecs/cn-northwest-1/*.json',\n        'data/CfnLintCli/config/schema.json'\n    ]},\n    packages=find_packages('src'),\n    zip_safe=False,\n    install_requires=[\n        'pyyaml<=5.2;python_version==\"3.4\"',\n        'pyyaml;python_version!=\"3.4\"',\n        'six~=1.11',\n        'aws-sam-translator>=1.21.0',\n        'jsonpatch;python_version!=\"3.4\"',\n        'jsonpatch<=1.24;python_version==\"3.4\"',\n        'jsonschema~=3.0',\n        'pathlib2>=2.3.0;python_version<=\"3.4\"',\n        'importlib_resources~=1.0.2;python_version<\"3.7\"',\n        'networkx~=2.4;python_version>=\"3.5\"',\n        'networkx~=2.1;python_version<\"3.5\"'\n    ],\n    python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',\n    entry_points={\n        'console_scripts': [\n            'cfn-lint = cfnlint.__main__:main'\n        ]\n    },\n    license='MIT no attribution',\n    test_suite=\"unittest\",\n    classifiers=[\n        'Development Status :: 5 - Production/Stable',\n        'Intended Audience :: Developers',\n        'License :: OSI Approved :: MIT License',\n        'Natural Language :: English',\n        'Operating System :: OS Independent',\n        'Programming Language :: Python :: 2',\n        'Programming Language :: Python :: 2.7',\n        'Programming Language :: Python :: 3',\n        'Programming Language :: Python :: 3.4',\n        'Programming Language :: Python :: 3.5',\n        'Programming Language :: Python :: 3.6',\n        'Programming Language :: Python :: 3.7',\n        'Programming Language :: Python :: 3.8',\n    ],\n)\n", "path": "setup.py"}], "after_files": [{"content": "\"\"\"\nCopyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: MIT-0\n\"\"\"\nimport codecs\nimport re\nfrom setuptools import find_packages\nfrom setuptools import setup\n\n\ndef get_version(filename):\n    with codecs.open(filename, 'r', 'utf-8') as fp:\n        contents = fp.read()\n    return re.search(r\"__version__ = ['\\\"]([^'\\\"]+)['\\\"]\", contents).group(1)\n\n\nversion = get_version('src/cfnlint/version.py')\n\n\nwith open('README.md') as f:\n    readme = f.read()\n\nsetup(\n    name='cfn-lint',\n    version=version,\n    description=('Checks CloudFormation templates for practices and behaviour \\\nthat could potentially be improved'),\n    long_description=readme,\n    long_description_content_type=\"text/markdown\",\n    keywords='aws, lint',\n    author='kddejong',\n    author_email='kddejong@amazon.com',\n    url='https://github.com/aws-cloudformation/cfn-python-lint',\n    package_dir={'': 'src'},\n    package_data={'cfnlint': [\n        'data/CloudSpecs/*.json',\n        'data/AdditionalSpecs/*.json',\n        'data/Serverless/*.json',\n        'data/ExtendedSpecs/all/*.json',\n        'data/ExtendedSpecs/ap-northeast-1/*.json',\n        'data/ExtendedSpecs/ap-northeast-2/*.json',\n        'data/ExtendedSpecs/ap-northeast-3/*.json',\n        'data/ExtendedSpecs/ap-south-1/*.json',\n        'data/ExtendedSpecs/ap-southeast-1/*.json',\n        'data/ExtendedSpecs/ap-southeast-2/*.json',\n        'data/ExtendedSpecs/ca-central-1/*.json',\n        'data/ExtendedSpecs/eu-central-1/*.json',\n        'data/ExtendedSpecs/eu-north-1/*.json',\n        'data/ExtendedSpecs/eu-west-1/*.json',\n        'data/ExtendedSpecs/eu-west-2/*.json',\n        'data/ExtendedSpecs/eu-west-3/*.json',\n        'data/ExtendedSpecs/sa-east-1/*.json',\n        'data/ExtendedSpecs/us-east-1/*.json',\n        'data/ExtendedSpecs/us-east-2/*.json',\n        'data/ExtendedSpecs/us-gov-east-1/*.json',\n        'data/ExtendedSpecs/us-gov-west-1/*.json',\n        'data/ExtendedSpecs/us-west-1/*.json',\n        'data/ExtendedSpecs/us-west-2/*.json',\n        'data/ExtendedSpecs/cn-north-1/*.json',\n        'data/ExtendedSpecs/cn-northwest-1/*.json',\n        'data/CfnLintCli/config/schema.json'\n    ]},\n    packages=find_packages('src'),\n    zip_safe=False,\n    install_requires=[\n        'pyyaml<=5.2;python_version==\"3.4\"',\n        'pyyaml;python_version!=\"3.4\"',\n        'six~=1.11',\n        'aws-sam-translator>=1.21.0',\n        'jsonpatch;python_version!=\"3.4\"',\n        'jsonpatch<=1.24;python_version==\"3.4\"',\n        'jsonschema~=3.0',\n        'pathlib2>=2.3.0;python_version<=\"3.4\"',\n        'importlib_resources~=1.0.2;python_version<\"3.7\"',\n        'networkx~=2.4;python_version>=\"3.5\"',\n        'networkx<=2.2;python_version<\"3.5\"'\n    ],\n    python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',\n    entry_points={\n        'console_scripts': [\n            'cfn-lint = cfnlint.__main__:main'\n        ]\n    },\n    license='MIT no attribution',\n    test_suite=\"unittest\",\n    classifiers=[\n        'Development Status :: 5 - Production/Stable',\n        'Intended Audience :: Developers',\n        'License :: OSI Approved :: MIT License',\n        'Natural Language :: English',\n        'Operating System :: OS Independent',\n        'Programming Language :: Python :: 2',\n        'Programming Language :: Python :: 2.7',\n        'Programming Language :: Python :: 3',\n        'Programming Language :: Python :: 3.4',\n        'Programming Language :: Python :: 3.5',\n        'Programming Language :: Python :: 3.6',\n        'Programming Language :: Python :: 3.7',\n        'Programming Language :: Python :: 3.8',\n    ],\n)\n", "path": "setup.py"}]}