prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Deprecated distutils bdist_wininst is going to be removed
  I proposed to remove the bdist_winstinst command from distutils in Python 3.9:
  
  * https://bugs.python.org/issue39541
  * https://discuss.python.org/t/remove-distutils-bdist-wininst-command/3115
  * https://github.com/python/cpython/pull/18329
  
  Problem: setuptools always uses it on all platforms at: setuptools/command/install_scripts.py, line 35:
  
  ```
    bw_cmd = self.get_finalized_command("bdist_wininst")
  ```
  
  See #857 which is a closed duplicated which proposed different options to fix the issue.
  
  </issue>
  <code>
  [start of setuptools/command/install_scripts.py]
  1 from distutils import log
  2 import distutils.command.install_scripts as orig
  3 import os
  4 import sys
  5 
  6 from pkg_resources import Distribution, PathMetadata, ensure_directory
  7 
  8 
  9 class install_scripts(orig.install_scripts):
  10     """Do normal script install, plus any egg_info wrapper scripts"""
  11 
  12     def initialize_options(self):
  13         orig.install_scripts.initialize_options(self)
  14         self.no_ep = False
  15 
  16     def run(self):
  17         import setuptools.command.easy_install as ei
  18 
  19         self.run_command("egg_info")
  20         if self.distribution.scripts:
  21             orig.install_scripts.run(self)  # run first to set up self.outfiles
  22         else:
  23             self.outfiles = []
  24         if self.no_ep:
  25             # don't install entry point scripts into .egg file!
  26             return
  27 
  28         ei_cmd = self.get_finalized_command("egg_info")
  29         dist = Distribution(
  30             ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info),
  31             ei_cmd.egg_name, ei_cmd.egg_version,
  32         )
  33         bs_cmd = self.get_finalized_command('build_scripts')
  34         exec_param = getattr(bs_cmd, 'executable', None)
  35         bw_cmd = self.get_finalized_command("bdist_wininst")
  36         is_wininst = getattr(bw_cmd, '_is_running', False)
  37         writer = ei.ScriptWriter
  38         if is_wininst:
  39             exec_param = "python.exe"
  40             writer = ei.WindowsScriptWriter
  41         if exec_param == sys.executable:
  42             # In case the path to the Python executable contains a space, wrap
  43             # it so it's not split up.
  44             exec_param = [exec_param]
  45         # resolve the writer to the environment
  46         writer = writer.best()
  47         cmd = writer.command_spec_class.best().from_param(exec_param)
  48         for args in writer.get_args(dist, cmd.as_header()):
  49             self.write_script(*args)
  50 
  51     def write_script(self, script_name, contents, mode="t", *ignored):
  52         """Write an executable file to the scripts directory"""
  53         from setuptools.command.easy_install import chmod, current_umask
  54 
  55         log.info("Installing %s script to %s", script_name, self.install_dir)
  56         target = os.path.join(self.install_dir, script_name)
  57         self.outfiles.append(target)
  58 
  59         mask = current_umask()
  60         if not self.dry_run:
  61             ensure_directory(target)
  62             f = open(target, "w" + mode)
  63             f.write(contents)
  64             f.close()
  65             chmod(target, 0o777 - mask)
  66
  [end of setuptools/command/install_scripts.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/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py
  --- a/setuptools/command/install_scripts.py
  +++ b/setuptools/command/install_scripts.py
  @@ -32,8 +32,11 @@
           )
           bs_cmd = self.get_finalized_command('build_scripts')
           exec_param = getattr(bs_cmd, 'executable', None)
  -        bw_cmd = self.get_finalized_command("bdist_wininst")
  -        is_wininst = getattr(bw_cmd, '_is_running', False)
  +        try:
  +            bw_cmd = self.get_finalized_command("bdist_wininst")
  +            is_wininst = getattr(bw_cmd, '_is_running', False)
  +        except ImportError:
  +            is_wininst = False
           writer = ei.ScriptWriter
           if is_wininst:
               exec_param = "python.exe"
  
