prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Refactor setup.py external module selection for Cython
  Reduce complexity and duplication of the external module selection for Cython in setup.py.
  
  At the time of this issue, this cruft was located in: 
  https://github.com/kgriffs/falcon/blob/routing/setup.py#L35
  
  
  </issue>
  <code>
  [start of setup.py]
  1 import glob
  2 import imp
  3 import io
  4 import os
  5 from os import path
  6 from setuptools import setup, find_packages, Extension
  7 import sys
  8 
  9 MYDIR = path.abspath(os.path.dirname(__file__))
  10 
  11 VERSION = imp.load_source('version', path.join('.', 'falcon', 'version.py'))
  12 VERSION = VERSION.__version__
  13 
  14 # NOTE(kgriffs): python-mimeparse is newer than mimeparse, supports Py3
  15 # TODO(kgriffs): Fork and optimize/modernize python-mimeparse
  16 REQUIRES = ['six>=1.4.0', 'python-mimeparse']
  17 
  18 JYTHON = 'java' in sys.platform
  19 
  20 try:
  21     sys.pypy_version_info
  22     PYPY = True
  23 except AttributeError:
  24     PYPY = False
  25 
  26 if PYPY or JYTHON:
  27     CYTHON = False
  28 else:
  29     try:
  30         from Cython.Distutils import build_ext
  31         CYTHON = True
  32     except ImportError:
  33         # TODO(kgriffs): pip now ignores all output, so the user
  34         # may not see this message. See also:
  35         #
  36         #   https://github.com/pypa/pip/issues/2732
  37         #
  38         print('\nNOTE: Cython not installed. '
  39               'Falcon will still work fine, but may run '
  40               'a bit slower.\n')
  41         CYTHON = False
  42 
  43 if CYTHON:
  44     def list_modules(dirname):
  45         filenames = glob.glob(path.join(dirname, '*.py'))
  46 
  47         module_names = []
  48         for name in filenames:
  49             module, ext = path.splitext(path.basename(name))
  50             if module != '__init__':
  51                 module_names.append(module)
  52 
  53         return module_names
  54 
  55     ext_modules = [
  56         Extension('falcon.' + ext, [path.join('falcon', ext + '.py')])
  57         for ext in list_modules(path.join(MYDIR, 'falcon'))]
  58 
  59     ext_modules += [
  60         Extension('falcon.util.' + ext,
  61                   [path.join('falcon', 'util', ext + '.py')])
  62 
  63         for ext in list_modules(path.join(MYDIR, 'falcon', 'util'))]
  64 
  65     ext_modules += [
  66         Extension('falcon.routing.' + ext,
  67                   [path.join('falcon', 'routing', ext + '.py')])
  68 
  69         for ext in list_modules(path.join(MYDIR, 'falcon', 'routing'))]
  70 
  71     cmdclass = {'build_ext': build_ext}
  72 
  73 else:
  74     cmdclass = {}
  75     ext_modules = []
  76 
  77 setup(
  78     name='falcon',
  79     version=VERSION,
  80     description='An unladen web framework for building APIs and app backends.',
  81     long_description=io.open('README.rst', 'r', encoding='utf-8').read(),
  82     classifiers=[
  83         'Development Status :: 5 - Production/Stable',
  84         'Environment :: Web Environment',
  85         'Natural Language :: English',
  86         'Intended Audience :: Developers',
  87         'Intended Audience :: System Administrators',
  88         'License :: OSI Approved :: Apache Software License',
  89         'Operating System :: MacOS :: MacOS X',
  90         'Operating System :: Microsoft :: Windows',
  91         'Operating System :: POSIX',
  92         'Topic :: Internet :: WWW/HTTP :: WSGI',
  93         'Topic :: Software Development :: Libraries :: Application Frameworks',
  94         'Programming Language :: Python',
  95         'Programming Language :: Python :: Implementation :: CPython',
  96         'Programming Language :: Python :: Implementation :: PyPy',
  97         'Programming Language :: Python :: Implementation :: Jython',
  98         'Programming Language :: Python :: 2.6',
  99         'Programming Language :: Python :: 2.7',
  100         'Programming Language :: Python :: 3.3',
  101         'Programming Language :: Python :: 3.4',
  102         'Programming Language :: Python :: 3.5',
  103     ],
  104     keywords='wsgi web api framework rest http cloud',
  105     author='Kurt Griffiths',
  106     author_email='mail@kgriffs.com',
  107     url='http://falconframework.org',
  108     license='Apache 2.0',
  109     packages=find_packages(exclude=['tests']),
  110     include_package_data=True,
  111     zip_safe=False,
  112     install_requires=REQUIRES,
  113     setup_requires=[],
  114     cmdclass=cmdclass,
  115     ext_modules=ext_modules,
  116     test_suite='nose.collector',
  117     entry_points={
  118         'console_scripts': [
  119             'falcon-bench = falcon.cmd.bench:main'
  120         ]
  121     }
  122 )
  123
  [end of setup.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/setup.py b/setup.py
  --- a/setup.py
  +++ b/setup.py
  @@ -52,21 +52,15 @@
   
           return module_names
   
  +    package_names = ['falcon', 'falcon.util', 'falcon.routing']
       ext_modules = [
  -        Extension('falcon.' + ext, [path.join('falcon', ext + '.py')])
  -        for ext in list_modules(path.join(MYDIR, 'falcon'))]
  -
  -    ext_modules += [
  -        Extension('falcon.util.' + ext,
  -                  [path.join('falcon', 'util', ext + '.py')])
  -
  -        for ext in list_modules(path.join(MYDIR, 'falcon', 'util'))]
  -
  -    ext_modules += [
  -        Extension('falcon.routing.' + ext,
  -                  [path.join('falcon', 'routing', ext + '.py')])
  -
  -        for ext in list_modules(path.join(MYDIR, 'falcon', 'routing'))]
  +        Extension(
  +            package + '.' + module,
  +            [path.join(*(package.split('.') + [module + '.py']))]
  +        )
  +        for package in package_names
  +        for module in list_modules(path.join(MYDIR, *package.split('.')))
  +    ]
   
       cmdclass = {'build_ext': build_ext}
  
