We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Remove pkg_resources.build_zipmanifest monkeypatching
This may involve increasing the minimum setuptools version.  Another alternative is vendoring setuptools.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pex/version.py`
Content:
```
1 # Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
2 # Licensed under the Apache License, Version 2.0 (see LICENSE).
3 
4 __version__ = '1.1.15'
5 
6 SETUPTOOLS_REQUIREMENT = 'setuptools>=2.2,<20.11'
7 WHEEL_REQUIREMENT = 'wheel>=0.26.0,<0.30.0'
8
```

Path: `pex/pex_bootstrapper.py`
Content:
```
1 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
2 # Licensed under the Apache License, Version 2.0 (see LICENSE).
3 
4 import contextlib
5 import os
6 import sys
7 import zipfile
8 
9 __all__ = ('bootstrap_pex',)
10 
11 
12 def pex_info_name(entry_point):
13   """Return the PEX-INFO for an entry_point"""
14   return os.path.join(entry_point, 'PEX-INFO')
15 
16 
17 def is_compressed(entry_point):
18   return os.path.exists(entry_point) and not os.path.exists(pex_info_name(entry_point))
19 
20 
21 def read_pexinfo_from_directory(entry_point):
22   with open(pex_info_name(entry_point), 'rb') as fp:
23     return fp.read()
24 
25 
26 def read_pexinfo_from_zip(entry_point):
27   with contextlib.closing(zipfile.ZipFile(entry_point)) as zf:
28     return zf.read('PEX-INFO')
29 
30 
31 def read_pex_info_content(entry_point):
32   """Return the raw content of a PEX-INFO."""
33   if is_compressed(entry_point):
34     return read_pexinfo_from_zip(entry_point)
35   else:
36     return read_pexinfo_from_directory(entry_point)
37 
38 
39 def get_pex_info(entry_point):
40   """Return the PexInfo object for an entry point."""
41   from . import pex_info
42 
43   pex_info_content = read_pex_info_content(entry_point)
44   if pex_info_content:
45     return pex_info.PexInfo.from_json(pex_info_content)
46   raise ValueError('Invalid entry_point: %s' % entry_point)
47 
48 
49 # TODO(wickman) Remove once resolved (#91):
50 #   https://bitbucket.org/pypa/setuptools/issue/154/build_zipmanifest-results-should-be
51 def monkeypatch_build_zipmanifest():
52   import pkg_resources
53   if not hasattr(pkg_resources, 'build_zipmanifest'):
54     return
55   old_build_zipmanifest = pkg_resources.build_zipmanifest
56   def memoized_build_zipmanifest(archive, memo={}):
57     if archive not in memo:
58       memo[archive] = old_build_zipmanifest(archive)
59     return memo[archive]
60   pkg_resources.build_zipmanifest = memoized_build_zipmanifest
61 
62 
63 def find_in_path(target_interpreter):
64   if os.path.exists(target_interpreter):
65     return target_interpreter
66 
67   for directory in os.getenv('PATH', '').split(os.pathsep):
68     try_path = os.path.join(directory, target_interpreter)
69     if os.path.exists(try_path):
70       return try_path
71 
72 
73 def maybe_reexec_pex():
74   from .variables import ENV
75   if not ENV.PEX_PYTHON:
76     return
77 
78   from .common import die
79   from .tracer import TRACER
80 
81   target_python = ENV.PEX_PYTHON
82   target = find_in_path(target_python)
83   if not target:
84     die('Failed to find interpreter specified by PEX_PYTHON: %s' % target)
85   if os.path.exists(target) and os.path.realpath(target) != os.path.realpath(sys.executable):
86     TRACER.log('Detected PEX_PYTHON, re-exec to %s' % target)
87     ENV.delete('PEX_PYTHON')
88     os.execve(target, [target_python] + sys.argv, ENV.copy())
89 
90 
91 def bootstrap_pex(entry_point):
92   from .finders import register_finders
93   monkeypatch_build_zipmanifest()
94   register_finders()
95   maybe_reexec_pex()
96 
97   from . import pex
98   pex.PEX(entry_point).execute()
99 
100 
101 def bootstrap_pex_env(entry_point):
102   """Bootstrap the current runtime environment using a given pex."""
103   from .environment import PEXEnvironment
104   from .finders import register_finders
105   from .pex_info import PexInfo
106 
107   monkeypatch_build_zipmanifest()
108   register_finders()
109 
110   PEXEnvironment(entry_point, PexInfo.from_pex(entry_point)).activate()
111
```
--- 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/pex/pex_bootstrapper.py b/pex/pex_bootstrapper.py
--- a/pex/pex_bootstrapper.py
+++ b/pex/pex_bootstrapper.py
@@ -46,20 +46,6 @@
   raise ValueError('Invalid entry_point: %s' % entry_point)
 
 
-# TODO(wickman) Remove once resolved (#91):
-#   https://bitbucket.org/pypa/setuptools/issue/154/build_zipmanifest-results-should-be
-def monkeypatch_build_zipmanifest():
-  import pkg_resources
-  if not hasattr(pkg_resources, 'build_zipmanifest'):
-    return
-  old_build_zipmanifest = pkg_resources.build_zipmanifest
-  def memoized_build_zipmanifest(archive, memo={}):
-    if archive not in memo:
-      memo[archive] = old_build_zipmanifest(archive)
-    return memo[archive]
-  pkg_resources.build_zipmanifest = memoized_build_zipmanifest
-
-
 def find_in_path(target_interpreter):
   if os.path.exists(target_interpreter):
     return target_interpreter
@@ -90,7 +76,6 @@
 
 def bootstrap_pex(entry_point):
   from .finders import register_finders
-  monkeypatch_build_zipmanifest()
   register_finders()
   maybe_reexec_pex()
 
@@ -104,7 +89,6 @@
   from .finders import register_finders
   from .pex_info import PexInfo
 
-  monkeypatch_build_zipmanifest()
   register_finders()
 
   PEXEnvironment(entry_point, PexInfo.from_pex(entry_point)).activate()
diff --git a/pex/version.py b/pex/version.py
--- a/pex/version.py
+++ b/pex/version.py
@@ -3,5 +3,5 @@
 
 __version__ = '1.1.15'
 
-SETUPTOOLS_REQUIREMENT = 'setuptools>=2.2,<20.11'
+SETUPTOOLS_REQUIREMENT = 'setuptools>=5.7,<20.11'
 WHEEL_REQUIREMENT = 'wheel>=0.26.0,<0.30.0'

{"golden_diff": "diff --git a/pex/pex_bootstrapper.py b/pex/pex_bootstrapper.py\n--- a/pex/pex_bootstrapper.py\n+++ b/pex/pex_bootstrapper.py\n@@ -46,20 +46,6 @@\n   raise ValueError('Invalid entry_point: %s' % entry_point)\n \n \n-# TODO(wickman) Remove once resolved (#91):\n-#   https://bitbucket.org/pypa/setuptools/issue/154/build_zipmanifest-results-should-be\n-def monkeypatch_build_zipmanifest():\n-  import pkg_resources\n-  if not hasattr(pkg_resources, 'build_zipmanifest'):\n-    return\n-  old_build_zipmanifest = pkg_resources.build_zipmanifest\n-  def memoized_build_zipmanifest(archive, memo={}):\n-    if archive not in memo:\n-      memo[archive] = old_build_zipmanifest(archive)\n-    return memo[archive]\n-  pkg_resources.build_zipmanifest = memoized_build_zipmanifest\n-\n-\n def find_in_path(target_interpreter):\n   if os.path.exists(target_interpreter):\n     return target_interpreter\n@@ -90,7 +76,6 @@\n \n def bootstrap_pex(entry_point):\n   from .finders import register_finders\n-  monkeypatch_build_zipmanifest()\n   register_finders()\n   maybe_reexec_pex()\n \n@@ -104,7 +89,6 @@\n   from .finders import register_finders\n   from .pex_info import PexInfo\n \n-  monkeypatch_build_zipmanifest()\n   register_finders()\n \n   PEXEnvironment(entry_point, PexInfo.from_pex(entry_point)).activate()\ndiff --git a/pex/version.py b/pex/version.py\n--- a/pex/version.py\n+++ b/pex/version.py\n@@ -3,5 +3,5 @@\n \n __version__ = '1.1.15'\n \n-SETUPTOOLS_REQUIREMENT = 'setuptools>=2.2,<20.11'\n+SETUPTOOLS_REQUIREMENT = 'setuptools>=5.7,<20.11'\n WHEEL_REQUIREMENT = 'wheel>=0.26.0,<0.30.0'\n", "issue": "Remove pkg_resources.build_zipmanifest monkeypatching\nThis may involve increasing the minimum setuptools version.  Another alternative is vendoring setuptools.\n\n", "before_files": [{"content": "# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).\n# Licensed under the Apache License, Version 2.0 (see LICENSE).\n\n__version__ = '1.1.15'\n\nSETUPTOOLS_REQUIREMENT = 'setuptools>=2.2,<20.11'\nWHEEL_REQUIREMENT = 'wheel>=0.26.0,<0.30.0'\n", "path": "pex/version.py"}, {"content": "# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).\n# Licensed under the Apache License, Version 2.0 (see LICENSE).\n\nimport contextlib\nimport os\nimport sys\nimport zipfile\n\n__all__ = ('bootstrap_pex',)\n\n\ndef pex_info_name(entry_point):\n  \"\"\"Return the PEX-INFO for an entry_point\"\"\"\n  return os.path.join(entry_point, 'PEX-INFO')\n\n\ndef is_compressed(entry_point):\n  return os.path.exists(entry_point) and not os.path.exists(pex_info_name(entry_point))\n\n\ndef read_pexinfo_from_directory(entry_point):\n  with open(pex_info_name(entry_point), 'rb') as fp:\n    return fp.read()\n\n\ndef read_pexinfo_from_zip(entry_point):\n  with contextlib.closing(zipfile.ZipFile(entry_point)) as zf:\n    return zf.read('PEX-INFO')\n\n\ndef read_pex_info_content(entry_point):\n  \"\"\"Return the raw content of a PEX-INFO.\"\"\"\n  if is_compressed(entry_point):\n    return read_pexinfo_from_zip(entry_point)\n  else:\n    return read_pexinfo_from_directory(entry_point)\n\n\ndef get_pex_info(entry_point):\n  \"\"\"Return the PexInfo object for an entry point.\"\"\"\n  from . import pex_info\n\n  pex_info_content = read_pex_info_content(entry_point)\n  if pex_info_content:\n    return pex_info.PexInfo.from_json(pex_info_content)\n  raise ValueError('Invalid entry_point: %s' % entry_point)\n\n\n# TODO(wickman) Remove once resolved (#91):\n#   https://bitbucket.org/pypa/setuptools/issue/154/build_zipmanifest-results-should-be\ndef monkeypatch_build_zipmanifest():\n  import pkg_resources\n  if not hasattr(pkg_resources, 'build_zipmanifest'):\n    return\n  old_build_zipmanifest = pkg_resources.build_zipmanifest\n  def memoized_build_zipmanifest(archive, memo={}):\n    if archive not in memo:\n      memo[archive] = old_build_zipmanifest(archive)\n    return memo[archive]\n  pkg_resources.build_zipmanifest = memoized_build_zipmanifest\n\n\ndef find_in_path(target_interpreter):\n  if os.path.exists(target_interpreter):\n    return target_interpreter\n\n  for directory in os.getenv('PATH', '').split(os.pathsep):\n    try_path = os.path.join(directory, target_interpreter)\n    if os.path.exists(try_path):\n      return try_path\n\n\ndef maybe_reexec_pex():\n  from .variables import ENV\n  if not ENV.PEX_PYTHON:\n    return\n\n  from .common import die\n  from .tracer import TRACER\n\n  target_python = ENV.PEX_PYTHON\n  target = find_in_path(target_python)\n  if not target:\n    die('Failed to find interpreter specified by PEX_PYTHON: %s' % target)\n  if os.path.exists(target) and os.path.realpath(target) != os.path.realpath(sys.executable):\n    TRACER.log('Detected PEX_PYTHON, re-exec to %s' % target)\n    ENV.delete('PEX_PYTHON')\n    os.execve(target, [target_python] + sys.argv, ENV.copy())\n\n\ndef bootstrap_pex(entry_point):\n  from .finders import register_finders\n  monkeypatch_build_zipmanifest()\n  register_finders()\n  maybe_reexec_pex()\n\n  from . import pex\n  pex.PEX(entry_point).execute()\n\n\ndef bootstrap_pex_env(entry_point):\n  \"\"\"Bootstrap the current runtime environment using a given pex.\"\"\"\n  from .environment import PEXEnvironment\n  from .finders import register_finders\n  from .pex_info import PexInfo\n\n  monkeypatch_build_zipmanifest()\n  register_finders()\n\n  PEXEnvironment(entry_point, PexInfo.from_pex(entry_point)).activate()\n", "path": "pex/pex_bootstrapper.py"}], "after_files": [{"content": "# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).\n# Licensed under the Apache License, Version 2.0 (see LICENSE).\n\n__version__ = '1.1.15'\n\nSETUPTOOLS_REQUIREMENT = 'setuptools>=5.7,<20.11'\nWHEEL_REQUIREMENT = 'wheel>=0.26.0,<0.30.0'\n", "path": "pex/version.py"}, {"content": "# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).\n# Licensed under the Apache License, Version 2.0 (see LICENSE).\n\nimport contextlib\nimport os\nimport sys\nimport zipfile\n\n__all__ = ('bootstrap_pex',)\n\n\ndef pex_info_name(entry_point):\n  \"\"\"Return the PEX-INFO for an entry_point\"\"\"\n  return os.path.join(entry_point, 'PEX-INFO')\n\n\ndef is_compressed(entry_point):\n  return os.path.exists(entry_point) and not os.path.exists(pex_info_name(entry_point))\n\n\ndef read_pexinfo_from_directory(entry_point):\n  with open(pex_info_name(entry_point), 'rb') as fp:\n    return fp.read()\n\n\ndef read_pexinfo_from_zip(entry_point):\n  with contextlib.closing(zipfile.ZipFile(entry_point)) as zf:\n    return zf.read('PEX-INFO')\n\n\ndef read_pex_info_content(entry_point):\n  \"\"\"Return the raw content of a PEX-INFO.\"\"\"\n  if is_compressed(entry_point):\n    return read_pexinfo_from_zip(entry_point)\n  else:\n    return read_pexinfo_from_directory(entry_point)\n\n\ndef get_pex_info(entry_point):\n  \"\"\"Return the PexInfo object for an entry point.\"\"\"\n  from . import pex_info\n\n  pex_info_content = read_pex_info_content(entry_point)\n  if pex_info_content:\n    return pex_info.PexInfo.from_json(pex_info_content)\n  raise ValueError('Invalid entry_point: %s' % entry_point)\n\n\ndef find_in_path(target_interpreter):\n  if os.path.exists(target_interpreter):\n    return target_interpreter\n\n  for directory in os.getenv('PATH', '').split(os.pathsep):\n    try_path = os.path.join(directory, target_interpreter)\n    if os.path.exists(try_path):\n      return try_path\n\n\ndef maybe_reexec_pex():\n  from .variables import ENV\n  if not ENV.PEX_PYTHON:\n    return\n\n  from .common import die\n  from .tracer import TRACER\n\n  target_python = ENV.PEX_PYTHON\n  target = find_in_path(target_python)\n  if not target:\n    die('Failed to find interpreter specified by PEX_PYTHON: %s' % target)\n  if os.path.exists(target) and os.path.realpath(target) != os.path.realpath(sys.executable):\n    TRACER.log('Detected PEX_PYTHON, re-exec to %s' % target)\n    ENV.delete('PEX_PYTHON')\n    os.execve(target, [target_python] + sys.argv, ENV.copy())\n\n\ndef bootstrap_pex(entry_point):\n  from .finders import register_finders\n  register_finders()\n  maybe_reexec_pex()\n\n  from . import pex\n  pex.PEX(entry_point).execute()\n\n\ndef bootstrap_pex_env(entry_point):\n  \"\"\"Bootstrap the current runtime environment using a given pex.\"\"\"\n  from .environment import PEXEnvironment\n  from .finders import register_finders\n  from .pex_info import PexInfo\n\n  register_finders()\n\n  PEXEnvironment(entry_point, PexInfo.from_pex(entry_point)).activate()\n", "path": "pex/pex_bootstrapper.py"}]}