prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Could not import `pywintypes` or `win32api` from `win32ctypes.pywin32`
  ## Description of the issue
  
  Error when running the executable.
  
  Issue is present in 6.6.0 and "latest development version". Issue is not present in 6.5.0.
  
  Output differs between versions at this point:
  
  6.6.0:
  ```
  import 'win32ctypes.core' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001C6D9E41BB0>
  # win32ctypes.core._common not found in PYZ
  # win32ctypes.core.ctypes not found in PYZ
  # destroy win32ctypes.pywin32.win32api
  # destroy win32ctypes.pywin32
  # destroy PyInstaller
  Could not import `pywintypes` or `win32api` from `win32ctypes.pywin32`.
  Please make sure that `pywin32-ctypes` is installed and importable, for example:
  
  pip install pywin32-ctypes
  
  ```
  
  6.5.0:
  ```
  # cffi not found in PYZ
  # code object from '[...]\\cffi\\__init__.pyc'
  # cffi.api not found in PYZ
  # code object from '[...]\\cffi\\api.pyc'
  # cffi.lock not found in PYZ
  # code object from '[...]\\cffi\\lock.pyc'
  import 'cffi.lock' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB845C0>
  # cffi.error not found in PYZ
  # code object from '[...]\\cffi\\error.pyc'
  import 'cffi.error' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB846B0>
  # cffi.model not found in PYZ
  # code object from '[...]\\cffi\\model.pyc'
  import 'cffi.model' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB848F0>
  import 'cffi.api' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB52330>
  import 'cffi' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB51EB0>
  import 'win32ctypes.core' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB51B80>
  # win32ctypes.core._common not found in PYZ
  # win32ctypes.core.cffi not found in PYZ
  # code object from '[...]\\win32ctypes\\core\\cffi\\__init__.pyc'
  import 'win32ctypes.core.cffi' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB86BA0>
  # win32ctypes.core.cffi._common not found in PYZ
  # code object from '[...]\\win32ctypes\\core\\cffi\\_common.pyc'
  # win32ctypes.core.cffi._util not found in PYZ
  # code object from '[...]\\win32ctypes\\core\\cffi\\_util.pyc'
  # win32ctypes.core.compat not found in PYZ
  # code object from '[...]\\win32ctypes\\core\\compat.pyc'
  import 'win32ctypes.core.compat' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB87440>
  # _cffi_backend not found in PYZ
  # extension module '_cffi_backend' loaded from '[...]\\_cffi_backend.cp312-win_amd64.pyd'
  # extension module '_cffi_backend' executed from '[...]\\_cffi_backend.cp312-win_amd64.pyd'
  import '_cffi_backend' # <_frozen_importlib_external.ExtensionFileLoader object at 0x000001F4AEB876B0>
  # cffi.cparser not found in PYZ
  # code object from '[...]\\cffi\\cparser.pyc'
  # cffi.commontypes not found in PYZ
  # code object from '[...]\\cffi\\commontypes.pyc'
  import 'cffi.commontypes' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEBA91F0>
  ```
  
  
  ### Context information (for bug reports)
  
  * 502 INFO: PyInstaller: 6.6.0, contrib hooks: 2024.6
  * 503 INFO: Python: 3.12.0
  * 541 INFO: Platform: Windows-10-10.0.19045-SP0
  
  
  
  
  </issue>
  <code>
  [start of PyInstaller/hooks/hook-win32ctypes.core.py]
  1 #-----------------------------------------------------------------------------
  2 # Copyright (c) 2020-2023, PyInstaller Development Team.
  3 #
  4 # Distributed under the terms of the GNU General Public License (version 2
  5 # or later) with exception for distributing the bootloader.
  6 #
  7 # The full license is in the file COPYING.txt, distributed with this software.
  8 #
  9 # SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
  10 #-----------------------------------------------------------------------------
  11 
  12 # TODO: remove this hook during PyInstaller 4.5 release cycle!
  13 
  14 from PyInstaller.utils.hooks import can_import_module, collect_submodules
  15 
  16 # We need to collect submodules from win32ctypes.core.cffi or win32ctypes.core.ctypes for win32ctypes.core to work. The
  17 # use of the backend is determined by availability of cffi.
  18 if can_import_module('cffi'):
  19     hiddenimports = collect_submodules('win32ctypes.core.cffi')
  20 else:
  21     hiddenimports = collect_submodules('win32ctypes.core.ctypes')
  22
  [end of PyInstaller/hooks/hook-win32ctypes.core.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/PyInstaller/hooks/hook-win32ctypes.core.py b/PyInstaller/hooks/hook-win32ctypes.core.py
  --- a/PyInstaller/hooks/hook-win32ctypes.core.py
  +++ b/PyInstaller/hooks/hook-win32ctypes.core.py
  @@ -13,9 +13,10 @@
   
   from PyInstaller.utils.hooks import can_import_module, collect_submodules
   
  -# We need to collect submodules from win32ctypes.core.cffi or win32ctypes.core.ctypes for win32ctypes.core to work. The
  -# use of the backend is determined by availability of cffi.
  +# We need to collect submodules from win32ctypes.core.cffi or win32ctypes.core.ctypes for win32ctypes.core to work.
  +# Always collect the `ctypes` backend, and add the `cffi` one if `cffi` is available. Having the `ctypes` backend always
  +# available helps in situations when `cffi` is available in the build environment, but is disabled at run-time or not
  +# collected (e.g., due to `--exclude cffi`).
  +hiddenimports = collect_submodules('win32ctypes.core.ctypes')
   if can_import_module('cffi'):
  -    hiddenimports = collect_submodules('win32ctypes.core.cffi')
  -else:
  -    hiddenimports = collect_submodules('win32ctypes.core.ctypes')
  +    hiddenimports += collect_submodules('win32ctypes.core.cffi')
  
verification_info: {"golden_diff": "diff --git a/PyInstaller/hooks/hook-win32ctypes.core.py b/PyInstaller/hooks/hook-win32ctypes.core.py\n--- a/PyInstaller/hooks/hook-win32ctypes.core.py\n+++ b/PyInstaller/hooks/hook-win32ctypes.core.py\n@@ -13,9 +13,10 @@\n \n from PyInstaller.utils.hooks import can_import_module, collect_submodules\n \n-# We need to collect submodules from win32ctypes.core.cffi or win32ctypes.core.ctypes for win32ctypes.core to work. The\n-# use of the backend is determined by availability of cffi.\n+# We need to collect submodules from win32ctypes.core.cffi or win32ctypes.core.ctypes for win32ctypes.core to work.\n+# Always collect the `ctypes` backend, and add the `cffi` one if `cffi` is available. Having the `ctypes` backend always\n+# available helps in situations when `cffi` is available in the build environment, but is disabled at run-time or not\n+# collected (e.g., due to `--exclude cffi`).\n+hiddenimports = collect_submodules('win32ctypes.core.ctypes')\n if can_import_module('cffi'):\n-    hiddenimports = collect_submodules('win32ctypes.core.cffi')\n-else:\n-    hiddenimports = collect_submodules('win32ctypes.core.ctypes')\n+    hiddenimports += collect_submodules('win32ctypes.core.cffi')\n", "issue": "Could not import `pywintypes` or `win32api` from `win32ctypes.pywin32`\n## Description of the issue\r\n\r\nError when running the executable.\r\n\r\nIssue is present in 6.6.0 and \"latest development version\". Issue is not present in 6.5.0.\r\n\r\nOutput differs between versions at this point:\r\n\r\n6.6.0:\r\n```\r\nimport 'win32ctypes.core' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001C6D9E41BB0>\r\n# win32ctypes.core._common not found in PYZ\r\n# win32ctypes.core.ctypes not found in PYZ\r\n# destroy win32ctypes.pywin32.win32api\r\n# destroy win32ctypes.pywin32\r\n# destroy PyInstaller\r\nCould not import `pywintypes` or `win32api` from `win32ctypes.pywin32`.\r\nPlease make sure that `pywin32-ctypes` is installed and importable, for example:\r\n\r\npip install pywin32-ctypes\r\n\r\n```\r\n\r\n6.5.0:\r\n```\r\n# cffi not found in PYZ\r\n# code object from '[...]\\\\cffi\\\\__init__.pyc'\r\n# cffi.api not found in PYZ\r\n# code object from '[...]\\\\cffi\\\\api.pyc'\r\n# cffi.lock not found in PYZ\r\n# code object from '[...]\\\\cffi\\\\lock.pyc'\r\nimport 'cffi.lock' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB845C0>\r\n# cffi.error not found in PYZ\r\n# code object from '[...]\\\\cffi\\\\error.pyc'\r\nimport 'cffi.error' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB846B0>\r\n# cffi.model not found in PYZ\r\n# code object from '[...]\\\\cffi\\\\model.pyc'\r\nimport 'cffi.model' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB848F0>\r\nimport 'cffi.api' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB52330>\r\nimport 'cffi' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB51EB0>\r\nimport 'win32ctypes.core' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB51B80>\r\n# win32ctypes.core._common not found in PYZ\r\n# win32ctypes.core.cffi not found in PYZ\r\n# code object from '[...]\\\\win32ctypes\\\\core\\\\cffi\\\\__init__.pyc'\r\nimport 'win32ctypes.core.cffi' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB86BA0>\r\n# win32ctypes.core.cffi._common not found in PYZ\r\n# code object from '[...]\\\\win32ctypes\\\\core\\\\cffi\\\\_common.pyc'\r\n# win32ctypes.core.cffi._util not found in PYZ\r\n# code object from '[...]\\\\win32ctypes\\\\core\\\\cffi\\\\_util.pyc'\r\n# win32ctypes.core.compat not found in PYZ\r\n# code object from '[...]\\\\win32ctypes\\\\core\\\\compat.pyc'\r\nimport 'win32ctypes.core.compat' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEB87440>\r\n# _cffi_backend not found in PYZ\r\n# extension module '_cffi_backend' loaded from '[...]\\\\_cffi_backend.cp312-win_amd64.pyd'\r\n# extension module '_cffi_backend' executed from '[...]\\\\_cffi_backend.cp312-win_amd64.pyd'\r\nimport '_cffi_backend' # <_frozen_importlib_external.ExtensionFileLoader object at 0x000001F4AEB876B0>\r\n# cffi.cparser not found in PYZ\r\n# code object from '[...]\\\\cffi\\\\cparser.pyc'\r\n# cffi.commontypes not found in PYZ\r\n# code object from '[...]\\\\cffi\\\\commontypes.pyc'\r\nimport 'cffi.commontypes' # <_frozen_importlib_external.SourcelessFileLoader object at 0x000001F4AEBA91F0>\r\n```\r\n\r\n\r\n### Context information (for bug reports)\r\n\r\n* 502 INFO: PyInstaller: 6.6.0, contrib hooks: 2024.6\r\n* 503 INFO: Python: 3.12.0\r\n* 541 INFO: Platform: Windows-10-10.0.19045-SP0\r\n\r\n\r\n\n", "before_files": [{"content": "#-----------------------------------------------------------------------------\n# Copyright (c) 2020-2023, PyInstaller Development Team.\n#\n# Distributed under the terms of the GNU General Public License (version 2\n# or later) with exception for distributing the bootloader.\n#\n# The full license is in the file COPYING.txt, distributed with this software.\n#\n# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)\n#-----------------------------------------------------------------------------\n\n# TODO: remove this hook during PyInstaller 4.5 release cycle!\n\nfrom PyInstaller.utils.hooks import can_import_module, collect_submodules\n\n# We need to collect submodules from win32ctypes.core.cffi or win32ctypes.core.ctypes for win32ctypes.core to work. The\n# use of the backend is determined by availability of cffi.\nif can_import_module('cffi'):\n    hiddenimports = collect_submodules('win32ctypes.core.cffi')\nelse:\n    hiddenimports = collect_submodules('win32ctypes.core.ctypes')\n", "path": "PyInstaller/hooks/hook-win32ctypes.core.py"}]}