verification_info: {"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -52,21 +52,15 @@\n \n         return module_names\n \n+    package_names = ['falcon', 'falcon.util', 'falcon.routing']\n     ext_modules = [\n-        Extension('falcon.' + ext, [path.join('falcon', ext + '.py')])\n-        for ext in list_modules(path.join(MYDIR, 'falcon'))]\n-\n-    ext_modules += [\n-        Extension('falcon.util.' + ext,\n-                  [path.join('falcon', 'util', ext + '.py')])\n-\n-        for ext in list_modules(path.join(MYDIR, 'falcon', 'util'))]\n-\n-    ext_modules += [\n-        Extension('falcon.routing.' + ext,\n-                  [path.join('falcon', 'routing', ext + '.py')])\n-\n-        for ext in list_modules(path.join(MYDIR, 'falcon', 'routing'))]\n+        Extension(\n+            package + '.' + module,\n+            [path.join(*(package.split('.') + [module + '.py']))]\n+        )\n+        for package in package_names\n+        for module in list_modules(path.join(MYDIR, *package.split('.')))\n+    ]\n \n     cmdclass = {'build_ext': build_ext}\n", "issue": "Refactor setup.py external module selection for Cython\nReduce complexity and duplication of the external module selection for Cython in setup.py.\n\nAt the time of this issue, this cruft was located in: \nhttps://github.com/kgriffs/falcon/blob/routing/setup.py#L35\n\n", "before_files": [{"content": "import glob\nimport imp\nimport io\nimport os\nfrom os import path\nfrom setuptools import setup, find_packages, Extension\nimport sys\n\nMYDIR = path.abspath(os.path.dirname(__file__))\n\nVERSION = imp.load_source('version', path.join('.', 'falcon', 'version.py'))\nVERSION = VERSION.__version__\n\n# NOTE(kgriffs): python-mimeparse is newer than mimeparse, supports Py3\n# TODO(kgriffs): Fork and optimize/modernize python-mimeparse\nREQUIRES = ['six>=1.4.0', 'python-mimeparse']\n\nJYTHON = 'java' in sys.platform\n\ntry:\n    sys.pypy_version_info\n    PYPY = True\nexcept AttributeError:\n    PYPY = False\n\nif PYPY or JYTHON:\n    CYTHON = False\nelse:\n    try:\n        from Cython.Distutils import build_ext\n        CYTHON = True\n    except ImportError:\n        # TODO(kgriffs): pip now ignores all output, so the user\n        # may not see this message. See also:\n        #\n        #   https://github.com/pypa/pip/issues/2732\n        #\n        print('\\nNOTE: Cython not installed. '\n              'Falcon will still work fine, but may run '\n              'a bit slower.\\n')\n        CYTHON = False\n\nif CYTHON:\n    def list_modules(dirname):\n        filenames = glob.glob(path.join(dirname, '*.py'))\n\n        module_names = []\n        for name in filenames:\n            module, ext = path.splitext(path.basename(name))\n            if module != '__init__':\n                module_names.append(module)\n\n        return module_names\n\n    ext_modules = [\n        Extension('falcon.' + ext, [path.join('falcon', ext + '.py')])\n        for ext in list_modules(path.join(MYDIR, 'falcon'))]\n\n    ext_modules += [\n        Extension('falcon.util.' + ext,\n                  [path.join('falcon', 'util', ext + '.py')])\n\n        for ext in list_modules(path.join(MYDIR, 'falcon', 'util'))]\n\n    ext_modules += [\n        Extension('falcon.routing.' + ext,\n                  [path.join('falcon', 'routing', ext + '.py')])\n\n        for ext in list_modules(path.join(MYDIR, 'falcon', 'routing'))]\n\n    cmdclass = {'build_ext': build_ext}\n\nelse:\n    cmdclass = {}\n    ext_modules = []\n\nsetup(\n    name='falcon',\n    version=VERSION,\n    description='An unladen web framework for building APIs and app backends.',\n    long_description=io.open('README.rst', 'r', encoding='utf-8').read(),\n    classifiers=[\n        'Development Status :: 5 - Production/Stable',\n        'Environment :: Web Environment',\n        'Natural Language :: English',\n        'Intended Audience :: Developers',\n        'Intended Audience :: System Administrators',\n        'License :: OSI Approved :: Apache Software License',\n        'Operating System :: MacOS :: MacOS X',\n        'Operating System :: Microsoft :: Windows',\n        'Operating System :: POSIX',\n        'Topic :: Internet :: WWW/HTTP :: WSGI',\n        'Topic :: Software Development :: Libraries :: Application Frameworks',\n        'Programming Language :: Python',\n        'Programming Language :: Python :: Implementation :: CPython',\n        'Programming Language :: Python :: Implementation :: PyPy',\n        'Programming Language :: Python :: Implementation :: Jython',\n        'Programming Language :: Python :: 2.6',\n        'Programming Language :: Python :: 2.7',\n        'Programming Language :: Python :: 3.3',\n        'Programming Language :: Python :: 3.4',\n        'Programming Language :: Python :: 3.5',\n    ],\n    keywords='wsgi web api framework rest http cloud',\n    author='Kurt Griffiths',\n    author_email='mail@kgriffs.com',\n    url='http://falconframework.org',\n    license='Apache 2.0',\n    packages=find_packages(exclude=['tests']),\n    include_package_data=True,\n    zip_safe=False,\n    install_requires=REQUIRES,\n    setup_requires=[],\n    cmdclass=cmdclass,\n    ext_modules=ext_modules,\n    test_suite='nose.collector',\n    entry_points={\n        'console_scripts': [\n            'falcon-bench = falcon.cmd.bench:main'\n        ]\n    }\n)\n", "path": "setup.py"}]}