We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Set a minimum version on setuptools
Apparently it fails in hilarious ways with very very old setuptools (or even distribute). We should set a floor in `setup.py`.

@dstufft do you have opinions on what a reasonable floor would be?


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

{"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -37,7 +37,7 @@\n     \"idna>=2.0\",\n     \"pyasn1>=0.1.8\",\n     \"six>=1.4.1\",\n-    \"setuptools\",\n+    \"setuptools>=1.0\",\n ]\n setup_requirements = []\n", "issue": "Set a minimum version on setuptools\nApparently it fails in hilarious ways with very very old setuptools (or even distribute). We should set a floor in `setup.py`.\n\n@dstufft do you have opinions on what a reasonable floor would be?\n\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\nfrom setuptools import find_packages, setup\nfrom setuptools.command.install import install\nfrom setuptools.command.test import test\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\nrequirements = [\n    \"idna>=2.0\",\n    \"pyasn1>=0.1.8\",\n    \"six>=1.4.1\",\n    \"setuptools\",\n]\nsetup_requirements = []\n\nif sys.version_info < (3, 4):\n    requirements.append(\"enum34\")\n\nif sys.version_info < (3, 3):\n    requirements.append(\"ipaddress\")\n\nif platform.python_implementation() == \"PyPy\":\n    if sys.pypy_version_info < (2, 6):\n        raise RuntimeError(\n            \"cryptography 1.0 is not compatible with PyPy < 2.6. Please \"\n            \"upgrade PyPy to use this library.\"\n        )\nelse:\n    requirements.append(\"cffi>=1.1.0\")\n    setup_requirements.append(\"cffi>=1.1.0\")\n\n# If you add a new dep here you probably need to add it in the tox.ini as well\ntest_requirements = [\n    \"pytest\",\n    \"pretend\",\n    \"iso8601\",\n    \"hypothesis\",\n    \"pyasn1_modules\",\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\ndef cc_is_available():\n    return sys.platform == \"darwin\" and list(map(\n        int, platform.mac_ver()[0].split(\".\"))) >= [10, 8, 0]\n\n\nbackends = [\n    \"openssl = cryptography.hazmat.backends.openssl:backend\"\n]\n\nif cc_is_available():\n    backends.append(\n        \"commoncrypto = cryptography.hazmat.backends.commoncrypto:backend\",\n    )\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        if cc_is_available():\n            cffi_modules.append(\"src/_cffi_src/build_commoncrypto.py:ffi\")\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.6\",\n        \"Programming Language :: Python :: 2.7\",\n        \"Programming Language :: Python :: 3\",\n        \"Programming Language :: Python :: 3.3\",\n        \"Programming Language :: Python :: 3.4\",\n        \"Programming Language :: Python :: 3.5\",\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(\n        where=\"src\", exclude=[\"_cffi_src\", \"_cffi_src.*\", \"tests\", \"tests.*\"]\n    ),\n    include_package_data=True,\n\n    install_requires=requirements,\n    tests_require=test_requirements,\n\n    # for cffi\n    zip_safe=False,\n    ext_package=\"cryptography.hazmat.bindings\",\n    entry_points={\n        \"cryptography.backends\": backends,\n    },\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\nfrom setuptools import find_packages, setup\nfrom setuptools.command.install import install\nfrom setuptools.command.test import test\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\nrequirements = [\n    \"idna>=2.0\",\n    \"pyasn1>=0.1.8\",\n    \"six>=1.4.1\",\n    \"setuptools>=1.0\",\n]\nsetup_requirements = []\n\nif sys.version_info < (3, 4):\n    requirements.append(\"enum34\")\n\nif sys.version_info < (3, 3):\n    requirements.append(\"ipaddress\")\n\nif platform.python_implementation() == \"PyPy\":\n    if sys.pypy_version_info < (2, 6):\n        raise RuntimeError(\n            \"cryptography 1.0 is not compatible with PyPy < 2.6. Please \"\n            \"upgrade PyPy to use this library.\"\n        )\nelse:\n    requirements.append(\"cffi>=1.1.0\")\n    setup_requirements.append(\"cffi>=1.1.0\")\n\n# If you add a new dep here you probably need to add it in the tox.ini as well\ntest_requirements = [\n    \"pytest\",\n    \"pretend\",\n    \"iso8601\",\n    \"hypothesis\",\n    \"pyasn1_modules\",\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\ndef cc_is_available():\n    return sys.platform == \"darwin\" and list(map(\n        int, platform.mac_ver()[0].split(\".\"))) >= [10, 8, 0]\n\n\nbackends = [\n    \"openssl = cryptography.hazmat.backends.openssl:backend\"\n]\n\nif cc_is_available():\n    backends.append(\n        \"commoncrypto = cryptography.hazmat.backends.commoncrypto:backend\",\n    )\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        if cc_is_available():\n            cffi_modules.append(\"src/_cffi_src/build_commoncrypto.py:ffi\")\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.6\",\n        \"Programming Language :: Python :: 2.7\",\n        \"Programming Language :: Python :: 3\",\n        \"Programming Language :: Python :: 3.3\",\n        \"Programming Language :: Python :: 3.4\",\n        \"Programming Language :: Python :: 3.5\",\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(\n        where=\"src\", exclude=[\"_cffi_src\", \"_cffi_src.*\", \"tests\", \"tests.*\"]\n    ),\n    include_package_data=True,\n\n    install_requires=requirements,\n    tests_require=test_requirements,\n\n    # for cffi\n    zip_safe=False,\n    ext_package=\"cryptography.hazmat.bindings\",\n    entry_points={\n        \"cryptography.backends\": backends,\n    },\n    **keywords_with_side_effects(sys.argv)\n)\n", "path": "setup.py"}]}