We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
ImportError: cannot import name monkey
```
user@hostname:~/project$ venv/bin/pip install -U setuptools==27.1.0
Collecting setuptools==27.1.0
  Downloading setuptools-27.1.0-py2.py3-none-any.whl (464kB)
    100% |████████████████████████████████| 471kB 1.6MB/s 
Installing collected packages: setuptools
  Found existing installation: setuptools 27.1.1
    Uninstalling setuptools-27.1.1:
      Successfully uninstalled setuptools-27.1.1
Successfully installed setuptools-27.1.0
user@hostname:~/project$ venv/bin/python -c "import setuptools"
user@hostname:~/project$ venv/bin/pip install -U setuptools==27.1.1
Collecting setuptools==27.1.1
  Using cached setuptools-27.1.1-py2.py3-none-any.whl
Installing collected packages: setuptools
  Found existing installation: setuptools 27.1.0
    Uninstalling setuptools-27.1.0:
      Successfully uninstalled setuptools-27.1.0
Successfully installed setuptools-27.1.1
user@hostname:~/project$ venv/bin/python -c "import setuptools"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/user/project/venv/local/lib/python2.7/site-packages/setuptools/__init__.py", line 13, in <module>
    from setuptools.extension import Extension
  File "/home/user/project/venv/local/lib/python2.7/site-packages/setuptools/extension.py", line 9, in <module>
    from .monkey import get_unpatched
  File "/home/user/project/venv/local/lib/python2.7/site-packages/setuptools/monkey.py", line 10, in <module>
    from . import msvc
  File "/home/user/project/venv/local/lib/python2.7/site-packages/setuptools/msvc.py", line 27, in <module>
    from . import monkey
ImportError: cannot import name monkey
user@hostname:~/project$ 
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setuptools/monkey.py`
Content:
```
1 """
2 Monkey patching of distutils.
3 """
4 
5 import sys
6 import distutils.filelist
7 import platform
8 
9 import setuptools
10 from . import msvc
11 
12 
13 __all__ = []
14 """
15 Everything is private. Contact the project team
16 if you think you need this functionality.
17 """
18 
19 
20 def get_unpatched(cls):
21     """Protect against re-patching the distutils if reloaded
22 
23     Also ensures that no other distutils extension monkeypatched the distutils
24     first.
25     """
26     while cls.__module__.startswith('setuptools'):
27         cls, = cls.__bases__
28     if not cls.__module__.startswith('distutils'):
29         raise AssertionError(
30             "distutils has already been patched by %r" % cls
31         )
32     return cls
33 
34 
35 def patch_all():
36     # we can't patch distutils.cmd, alas
37     distutils.core.Command = setuptools.Command
38 
39     has_issue_12885 = (
40         sys.version_info < (3, 4, 6)
41         or
42         (3, 5) < sys.version_info <= (3, 5, 3)
43         or
44         (3, 6) < sys.version_info
45     )
46 
47     if has_issue_12885:
48         # fix findall bug in distutils (http://bugs.python.org/issue12885)
49         distutils.filelist.findall = setuptools.findall
50 
51     needs_warehouse = (
52         sys.version_info < (2, 7, 13)
53         or
54         (3, 0) < sys.version_info < (3, 3, 7)
55         or
56         (3, 4) < sys.version_info < (3, 4, 6)
57         or
58         (3, 5) < sys.version_info <= (3, 5, 3)
59         or
60         (3, 6) < sys.version_info
61     )
62 
63     if needs_warehouse:
64         warehouse = 'https://upload.pypi.org/legacy/'
65         distutils.config.PyPIRCCommand.DEFAULT_REPOSITORY = warehouse
66 
67     _patch_distribution_metadata_write_pkg_file()
68     _patch_distribution_metadata_write_pkg_info()
69 
70     # Install Distribution throughout the distutils
71     for module in distutils.dist, distutils.core, distutils.cmd:
72         module.Distribution = setuptools.dist.Distribution
73 
74     # Install the patched Extension
75     distutils.core.Extension = setuptools.extension.Extension
76     distutils.extension.Extension = setuptools.extension.Extension
77     if 'distutils.command.build_ext' in sys.modules:
78         sys.modules['distutils.command.build_ext'].Extension = (
79             setuptools.extension.Extension
80         )
81 
82     patch_for_msvc_specialized_compiler()
83 
84 
85 def _patch_distribution_metadata_write_pkg_file():
86     """Patch write_pkg_file to also write Requires-Python/Requires-External"""
87     distutils.dist.DistributionMetadata.write_pkg_file = (
88         setuptools.dist.write_pkg_file
89     )
90 
91 
92 def _patch_distribution_metadata_write_pkg_info():
93     """
94     Workaround issue #197 - Python 3 prior to 3.2.2 uses an environment-local
95     encoding to save the pkg_info. Monkey-patch its write_pkg_info method to
96     correct this undesirable behavior.
97     """
98     environment_local = (3,) <= sys.version_info[:3] < (3, 2, 2)
99     if not environment_local:
100         return
101 
102     distutils.dist.DistributionMetadata.write_pkg_info = (
103         setuptools.dist.write_pkg_info
104     )
105 
106 
107 unpatched = dict()
108 
109 
110 def patch_for_msvc_specialized_compiler():
111     """
112     Patch functions in distutils to use standalone Microsoft Visual C++
113     compilers.
114     """
115     try:
116         # Distutil file for MSVC++ 9.0 and upper (Python 2.7 to 3.4)
117         import distutils.msvc9compiler as msvc9compiler
118     except ImportError:
119         pass
120 
121     try:
122         # Distutil file for MSVC++ 14.0 and upper (Python 3.5+)
123         import distutils._msvccompiler as msvc14compiler
124     except ImportError:
125         pass
126 
127     if platform.system() != 'Windows':
128         # Compilers only availables on Microsoft Windows
129         return
130 
131     if unpatched:
132         # Already patched
133         return
134 
135     try:
136         # Patch distutils.msvc9compiler
137         unpatched['msvc9_find_vcvarsall'] = msvc9compiler.find_vcvarsall
138         msvc9compiler.find_vcvarsall = msvc.msvc9_find_vcvarsall
139         unpatched['msvc9_query_vcvarsall'] = msvc9compiler.query_vcvarsall
140         msvc9compiler.query_vcvarsall = msvc.msvc9_query_vcvarsall
141     except NameError:
142         pass
143 
144     try:
145         # Patch distutils._msvccompiler._get_vc_env
146         unpatched['msvc14_get_vc_env'] = msvc14compiler._get_vc_env
147         msvc14compiler._get_vc_env = msvc.msvc14_get_vc_env
148     except NameError:
149         pass
150 
151     try:
152         # Patch distutils._msvccompiler.gen_lib_options for Numpy
153         unpatched['msvc14_gen_lib_options'] = msvc14compiler.gen_lib_options
154         msvc14compiler.gen_lib_options = msvc.msvc14_gen_lib_options
155     except NameError:
156         pass
157
```
--- 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/setuptools/monkey.py b/setuptools/monkey.py
--- a/setuptools/monkey.py
+++ b/setuptools/monkey.py
@@ -7,7 +7,6 @@
 import platform
 
 import setuptools
