prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Py3.6: Unable to find .../site-packages/importlib_resources/version.txt"
  Hello,
  
  On latest version of pyinstaller, the hook for importlib_resource seems to look for a non existing version.txt file. It is not provided by the latest version 1.2.0 of the backport: https://gitlab.com/python-devs/importlib_resources
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `PyInstaller/hooks/hook-importlib_resources.py`
  Content:
  ```
  1 #-----------------------------------------------------------------------------
  2 # Copyright (c) 2019-2020, 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 `importlib_resources` is a backport of the 3.7+ module `importlib.resources`
  13 """
  14 
  15 import os
  16 from PyInstaller.compat import is_py37
  17 from PyInstaller.utils.hooks import get_module_file_attribute
  18 
  19 # Include the version.txt file, used to set __version__
  20 res_loc = os.path.dirname(get_module_file_attribute('importlib_resources'))
  21 datas = [
  22     (os.path.join(res_loc, 'version.txt'), 'importlib_resources'),
  23 ]
  24 
  25 # Replicate the module's version checks to exclude unused modules.
  26 if is_py37:
  27     # Stdlib now has the implmentation of this, so the backports
  28     # aren't used at all
  29     excludedmodules = [
  30         'importlib_resources._py2',
  31         'importlib_resources._py3',
  32     ]
  33 else:
  34     excludedmodules = ['importlib_resources._py2']
  35
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/PyInstaller/hooks/hook-importlib_resources.py b/PyInstaller/hooks/hook-importlib_resources.py
  --- a/PyInstaller/hooks/hook-importlib_resources.py
  +++ b/PyInstaller/hooks/hook-importlib_resources.py
  @@ -9,26 +9,25 @@
   # SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
   #-----------------------------------------------------------------------------
   """
  -`importlib_resources` is a backport of the 3.7+ module `importlib.resources`
  +`importlib_resources` is a backport of the 3.9+ module `importlib.resources`
   """
   
   import os
  -from PyInstaller.compat import is_py37
  -from PyInstaller.utils.hooks import get_module_file_attribute
  +from PyInstaller.utils.hooks import get_module_file_attribute, \
  +    is_module_satisfies, copy_metadata
   
  -# Include the version.txt file, used to set __version__
  -res_loc = os.path.dirname(get_module_file_attribute('importlib_resources'))
  -datas = [
  -    (os.path.join(res_loc, 'version.txt'), 'importlib_resources'),
  -]
  -
  -# Replicate the module's version checks to exclude unused modules.
  -if is_py37:
  -    # Stdlib now has the implmentation of this, so the backports
  -    # aren't used at all
  -    excludedmodules = [
  -        'importlib_resources._py2',
  -        'importlib_resources._py3',
  -    ]
  +if is_module_satisfies("importlib_resources >= 1.2.0"):
  +    # since 1.2.0 importlib.metadata is used
  +    datas = copy_metadata('importlib_resources')
   else:
  -    excludedmodules = ['importlib_resources._py2']
  +    # include the version.txt file, used to set __version__
  +    res_loc = os.path.dirname(get_module_file_attribute('importlib_resources'))
  +    datas = [
  +        (os.path.join(res_loc, 'version.txt'), 'importlib_resources'),
  +    ]
  +
  +if is_module_satisfies("importlib_resources >= 1.3.1"):
  +    hiddenimports = ['importlib_resources.trees']
  +
  +# this is only required for python2 support
  +excludedimports = ['importlib_resources._py2']
  
verification_info: {"golden_diff": "diff --git a/PyInstaller/hooks/hook-importlib_resources.py b/PyInstaller/hooks/hook-importlib_resources.py\n--- a/PyInstaller/hooks/hook-importlib_resources.py\n+++ b/PyInstaller/hooks/hook-importlib_resources.py\n@@ -9,26 +9,25 @@\n # SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)\n #-----------------------------------------------------------------------------\n \"\"\"\n-`importlib_resources` is a backport of the 3.7+ module `importlib.resources`\n+`importlib_resources` is a backport of the 3.9+ module `importlib.resources`\n \"\"\"\n \n import os\n-from PyInstaller.compat import is_py37\n-from PyInstaller.utils.hooks import get_module_file_attribute\n+from PyInstaller.utils.hooks import get_module_file_attribute, \\\n+    is_module_satisfies, copy_metadata\n \n-# Include the version.txt file, used to set __version__\n-res_loc = os.path.dirname(get_module_file_attribute('importlib_resources'))\n-datas = [\n-    (os.path.join(res_loc, 'version.txt'), 'importlib_resources'),\n-]\n-\n-# Replicate the module's version checks to exclude unused modules.\n-if is_py37:\n-    # Stdlib now has the implmentation of this, so the backports\n-    # aren't used at all\n-    excludedmodules = [\n-        'importlib_resources._py2',\n-        'importlib_resources._py3',\n-    ]\n+if is_module_satisfies(\"importlib_resources >= 1.2.0\"):\n+    # since 1.2.0 importlib.metadata is used\n+    datas = copy_metadata('importlib_resources')\n else:\n-    excludedmodules = ['importlib_resources._py2']\n+    # include the version.txt file, used to set __version__\n+    res_loc = os.path.dirname(get_module_file_attribute('importlib_resources'))\n+    datas = [\n+        (os.path.join(res_loc, 'version.txt'), 'importlib_resources'),\n+    ]\n+\n+if is_module_satisfies(\"importlib_resources >= 1.3.1\"):\n+    hiddenimports = ['importlib_resources.trees']\n+\n+# this is only required for python2 support\n+excludedimports = ['importlib_resources._py2']\n", "issue": "Py3.6: Unable to find .../site-packages/importlib_resources/version.txt\"\nHello,\r\n\r\nOn latest version of pyinstaller, the hook for importlib_resource seems to look for a non existing version.txt file. It is not provided by the latest version 1.2.0 of the backport: https://gitlab.com/python-devs/importlib_resources\n", "before_files": [{"content": "#-----------------------------------------------------------------------------\n# Copyright (c) 2019-2020, 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`importlib_resources` is a backport of the 3.7+ module `importlib.resources`\n\"\"\"\n\nimport os\nfrom PyInstaller.compat import is_py37\nfrom PyInstaller.utils.hooks import get_module_file_attribute\n\n# Include the version.txt file, used to set __version__\nres_loc = os.path.dirname(get_module_file_attribute('importlib_resources'))\ndatas = [\n    (os.path.join(res_loc, 'version.txt'), 'importlib_resources'),\n]\n\n# Replicate the module's version checks to exclude unused modules.\nif is_py37:\n    # Stdlib now has the implmentation of this, so the backports\n    # aren't used at all\n    excludedmodules = [\n        'importlib_resources._py2',\n        'importlib_resources._py3',\n    ]\nelse:\n    excludedmodules = ['importlib_resources._py2']\n", "path": "PyInstaller/hooks/hook-importlib_resources.py"}], "after_files": [{"content": "#-----------------------------------------------------------------------------\n# Copyright (c) 2019-2020, 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`importlib_resources` is a backport of the 3.9+ module `importlib.resources`\n\"\"\"\n\nimport os\nfrom PyInstaller.utils.hooks import get_module_file_attribute, \\\n    is_module_satisfies, copy_metadata\n\nif is_module_satisfies(\"importlib_resources >= 1.2.0\"):\n    # since 1.2.0 importlib.metadata is used\n    datas = copy_metadata('importlib_resources')\nelse:\n    # include the version.txt file, used to set __version__\n    res_loc = os.path.dirname(get_module_file_attribute('importlib_resources'))\n    datas = [\n        (os.path.join(res_loc, 'version.txt'), 'importlib_resources'),\n    ]\n\nif is_module_satisfies(\"importlib_resources >= 1.3.1\"):\n    hiddenimports = ['importlib_resources.trees']\n\n# this is only required for python2 support\nexcludedimports = ['importlib_resources._py2']\n", "path": "PyInstaller/hooks/hook-importlib_resources.py"}]}