verification_info: {"golden_diff": "diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py\n--- a/setuptools/command/install_scripts.py\n+++ b/setuptools/command/install_scripts.py\n@@ -32,8 +32,11 @@\n         )\n         bs_cmd = self.get_finalized_command('build_scripts')\n         exec_param = getattr(bs_cmd, 'executable', None)\n-        bw_cmd = self.get_finalized_command(\"bdist_wininst\")\n-        is_wininst = getattr(bw_cmd, '_is_running', False)\n+        try:\n+            bw_cmd = self.get_finalized_command(\"bdist_wininst\")\n+            is_wininst = getattr(bw_cmd, '_is_running', False)\n+        except ImportError:\n+            is_wininst = False\n         writer = ei.ScriptWriter\n         if is_wininst:\n             exec_param = \"python.exe\"\n", "issue": "Deprecated distutils bdist_wininst is going to be removed\nI proposed to remove the bdist_winstinst command from distutils in Python 3.9:\r\n\r\n* https://bugs.python.org/issue39541\r\n* https://discuss.python.org/t/remove-distutils-bdist-wininst-command/3115\r\n* https://github.com/python/cpython/pull/18329\r\n\r\nProblem: setuptools always uses it on all platforms at: setuptools/command/install_scripts.py, line 35:\r\n\r\n```\r\n  bw_cmd = self.get_finalized_command(\"bdist_wininst\")\r\n```\r\n\r\nSee #857 which is a closed duplicated which proposed different options to fix the issue.\n", "before_files": [{"content": "from distutils import log\nimport distutils.command.install_scripts as orig\nimport os\nimport sys\n\nfrom pkg_resources import Distribution, PathMetadata, ensure_directory\n\n\nclass install_scripts(orig.install_scripts):\n    \"\"\"Do normal script install, plus any egg_info wrapper scripts\"\"\"\n\n    def initialize_options(self):\n        orig.install_scripts.initialize_options(self)\n        self.no_ep = False\n\n    def run(self):\n        import setuptools.command.easy_install as ei\n\n        self.run_command(\"egg_info\")\n        if self.distribution.scripts:\n            orig.install_scripts.run(self)  # run first to set up self.outfiles\n        else:\n            self.outfiles = []\n        if self.no_ep:\n            # don't install entry point scripts into .egg file!\n            return\n\n        ei_cmd = self.get_finalized_command(\"egg_info\")\n        dist = Distribution(\n            ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info),\n            ei_cmd.egg_name, ei_cmd.egg_version,\n        )\n        bs_cmd = self.get_finalized_command('build_scripts')\n        exec_param = getattr(bs_cmd, 'executable', None)\n        bw_cmd = self.get_finalized_command(\"bdist_wininst\")\n        is_wininst = getattr(bw_cmd, '_is_running', False)\n        writer = ei.ScriptWriter\n        if is_wininst:\n            exec_param = \"python.exe\"\n            writer = ei.WindowsScriptWriter\n        if exec_param == sys.executable:\n            # In case the path to the Python executable contains a space, wrap\n            # it so it's not split up.\n            exec_param = [exec_param]\n        # resolve the writer to the environment\n        writer = writer.best()\n        cmd = writer.command_spec_class.best().from_param(exec_param)\n        for args in writer.get_args(dist, cmd.as_header()):\n            self.write_script(*args)\n\n    def write_script(self, script_name, contents, mode=\"t\", *ignored):\n        \"\"\"Write an executable file to the scripts directory\"\"\"\n        from setuptools.command.easy_install import chmod, current_umask\n\n        log.info(\"Installing %s script to %s\", script_name, self.install_dir)\n        target = os.path.join(self.install_dir, script_name)\n        self.outfiles.append(target)\n\n        mask = current_umask()\n        if not self.dry_run:\n            ensure_directory(target)\n            f = open(target, \"w\" + mode)\n            f.write(contents)\n            f.close()\n            chmod(target, 0o777 - mask)\n", "path": "setuptools/command/install_scripts.py"}]}