We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Figure out how to fix docs build on rtd
It appears to be running into https://github.com/sphinx-doc/sphinx/issues/3976

--- 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 
3 # This file is dual licensed under the terms of the Apache License, Version
4 # 2.0, and the BSD License. See the LICENSE file in the root of this repository
5 # for complete details.
6 
7 from __future__ import absolute_import, division, print_function
8 
9 import os
10 import platform
11 import subprocess
12 import sys
13 from distutils.command.build import build
14 
15 import pkg_resources
16 
17 import setuptools
18 from setuptools import find_packages, setup
19 from setuptools.command.install import install
20 from setuptools.command.test import test
21 
22 
23 if (
24     pkg_resources.parse_version(setuptools.__version__) <
25     pkg_resources.parse_version("18.5")
26 ):
27     raise RuntimeError(
28         "cryptography requires setuptools 18.5 or newer, please upgrade to a "
29         "newer version of setuptools"
30     )
31 
32 base_dir = os.path.dirname(__file__)
33 src_dir = os.path.join(base_dir, "src")
34 
35 # When executing the setup.py, we need to be able to import ourselves, this
36 # means that we need to add the src/ directory to the sys.path.
37 sys.path.insert(0, src_dir)
38 
39 about = {}
40 with open(os.path.join(src_dir, "cryptography", "__about__.py")) as f:
41     exec(f.read(), about)
42 
43 
44 VECTORS_DEPENDENCY = "cryptography_vectors=={0}".format(about['__version__'])
45 
46 setup_requirements = []
47 
48 if platform.python_implementation() == "PyPy":
49     if sys.pypy_version_info < (5, 3):
50         raise RuntimeError(
51             "cryptography 1.9 is not compatible with PyPy < 5.3. Please "
52             "upgrade PyPy to use this library."
53         )
54 else:
55     setup_requirements.append("cffi>=1.7,!=1.11.3")
56 
57 test_requirements = [
58     "pytest>=3.2.1,!=3.3.0",
59     "pretend",
60     "iso8601",
61     "pytz",
62     "hypothesis>=1.11.4",
63 ]
64 
65 
66 # If there's no vectors locally that probably means we are in a tarball and
67 # need to go and get the matching vectors package from PyPi
68 if not os.path.exists(os.path.join(base_dir, "vectors/setup.py")):
69     test_requirements.append(VECTORS_DEPENDENCY)
70 
71 
72 class PyTest(test):
73     def finalize_options(self):
74         test.finalize_options(self)
75         self.test_args = []
76         self.test_suite = True
77 
78         # This means there's a vectors/ folder with the package in here.
79         # cd into it, install the vectors package and then refresh sys.path
80         if VECTORS_DEPENDENCY not in test_requirements:
81             subprocess.check_call(
82                 [sys.executable, "setup.py", "install"], cwd="vectors"
83             )
84             pkg_resources.get_distribution("cryptography_vectors").activate()
85 
86     def run_tests(self):
87         # Import here because in module scope the eggs are not loaded.
88         import pytest
89         test_args = [os.path.join(base_dir, "tests")]
90         errno = pytest.main(test_args)
91         sys.exit(errno)
92 
93 
94 def keywords_with_side_effects(argv):
95     """
96     Get a dictionary with setup keywords that (can) have side effects.
97 
98     :param argv: A list of strings with command line arguments.
99     :returns: A dictionary with keyword arguments for the ``setup()`` function.
100 
101     This setup.py script uses the setuptools 'setup_requires' feature because
102     this is required by the cffi package to compile extension modules. The
103     purpose of ``keywords_with_side_effects()`` is to avoid triggering the cffi
104     build process as a result of setup.py invocations that don't need the cffi
105     module to be built (setup.py serves the dual purpose of exposing package
106     metadata).
107 
108     All of the options listed by ``python setup.py --help`` that print
109     information should be recognized here. The commands ``clean``,
110     ``egg_info``, ``register``, ``sdist`` and ``upload`` are also recognized.
111     Any combination of these options and commands is also supported.
112 
113     This function was originally based on the `setup.py script`_ of SciPy (see
114     also the discussion in `pip issue #25`_).
115 
116     .. _pip issue #25: https://github.com/pypa/pip/issues/25
117     .. _setup.py script: https://github.com/scipy/scipy/blob/master/setup.py
118     """
119     no_setup_requires_arguments = (
120         '-h', '--help',
121         '-n', '--dry-run',
122         '-q', '--quiet',
123         '-v', '--verbose',
124         '-V', '--version',
125         '--author',
126         '--author-email',
127         '--classifiers',
128         '--contact',
129         '--contact-email',
130         '--description',
131         '--egg-base',
132         '--fullname',
133         '--help-commands',
134         '--keywords',
135         '--licence',
136         '--license',
137         '--long-description',
138         '--maintainer',
139         '--maintainer-email',
140         '--name',
141         '--no-user-cfg',
142         '--obsoletes',
143         '--platforms',
144         '--provides',
145         '--requires',
146         '--url',
147         'clean',
148         'egg_info',
149         'register',
150         'sdist',
151         'upload',
152     )
153 
154     def is_short_option(argument):
155         """Check whether a command line argument is a short option."""
156         return len(argument) >= 2 and argument[0] == '-' and argument[1] != '-'
157 
158     def expand_short_options(argument):
159         """Expand combined short options into canonical short options."""
160         return ('-' + char for char in argument[1:])
161 
162     def argument_without_setup_requirements(argv, i):
163         """Check whether a command line argument needs setup requirements."""
164         if argv[i] in no_setup_requires_arguments:
165             # Simple case: An argument which is either an option or a command
166             # which doesn't need setup requirements.
167             return True
168         elif (is_short_option(argv[i]) and
169               all(option in no_setup_requires_arguments
170                   for option in expand_short_options(argv[i]))):
171             # Not so simple case: Combined short options none of which need
172             # setup requirements.
173             return True
174         elif argv[i - 1:i] == ['--egg-base']:
175             # Tricky case: --egg-info takes an argument which should not make
176             # us use setup_requires (defeating the purpose of this code).
177             return True
178         else:
179             return False
180 
181     if all(argument_without_setup_requirements(argv, i)
182            for i in range(1, len(argv))):
183         return {
184             "cmdclass": {
185                 "build": DummyBuild,
186                 "install": DummyInstall,
187                 "test": DummyPyTest,
188             }
189         }
190     else:
191         cffi_modules = [
192             "src/_cffi_src/build_openssl.py:ffi",
193             "src/_cffi_src/build_constant_time.py:ffi",
194             "src/_cffi_src/build_padding.py:ffi",
195         ]
196 
197         return {
198             "setup_requires": setup_requirements,
199             "cmdclass": {
200                 "test": PyTest,
201             },
202             "cffi_modules": cffi_modules
203         }
204 
205 
206 setup_requires_error = ("Requested setup command that needs 'setup_requires' "
207                         "while command line arguments implied a side effect "
208                         "free command or option.")
209 
210 
211 class DummyBuild(build):
212     """
213     This class makes it very obvious when ``keywords_with_side_effects()`` has
214     incorrectly interpreted the command line arguments to ``setup.py build`` as
215     one of the 'side effect free' commands or options.
216     """
217 
218     def run(self):
219         raise RuntimeError(setup_requires_error)
220 
221 
222 class DummyInstall(install):
223     """
224     This class makes it very obvious when ``keywords_with_side_effects()`` has
225     incorrectly interpreted the command line arguments to ``setup.py install``
226     as one of the 'side effect free' commands or options.
227     """
228 
229     def run(self):
230         raise RuntimeError(setup_requires_error)
231 
232 
233 class DummyPyTest(test):
234     """
235     This class makes it very obvious when ``keywords_with_side_effects()`` has
236     incorrectly interpreted the command line arguments to ``setup.py test`` as
237     one of the 'side effect free' commands or options.
238     """
239 
240     def run_tests(self):
241         raise RuntimeError(setup_requires_error)
242 
243 
244 with open(os.path.join(base_dir, "README.rst")) as f:
245     long_description = f.read()
246 
247 
248 setup(
249     name=about["__title__"],
250     version=about["__version__"],
251 
252     description=about["__summary__"],
253     long_description=long_description,
254     license=about["__license__"],
255     url=about["__uri__"],
256 
257     author=about["__author__"],
258     author_email=about["__email__"],
259 
260     classifiers=[
261         "Intended Audience :: Developers",
262         "License :: OSI Approved :: Apache Software License",
263         "License :: OSI Approved :: BSD License",
264         "Natural Language :: English",
265         "Operating System :: MacOS :: MacOS X",
266         "Operating System :: POSIX",
267         "Operating System :: POSIX :: BSD",
268         "Operating System :: POSIX :: Linux",
269         "Operating System :: Microsoft :: Windows",
270         "Programming Language :: Python",
271         "Programming Language :: Python :: 2",
272         "Programming Language :: Python :: 2.7",
273         "Programming Language :: Python :: 3",
274         "Programming Language :: Python :: 3.4",
275         "Programming Language :: Python :: 3.5",
276         "Programming Language :: Python :: 3.6",
277         "Programming Language :: Python :: Implementation :: CPython",
278         "Programming Language :: Python :: Implementation :: PyPy",
279         "Topic :: Security :: Cryptography",
280     ],
281 
282     package_dir={"": "src"},
283     packages=find_packages(where="src", exclude=["_cffi_src", "_cffi_src.*"]),
284     include_package_data=True,
285 
286     python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*',
287 
288     install_requires=[
289         "idna >= 2.1",
290         "asn1crypto >= 0.21.0",
291         "six >= 1.4.1",
292     ],
293     tests_require=test_requirements,
294     extras_require={
295         ":python_version < '3'": ["enum34", "ipaddress"],
296         ":platform_python_implementation != 'PyPy'": ["cffi >= 1.7"],
297 
298         "test": test_requirements,
299         "docstest": [
300             "doc8",
301             "pyenchant >= 1.6.11",
302             "readme_renderer >= 16.0",
303             "sphinx >= 1.6.5",
304             "sphinx_rtd_theme",
305             "sphinxcontrib-spelling >= 4.0.1",
306         ],
307         "pep8test": [
308             "flake8",
309             "flake8-import-order",
310             "pep8-naming",
311         ],
312     },
313 
314     # for cffi
315     zip_safe=False,
316     ext_package="cryptography.hazmat.bindings",
317     **keywords_with_side_effects(sys.argv)
318 )
319
```
--- 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/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -296,12 +296,14 @@
         ":platform_python_implementation != 'PyPy'": ["cffi >= 1.7"],
 
         "test": test_requirements,
+        "docs": [
+            "sphinx >= 1.6.5",
+            "sphinx_rtd_theme",
+        ],
         "docstest": [
             "doc8",
             "pyenchant >= 1.6.11",
             "readme_renderer >= 16.0",
-            "sphinx >= 1.6.5",
-            "sphinx_rtd_theme",
             "sphinxcontrib-spelling >= 4.0.1",
         ],
         "pep8test": [

{"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -296,12 +296,14 @@\n         \":platform_python_implementation != 'PyPy'\": [\"cffi >= 1.7\"],\n \n         \"test\": test_requirements,\n+        \"docs\": [\n+            \"sphinx >= 1.6.5\",\n+            \"sphinx_rtd_theme\",\n+        ],\n         \"docstest\": [\n             \"doc8\",\n             \"pyenchant >= 1.6.11\",\n             \"readme_renderer >= 16.0\",\n-            \"sphinx >= 1.6.5\",\n-            \"sphinx_rtd_theme\",\n             \"sphinxcontrib-spelling >= 4.0.1\",\n         ],\n         \"pep8test\": [\n", "issue": "Figure out how to fix docs build on rtd\nIt appears to be running into https://github.com/sphinx-doc/sphinx/issues/3976\n", "before_files": [{"content": "#!/usr/bin/env python\n\n# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport os\nimport platform\nimport subprocess\nimport sys\nfrom distutils.command.build import build\n\nimport pkg_resources\n\nimport setuptools\nfrom setuptools import find_packages, setup\nfrom setuptools.command.install import install\nfrom setuptools.command.test import test\n\n\nif (\n    pkg_resources.parse_version(setuptools.__version__) <\n    pkg_resources.parse_version(\"18.5\")\n):\n    raise RuntimeError(\n        \"cryptography requires setuptools 18.5 or newer, please upgrade to a \"\n        \"newer version of setuptools\"\n    )\n\nbase_dir = os.path.dirname(__file__)\nsrc_dir = os.path.join(base_dir, \"src\")\n\n# When executing the setup.py, we need to be able to import ourselves, this\n# means that we need to add the src/ directory to the sys.path.\nsys.path.insert(0, src_dir)\n\nabout = {}\nwith open(os.path.join(src_dir, \"cryptography\", \"__about__.py\")) as f:\n    exec(f.read(), about)\n\n\nVECTORS_DEPENDENCY = \"cryptography_vectors=={0}\".format(about['__version__'])\n\nsetup_requirements = []\n\nif platform.python_implementation() == \"PyPy\":\n    if sys.pypy_version_info < (5, 3):\n        raise RuntimeError(\n            \"cryptography 1.9 is not compatible with PyPy < 5.3. Please \"\n            \"upgrade PyPy to use this library.\"\n        )\nelse:\n    setup_requirements.append(\"cffi>=1.7,!=1.11.3\")\n\ntest_requirements = [\n    \"pytest>=3.2.1,!=3.3.0\",\n    \"pretend\",\n    \"iso8601\",\n    \"pytz\",\n    \"hypothesis>=1.11.4\",\n]\n\n\n# If there's no vectors locally that probably means we are in a tarball and\n# need to go and get the matching vectors package from PyPi\nif not os.path.exists(os.path.join(base_dir, \"vectors/setup.py\")):\n    test_requirements.append(VECTORS_DEPENDENCY)\n\n\nclass PyTest(test):\n    def finalize_options(self):\n        test.finalize_options(self)\n        self.test_args = []\n        self.test_suite = True\n\n        # This means there's a vectors/ folder with the package in here.\n        # cd into it, install the vectors package and then refresh sys.path\n        if VECTORS_DEPENDENCY not in test_requirements:\n            subprocess.check_call(\n                [sys.executable, \"setup.py\", \"install\"], cwd=\"vectors\"\n            )\n            pkg_resources.get_distribution(\"cryptography_vectors\").activate()\n\n    def run_tests(self):\n        # Import here because in module scope the eggs are not loaded.\n        import pytest\n        test_args = [os.path.join(base_dir, \"tests\")]\n        errno = pytest.main(test_args)\n        sys.exit(errno)\n\n\ndef keywords_with_side_effects(argv):\n    \"\"\"\n    Get a dictionary with setup keywords that (can) have side effects.\n\n    :param argv: A list of strings with command line arguments.\n    :returns: A dictionary with keyword arguments for the ``setup()`` function.\n\n    This setup.py script uses the setuptools 'setup_requires' feature because\n    this is required by the cffi package to compile extension modules. The\n    purpose of ``keywords_with_side_effects()`` is to avoid triggering the cffi\n    build process as a result of setup.py invocations that don't need the cffi\n    module to be built (setup.py serves the dual purpose of exposing package\n    metadata).\n\n    All of the options listed by ``python setup.py --help`` that print\n    information should be recognized here. The commands ``clean``,\n    ``egg_info``, ``register``, ``sdist`` and ``upload`` are also recognized.\n    Any combination of these options and commands is also supported.\n\n    This function was originally based on the `setup.py script`_ of SciPy (see\n    also the discussion in `pip issue #25`_).\n\n    .. _pip issue #25: https://github.com/pypa/pip/issues/25\n    .. _setup.py script: https://github.com/scipy/scipy/blob/master/setup.py\n    \"\"\"\n    no_setup_requires_arguments = (\n        '-h', '--help',\n        '-n', '--dry-run',\n        '-q', '--quiet',\n        '-v', '--verbose',\n        '-V', '--version',\n        '--author',\n        '--author-email',\n        '--classifiers',\n        '--contact',\n        '--contact-email',\n        '--description',\n        '--egg-base',\n        '--fullname',\n        '--help-commands',\n        '--keywords',\n        '--licence',\n        '--license',\n        '--long-description',\n        '--maintainer',\n        '--maintainer-email',\n        '--name',\n        '--no-user-cfg',\n        '--obsoletes',\n        '--platforms',\n        '--provides',\n        '--requires',\n        '--url',\n        'clean',\n        'egg_info',\n        'register',\n        'sdist',\n        'upload',\n    )\n\n    def is_short_option(argument):\n        \"\"\"Check whether a command line argument is a short option.\"\"\"\n        return len(argument) >= 2 and argument[0] == '-' and argument[1] != '-'\n\n    def expand_short_options(argument):\n        \"\"\"Expand combined short options into canonical short options.\"\"\"\n        return ('-' + char for char in argument[1:])\n\n    def argument_without_setup_requirements(argv, i):\n        \"\"\"Check whether a command line argument needs setup requirements.\"\"\"\n        if argv[i] in no_setup_requires_arguments:\n            # Simple case: An argument which is either an option or a command\n            # which doesn't need setup requirements.\n            return True\n        elif (is_short_option(argv[i]) and\n              all(option in no_setup_requires_arguments\n                  for option in expand_short_options(argv[i]))):\n            # Not so simple case: Combined short options none of which need\n            # setup requirements.\n            return True\n        elif argv[i - 1:i] == ['--egg-base']:\n            # Tricky case: --egg-info takes an argument which should not make\n            # us use setup_requires (defeating the purpose of this code).\n            return True\n        else:\n            return False\n\n    if all(argument_without_setup_requirements(argv, i)\n           for i in range(1, len(argv))):\n        return {\n            \"cmdclass\": {\n                \"build\": DummyBuild,\n                \"install\": DummyInstall,\n                \"test\": DummyPyTest,\n            }\n        }\n    else:\n        cffi_modules = [\n            \"src/_cffi_src/build_openssl.py:ffi\",\n            \"src/_cffi_src/build_constant_time.py:ffi\",\n            \"src/_cffi_src/build_padding.py:ffi\",\n        ]\n\n        return {\n            \"setup_requires\": setup_requirements,\n            \"cmdclass\": {\n                \"test\": PyTest,\n            },\n            \"cffi_modules\": cffi_modules\n        }\n\n\nsetup_requires_error = (\"Requested setup command that needs 'setup_requires' \"\n                        \"while command line arguments implied a side effect \"\n                        \"free command or option.\")\n\n\nclass DummyBuild(build):\n    \"\"\"\n    This class makes it very obvious when ``keywords_with_side_effects()`` has\n    incorrectly interpreted the command line arguments to ``setup.py build`` as\n    one of the 'side effect free' commands or options.\n    \"\"\"\n\n    def run(self):\n        raise RuntimeError(setup_requires_error)\n\n\nclass DummyInstall(install):\n    \"\"\"\n    This class makes it very obvious when ``keywords_with_side_effects()`` has\n    incorrectly interpreted the command line arguments to ``setup.py install``\n    as one of the 'side effect free' commands or options.\n    \"\"\"\n\n    def run(self):\n        raise RuntimeError(setup_requires_error)\n\n\nclass DummyPyTest(test):\n    \"\"\"\n    This class makes it very obvious when ``keywords_with_side_effects()`` has\n    incorrectly interpreted the command line arguments to ``setup.py test`` as\n    one of the 'side effect free' commands or options.\n    \"\"\"\n\n    def run_tests(self):\n        raise RuntimeError(setup_requires_error)\n\n\nwith open(os.path.join(base_dir, \"README.rst\")) as f:\n    long_description = f.read()\n\n\nsetup(\n    name=about[\"__title__\"],\n    version=about[\"__version__\"],\n\n    description=about[\"__summary__\"],\n    long_description=long_description,\n    license=about[\"__license__\"],\n    url=about[\"__uri__\"],\n\n    author=about[\"__author__\"],\n    author_email=about[\"__email__\"],\n\n    classifiers=[\n        \"Intended Audience :: Developers\",\n        \"License :: OSI Approved :: Apache Software License\",\n        \"License :: OSI Approved :: BSD License\",\n        \"Natural Language :: English\",\n        \"Operating System :: MacOS :: MacOS X\",\n        \"Operating System :: POSIX\",\n        \"Operating System :: POSIX :: BSD\",\n        \"Operating System :: POSIX :: Linux\",\n        \"Operating System :: Microsoft :: Windows\",\n        \"Programming Language :: Python\",\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 :: Implementation :: CPython\",\n        \"Programming Language :: Python :: Implementation :: PyPy\",\n        \"Topic :: Security :: Cryptography\",\n    ],\n\n    package_dir={\"\": \"src\"},\n    packages=find_packages(where=\"src\", exclude=[\"_cffi_src\", \"_cffi_src.*\"]),\n    include_package_data=True,\n\n    python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*',\n\n    install_requires=[\n        \"idna >= 2.1\",\n        \"asn1crypto >= 0.21.0\",\n        \"six >= 1.4.1\",\n    ],\n    tests_require=test_requirements,\n    extras_require={\n        \":python_version < '3'\": [\"enum34\", \"ipaddress\"],\n        \":platform_python_implementation != 'PyPy'\": [\"cffi >= 1.7\"],\n\n        \"test\": test_requirements,\n        \"docstest\": [\n            \"doc8\",\n            \"pyenchant >= 1.6.11\",\n            \"readme_renderer >= 16.0\",\n            \"sphinx >= 1.6.5\",\n            \"sphinx_rtd_theme\",\n            \"sphinxcontrib-spelling >= 4.0.1\",\n        ],\n        \"pep8test\": [\n            \"flake8\",\n            \"flake8-import-order\",\n            \"pep8-naming\",\n        ],\n    },\n\n    # for cffi\n    zip_safe=False,\n    ext_package=\"cryptography.hazmat.bindings\",\n    **keywords_with_side_effects(sys.argv)\n)\n", "path": "setup.py"}], "after_files": [{"content": "#!/usr/bin/env python\n\n# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport os\nimport platform\nimport subprocess\nimport sys\nfrom distutils.command.build import build\n\nimport pkg_resources\n\nimport setuptools\nfrom setuptools import find_packages, setup\nfrom setuptools.command.install import install\nfrom setuptools.command.test import test\n\n\nif (\n    pkg_resources.parse_version(setuptools.__version__) <\n    pkg_resources.parse_version(\"18.5\")\n):\n    raise RuntimeError(\n        \"cryptography requires setuptools 18.5 or newer, please upgrade to a \"\n        \"newer version of setuptools\"\n    )\n\nbase_dir = os.path.dirname(__file__)\nsrc_dir = os.path.join(base_dir, \"src\")\n\n# When executing the setup.py, we need to be able to import ourselves, this\n# means that we need to add the src/ directory to the sys.path.\nsys.path.insert(0, src_dir)\n\nabout = {}\nwith open(os.path.join(src_dir, \"cryptography\", \"__about__.py\")) as f:\n    exec(f.read(), about)\n\n\nVECTORS_DEPENDENCY = \"cryptography_vectors=={0}\".format(about['__version__'])\n\nsetup_requirements = []\n\nif platform.python_implementation() == \"PyPy\":\n    if sys.pypy_version_info < (5, 3):\n        raise RuntimeError(\n            \"cryptography 1.9 is not compatible with PyPy < 5.3. Please \"\n            \"upgrade PyPy to use this library.\"\n        )\nelse:\n    setup_requirements.append(\"cffi>=1.7,!=1.11.3\")\n\ntest_requirements = [\n    \"pytest>=3.2.1,!=3.3.0\",\n    \"pretend\",\n    \"iso8601\",\n    \"pytz\",\n    \"hypothesis>=1.11.4\",\n]\n\n\n# If there's no vectors locally that probably means we are in a tarball and\n# need to go and get the matching vectors package from PyPi\nif not os.path.exists(os.path.join(base_dir, \"vectors/setup.py\")):\n    test_requirements.append(VECTORS_DEPENDENCY)\n\n\nclass PyTest(test):\n    def finalize_options(self):\n        test.finalize_options(self)\n        self.test_args = []\n        self.test_suite = True\n\n        # This means there's a vectors/ folder with the package in here.\n        # cd into it, install the vectors package and then refresh sys.path\n        if VECTORS_DEPENDENCY not in test_requirements:\n            subprocess.check_call(\n                [sys.executable, \"setup.py\", \"install\"], cwd=\"vectors\"\n            )\n            pkg_resources.get_distribution(\"cryptography_vectors\").activate()\n\n    def run_tests(self):\n        # Import here because in module scope the eggs are not loaded.\n        import pytest\n        test_args = [os.path.join(base_dir, \"tests\")]\n        errno = pytest.main(test_args)\n        sys.exit(errno)\n\n\ndef keywords_with_side_effects(argv):\n    \"\"\"\n    Get a dictionary with setup keywords that (can) have side effects.\n\n    :param argv: A list of strings with command line arguments.\n    :returns: A dictionary with keyword arguments for the ``setup()`` function.\n\n    This setup.py script uses the setuptools 'setup_requires' feature because\n    this is required by the cffi package to compile extension modules. The\n    purpose of ``keywords_with_side_effects()`` is to avoid triggering the cffi\n    build process as a result of setup.py invocations that don't need the cffi\n    module to be built (setup.py serves the dual purpose of exposing package\n    metadata).\n\n    All of the options listed by ``python setup.py --help`` that print\n    information should be recognized here. The commands ``clean``,\n    ``egg_info``, ``register``, ``sdist`` and ``upload`` are also recognized.\n    Any combination of these options and commands is also supported.\n\n    This function was originally based on the `setup.py script`_ of SciPy (see\n    also the discussion in `pip issue #25`_).\n\n    .. _pip issue #25: https://github.com/pypa/pip/issues/25\n    .. _setup.py script: https://github.com/scipy/scipy/blob/master/setup.py\n    \"\"\"\n    no_setup_requires_arguments = (\n        '-h', '--help',\n        '-n', '--dry-run',\n        '-q', '--quiet',\n        '-v', '--verbose',\n        '-V', '--version',\n        '--author',\n        '--author-email',\n        '--classifiers',\n        '--contact',\n        '--contact-email',\n        '--description',\n        '--egg-base',\n        '--fullname',\n        '--help-commands',\n        '--keywords',\n        '--licence',\n        '--license',\n        '--long-description',\n        '--maintainer',\n        '--maintainer-email',\n        '--name',\n        '--no-user-cfg',\n        '--obsoletes',\n        '--platforms',\n        '--provides',\n        '--requires',\n        '--url',\n        'clean',\n        'egg_info',\n        'register',\n        'sdist',\n        'upload',\n    )\n\n    def is_short_option(argument):\n        \"\"\"Check whether a command line argument is a short option.\"\"\"\n        return len(argument) >= 2 and argument[0] == '-' and argument[1] != '-'\n\n    def expand_short_options(argument):\n        \"\"\"Expand combined short options into canonical short options.\"\"\"\n        return ('-' + char for char in argument[1:])\n\n    def argument_without_setup_requirements(argv, i):\n        \"\"\"Check whether a command line argument needs setup requirements.\"\"\"\n        if argv[i] in no_setup_requires_arguments:\n            # Simple case: An argument which is either an option or a command\n            # which doesn't need setup requirements.\n            return True\n        elif (is_short_option(argv[i]) and\n              all(option in no_setup_requires_arguments\n                  for option in expand_short_options(argv[i]))):\n            # Not so simple case: Combined short options none of which need\n            # setup requirements.\n            return True\n        elif argv[i - 1:i] == ['--egg-base']:\n            # Tricky case: --egg-info takes an argument which should not make\n            # us use setup_requires (defeating the purpose of this code).\n            return True\n        else:\n            return False\n\n    if all(argument_without_setup_requirements(argv, i)\n           for i in range(1, len(argv))):\n        return {\n            \"cmdclass\": {\n                \"build\": DummyBuild,\n                \"install\": DummyInstall,\n                \"test\": DummyPyTest,\n            }\n        }\n    else:\n        cffi_modules = [\n            \"src/_cffi_src/build_openssl.py:ffi\",\n            \"src/_cffi_src/build_constant_time.py:ffi\",\n            \"src/_cffi_src/build_padding.py:ffi\",\n        ]\n\n        return {\n            \"setup_requires\": setup_requirements,\n            \"cmdclass\": {\n                \"test\": PyTest,\n            },\n            \"cffi_modules\": cffi_modules\n        }\n\n\nsetup_requires_error = (\"Requested setup command that needs 'setup_requires' \"\n                        \"while command line arguments implied a side effect \"\n                        \"free command or option.\")\n\n\nclass DummyBuild(build):\n    \"\"\"\n    This class makes it very obvious when ``keywords_with_side_effects()`` has\n    incorrectly interpreted the command line arguments to ``setup.py build`` as\n    one of the 'side effect free' commands or options.\n    \"\"\"\n\n    def run(self):\n        raise RuntimeError(setup_requires_error)\n\n\nclass DummyInstall(install):\n    \"\"\"\n    This class makes it very obvious when ``keywords_with_side_effects()`` has\n    incorrectly interpreted the command line arguments to ``setup.py install``\n    as one of the 'side effect free' commands or options.\n    \"\"\"\n\n    def run(self):\n        raise RuntimeError(setup_requires_error)\n\n\nclass DummyPyTest(test):\n    \"\"\"\n    This class makes it very obvious when ``keywords_with_side_effects()`` has\n    incorrectly interpreted the command line arguments to ``setup.py test`` as\n    one of the 'side effect free' commands or options.\n    \"\"\"\n\n    def run_tests(self):\n        raise RuntimeError(setup_requires_error)\n\n\nwith open(os.path.join(base_dir, \"README.rst\")) as f:\n    long_description = f.read()\n\n\nsetup(\n    name=about[\"__title__\"],\n    version=about[\"__version__\"],\n\n    description=about[\"__summary__\"],\n    long_description=long_description,\n    license=about[\"__license__\"],\n    url=about[\"__uri__\"],\n\n    author=about[\"__author__\"],\n    author_email=about[\"__email__\"],\n\n    classifiers=[\n        \"Intended Audience :: Developers\",\n        \"License :: OSI Approved :: Apache Software License\",\n        \"License :: OSI Approved :: BSD License\",\n        \"Natural Language :: English\",\n        \"Operating System :: MacOS :: MacOS X\",\n        \"Operating System :: POSIX\",\n        \"Operating System :: POSIX :: BSD\",\n        \"Operating System :: POSIX :: Linux\",\n        \"Operating System :: Microsoft :: Windows\",\n        \"Programming Language :: Python\",\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 :: Implementation :: CPython\",\n        \"Programming Language :: Python :: Implementation :: PyPy\",\n        \"Topic :: Security :: Cryptography\",\n    ],\n\n    package_dir={\"\": \"src\"},\n    packages=find_packages(where=\"src\", exclude=[\"_cffi_src\", \"_cffi_src.*\"]),\n    include_package_data=True,\n\n    python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*',\n\n    install_requires=[\n        \"idna >= 2.1\",\n        \"asn1crypto >= 0.21.0\",\n        \"six >= 1.4.1\",\n    ],\n    tests_require=test_requirements,\n    extras_require={\n        \":python_version < '3'\": [\"enum34\", \"ipaddress\"],\n        \":platform_python_implementation != 'PyPy'\": [\"cffi >= 1.7\"],\n\n        \"test\": test_requirements,\n        \"docs\": [\n            \"sphinx >= 1.6.5\",\n            \"sphinx_rtd_theme\",\n        ],\n        \"docstest\": [\n            \"doc8\",\n            \"pyenchant >= 1.6.11\",\n            \"readme_renderer >= 16.0\",\n            \"sphinxcontrib-spelling >= 4.0.1\",\n        ],\n        \"pep8test\": [\n            \"flake8\",\n            \"flake8-import-order\",\n            \"pep8-naming\",\n        ],\n    },\n\n    # for cffi\n    zip_safe=False,\n    ext_package=\"cryptography.hazmat.bindings\",\n    **keywords_with_side_effects(sys.argv)\n)\n", "path": "setup.py"}]}