-from . import msvc
 
 
 __all__ = []
@@ -112,6 +111,8 @@
     Patch functions in distutils to use standalone Microsoft Visual C++
     compilers.
     """
+    from . import msvc
+
     try:
         # Distutil file for MSVC++ 9.0 and upper (Python 2.7 to 3.4)
         import distutils.msvc9compiler as msvc9compiler

{"golden_diff": "diff --git a/setuptools/monkey.py b/setuptools/monkey.py\n--- a/setuptools/monkey.py\n+++ b/setuptools/monkey.py\n@@ -7,7 +7,6 @@\n import platform\n \n import setuptools\n-from . import msvc\n \n \n __all__ = []\n@@ -112,6 +111,8 @@\n     Patch functions in distutils to use standalone Microsoft Visual C++\n     compilers.\n     \"\"\"\n+    from . import msvc\n+\n     try:\n         # Distutil file for MSVC++ 9.0 and upper (Python 2.7 to 3.4)\n         import distutils.msvc9compiler as msvc9compiler\n", "issue": "ImportError: cannot import name monkey\n```\nuser@hostname:~/project$ venv/bin/pip install -U setuptools==27.1.0\nCollecting setuptools==27.1.0\n  Downloading setuptools-27.1.0-py2.py3-none-any.whl (464kB)\n    100% |\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 471kB 1.6MB/s \nInstalling collected packages: setuptools\n  Found existing installation: setuptools 27.1.1\n    Uninstalling setuptools-27.1.1:\n      Successfully uninstalled setuptools-27.1.1\nSuccessfully installed setuptools-27.1.0\nuser@hostname:~/project$ venv/bin/python -c \"import setuptools\"\nuser@hostname:~/project$ venv/bin/pip install -U setuptools==27.1.1\nCollecting setuptools==27.1.1\n  Using cached setuptools-27.1.1-py2.py3-none-any.whl\nInstalling collected packages: setuptools\n  Found existing installation: setuptools 27.1.0\n    Uninstalling setuptools-27.1.0:\n      Successfully uninstalled setuptools-27.1.0\nSuccessfully installed setuptools-27.1.1\nuser@hostname:~/project$ venv/bin/python -c \"import setuptools\"\nTraceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/home/user/project/venv/local/lib/python2.7/site-packages/setuptools/__init__.py\", line 13, in <module>\n    from setuptools.extension import Extension\n  File \"/home/user/project/venv/local/lib/python2.7/site-packages/setuptools/extension.py\", line 9, in <module>\n    from .monkey import get_unpatched\n  File \"/home/user/project/venv/local/lib/python2.7/site-packages/setuptools/monkey.py\", line 10, in <module>\n    from . import msvc\n  File \"/home/user/project/venv/local/lib/python2.7/site-packages/setuptools/msvc.py\", line 27, in <module>\n    from . import monkey\nImportError: cannot import name monkey\nuser@hostname:~/project$ \n```\n\n", "before_files": [{"content": "\"\"\"\nMonkey patching of distutils.\n\"\"\"\n\nimport sys\nimport distutils.filelist\nimport platform\n\nimport setuptools\nfrom . import msvc\n\n\n__all__ = []\n\"\"\"\nEverything is private. Contact the project team\nif you think you need this functionality.\n\"\"\"\n\n\ndef get_unpatched(cls):\n    \"\"\"Protect against re-patching the distutils if reloaded\n\n    Also ensures that no other distutils extension monkeypatched the distutils\n    first.\n    \"\"\"\n    while cls.__module__.startswith('setuptools'):\n        cls, = cls.__bases__\n    if not cls.__module__.startswith('distutils'):\n        raise AssertionError(\n            \"distutils has already been patched by %r\" % cls\n        )\n    return cls\n\n\ndef patch_all():\n    # we can't patch distutils.cmd, alas\n    distutils.core.Command = setuptools.Command\n\n    has_issue_12885 = (\n        sys.version_info < (3, 4, 6)\n        or\n        (3, 5) < sys.version_info <= (3, 5, 3)\n        or\n        (3, 6) < sys.version_info\n    )\n\n    if has_issue_12885:\n        # fix findall bug in distutils (http://bugs.python.org/issue12885)\n        distutils.filelist.findall = setuptools.findall\n\n    needs_warehouse = (\n        sys.version_info < (2, 7, 13)\n        or\n        (3, 0) < sys.version_info < (3, 3, 7)\n        or\n        (3, 4) < sys.version_info < (3, 4, 6)\n        or\n        (3, 5) < sys.version_info <= (3, 5, 3)\n        or\n        (3, 6) < sys.version_info\n    )\n\n    if needs_warehouse:\n        warehouse = 'https://upload.pypi.org/legacy/'\n        distutils.config.PyPIRCCommand.DEFAULT_REPOSITORY = warehouse\n\n    _patch_distribution_metadata_write_pkg_file()\n    _patch_distribution_metadata_write_pkg_info()\n\n    # Install Distribution throughout the distutils\n    for module in distutils.dist, distutils.core, distutils.cmd:\n        module.Distribution = setuptools.dist.Distribution\n\n    # Install the patched Extension\n    distutils.core.Extension = setuptools.extension.Extension\n    distutils.extension.Extension = setuptools.extension.Extension\n    if 'distutils.command.build_ext' in sys.modules:\n        sys.modules['distutils.command.build_ext'].Extension = (\n            setuptools.extension.Extension\n        )\n\n    patch_for_msvc_specialized_compiler()\n\n\ndef _patch_distribution_metadata_write_pkg_file():\n    \"\"\"Patch write_pkg_file to also write Requires-Python/Requires-External\"\"\"\n    distutils.dist.DistributionMetadata.write_pkg_file = (\n        setuptools.dist.write_pkg_file\n    )\n\n\ndef _patch_distribution_metadata_write_pkg_info():\n    \"\"\"\n    Workaround issue #197 - Python 3 prior to 3.2.2 uses an environment-local\n    encoding to save the pkg_info. Monkey-patch its write_pkg_info method to\n    correct this undesirable behavior.\n    \"\"\"\n    environment_local = (3,) <= sys.version_info[:3] < (3, 2, 2)\n    if not environment_local:\n        return\n\n    distutils.dist.DistributionMetadata.write_pkg_info = (\n        setuptools.dist.write_pkg_info\n    )\n\n\nunpatched = dict()\n\n\ndef patch_for_msvc_specialized_compiler():\n    \"\"\"\n    Patch functions in distutils to use standalone Microsoft Visual C++\n    compilers.\n    \"\"\"\n    try:\n        # Distutil file for MSVC++ 9.0 and upper (Python 2.7 to 3.4)\n        import distutils.msvc9compiler as msvc9compiler\n    except ImportError:\n        pass\n\n    try:\n        # Distutil file for MSVC++ 14.0 and upper (Python 3.5+)\n        import distutils._msvccompiler as msvc14compiler\n    except ImportError:\n        pass\n\n    if platform.system() != 'Windows':\n        # Compilers only availables on Microsoft Windows\n        return\n\n    if unpatched:\n        # Already patched\n        return\n\n    try:\n        # Patch distutils.msvc9compiler\n        unpatched['msvc9_find_vcvarsall'] = msvc9compiler.find_vcvarsall\n        msvc9compiler.find_vcvarsall = msvc.msvc9_find_vcvarsall\n        unpatched['msvc9_query_vcvarsall'] = msvc9compiler.query_vcvarsall\n        msvc9compiler.query_vcvarsall = msvc.msvc9_query_vcvarsall\n    except NameError:\n        pass\n\n    try:\n        # Patch distutils._msvccompiler._get_vc_env\n        unpatched['msvc14_get_vc_env'] = msvc14compiler._get_vc_env\n        msvc14compiler._get_vc_env = msvc.msvc14_get_vc_env\n    except NameError:\n        pass\n\n    try:\n        # Patch distutils._msvccompiler.gen_lib_options for Numpy\n        unpatched['msvc14_gen_lib_options'] = msvc14compiler.gen_lib_options\n        msvc14compiler.gen_lib_options = msvc.msvc14_gen_lib_options\n    except NameError:\n        pass\n", "path": "setuptools/monkey.py"}], "after_files": [{"content": "\"\"\"\nMonkey patching of distutils.\n\"\"\"\n\nimport sys\nimport distutils.filelist\nimport platform\n\nimport setuptools\n\n\n__all__ = []\n\"\"\"\nEverything is private. Contact the project team\nif you think you need this functionality.\n\"\"\"\n\n\ndef get_unpatched(cls):\n    \"\"\"Protect against re-patching the distutils if reloaded\n\n    Also ensures that no other distutils extension monkeypatched the distutils\n    first.\n    \"\"\"\n    while cls.__module__.startswith('setuptools'):\n        cls, = cls.__bases__\n    if not cls.__module__.startswith('distutils'):\n        raise AssertionError(\n            \"distutils has already been patched by %r\" % cls\n        )\n    return cls\n\n\ndef patch_all():\n    # we can't patch distutils.cmd, alas\n    distutils.core.Command = setuptools.Command\n\n    has_issue_12885 = (\n        sys.version_info < (3, 4, 6)\n        or\n        (3, 5) < sys.version_info <= (3, 5, 3)\n        or\n        (3, 6) < sys.version_info\n    )\n\n    if has_issue_12885:\n        # fix findall bug in distutils (http://bugs.python.org/issue12885)\n        distutils.filelist.findall = setuptools.findall\n\n    needs_warehouse = (\n        sys.version_info < (2, 7, 13)\n        or\n        (3, 0) < sys.version_info < (3, 3, 7)\n        or\n        (3, 4) < sys.version_info < (3, 4, 6)\n        or\n        (3, 5) < sys.version_info <= (3, 5, 3)\n        or\n        (3, 6) < sys.version_info\n    )\n\n    if needs_warehouse:\n        warehouse = 'https://upload.pypi.org/legacy/'\n        distutils.config.PyPIRCCommand.DEFAULT_REPOSITORY = warehouse\n\n    _patch_distribution_metadata_write_pkg_file()\n    _patch_distribution_metadata_write_pkg_info()\n\n    # Install Distribution throughout the distutils\n    for module in distutils.dist, distutils.core, distutils.cmd:\n        module.Distribution = setuptools.dist.Distribution\n\n    # Install the patched Extension\n    distutils.core.Extension = setuptools.extension.Extension\n    distutils.extension.Extension = setuptools.extension.Extension\n    if 'distutils.command.build_ext' in sys.modules:\n        sys.modules['distutils.command.build_ext'].Extension = (\n            setuptools.extension.Extension\n        )\n\n    patch_for_msvc_specialized_compiler()\n\n\ndef _patch_distribution_metadata_write_pkg_file():\n    \"\"\"Patch write_pkg_file to also write Requires-Python/Requires-External\"\"\"\n    distutils.dist.DistributionMetadata.write_pkg_file = (\n        setuptools.dist.write_pkg_file\n    )\n\n\ndef _patch_distribution_metadata_write_pkg_info():\n    \"\"\"\n    Workaround issue #197 - Python 3 prior to 3.2.2 uses an environment-local\n    encoding to save the pkg_info. Monkey-patch its write_pkg_info method to\n    correct this undesirable behavior.\n    \"\"\"\n    environment_local = (3,) <= sys.version_info[:3] < (3, 2, 2)\n    if not environment_local:\n        return\n\n    distutils.dist.DistributionMetadata.write_pkg_info = (\n        setuptools.dist.write_pkg_info\n    )\n\n\nunpatched = dict()\n\n\ndef patch_for_msvc_specialized_compiler():\n    \"\"\"\n    Patch functions in distutils to use standalone Microsoft Visual C++\n    compilers.\n    \"\"\"\n    from . import msvc\n\n    try:\n        # Distutil file for MSVC++ 9.0 and upper (Python 2.7 to 3.4)\n        import distutils.msvc9compiler as msvc9compiler\n    except ImportError:\n        pass\n\n    try:\n        # Distutil file for MSVC++ 14.0 and upper (Python 3.5+)\n        import distutils._msvccompiler as msvc14compiler\n    except ImportError:\n        pass\n\n    if platform.system() != 'Windows':\n        # Compilers only availables on Microsoft Windows\n        return\n\n    if unpatched:\n        # Already patched\n        return\n\n    try:\n        # Patch distutils.msvc9compiler\n        unpatched['msvc9_find_vcvarsall'] = msvc9compiler.find_vcvarsall\n        msvc9compiler.find_vcvarsall = msvc.msvc9_find_vcvarsall\n        unpatched['msvc9_query_vcvarsall'] = msvc9compiler.query_vcvarsall\n        msvc9compiler.query_vcvarsall = msvc.msvc9_query_vcvarsall\n    except NameError:\n        pass\n\n    try:\n        # Patch distutils._msvccompiler._get_vc_env\n        unpatched['msvc14_get_vc_env'] = msvc14compiler._get_vc_env\n        msvc14compiler._get_vc_env = msvc.msvc14_get_vc_env\n    except NameError:\n        pass\n\n    try:\n        # Patch distutils._msvccompiler.gen_lib_options for Numpy\n        unpatched['msvc14_gen_lib_options'] = msvc14compiler.gen_lib_options\n        msvc14compiler.gen_lib_options = msvc.msvc14_gen_lib_options\n    except NameError:\n        pass\n", "path": "setuptools/monkey.py"}]}