Repository: pyinstaller/pyinstaller

Issue:
Incompatible change in collect_entry_point
## Description of the issue

In https://github.com/pyinstaller/pyinstaller/pull/7943/commits/7889dbe929ebef3aabb3e69042d5c21a50f4ecbc, the `collect_entry_point` hook util was updated to use importlib.metadata. However, the imports returned now includes the Class name instead of only the module name.

### Context information (for bug reports)

* Output of `pyinstaller --version`: latest develop
* Version of Python: 3.12.0rc2
* Platform: Linux openSUSE Aeon
* How you installed Python: pyenv
* Did you also try this on another platform? Does it work there? I haven't tried


### Make sure [everything is packaged correctly](https://github.com/pyinstaller/pyinstaller/wiki/How-to-Report-Bugs#make-sure-everything-is-packaged-correctly)

  * [X] start with clean installation
  * [X] use the latest development version
  * [X] Run your frozen program **from a command window (shell)** — instead of double-clicking on it
  * [X] Package your program in **--onedir mode**
  * [X] Package **without UPX**, say: use the option `--noupx` or set `upx=False` in your .spec-file
  * [X] Repackage you application in **verbose/debug mode**. For this, pass the option `--debug` to `pyi-makespec` or `pyinstaller` or use `EXE(..., debug=1, ...)` in your .spec file.


### A minimal example program which shows the error

In PyInstaller 5.13.2:
```
collect_entry_point("gaphor.modelinglanguages")
([('/home/dan/Projects/gaphor/.venv/lib/python3.12/site-packages/gaphor-2.21.0.dist-info',
   'gaphor-2.21.0.dist-info'),
  ('/home/dan/Projects/gaphor/.venv/lib/python3.12/site-packages/gaphor-2.21.0.dist-info',
   'gaphor-2.21.0.dist-info'),
  ('/home/dan/Projects/gaphor/.venv/lib/python3.12/site-packages/gaphor-2.21.0.dist-info',
   'gaphor-2.21.0.dist-info'),
  ('/home/dan/Projects/gaphor/.venv/lib/python3.12/site-packages/gaphor-2.21.0.dist-info',
   'gaphor-2.21.0.dist-info'),
  ('/home/dan/Projects/gaphor/.venv/lib/python3.12/site-packages/gaphor-2.21.0.dist-info',
   'gaphor-2.21.0.dist-info')],
 ['gaphor.C4Model.modelinglanguage',
  'gaphor.core.modeling.modelinglanguage',
  'gaphor.RAAML.modelinglanguage',
  'gaphor.SysML.modelinglanguage',
  'gaphor.UML.modelinglanguage'])
```

In PyInstaller 6.0 and latest Develop:
```
collect_entry_point("gaphor.modelinglanguages")
Out[4]: 
([('/home/dan/Projects/gaphor/.venv/lib/python3.12/site-packages/gaphor-2.21.0.dist-info',
   'gaphor-2.21.0.dist-info'),
  ('/home/dan/Projects/gaphor/.venv/lib/python3.12/site-packages/gaphor-2.21.0.dist-info',
   'gaphor-2.21.0.dist-info'),
  ('/home/dan/Projects/gaphor/.venv/lib/python3.12/site-packages/gaphor-2.21.0.dist-info',
   'gaphor-2.21.0.dist-info'),
  ('/home/dan/Projects/gaphor/.venv/lib/python3.12/site-packages/gaphor-2.21.0.dist-info',
   'gaphor-2.21.0.dist-info'),
  ('/home/dan/Projects/gaphor/.venv/lib/python3.12/site-packages/gaphor-2.21.0.dist-info',
   'gaphor-2.21.0.dist-info')],
 ['gaphor.C4Model.modelinglanguage:C4ModelLanguage',
  'gaphor.core.modeling.modelinglanguage:CoreModelingLanguage',
  'gaphor.RAAML.modelinglanguage:RAAMLModelingLanguage',
  'gaphor.SysML.modelinglanguage:SysMLModelingLanguage',
  'gaphor.UML.modelinglanguage:UMLModelingLanguage'])
```

If you agree that this change in behavior is a bug, I can submit a PR to fix it :+1:, thanks!



Discussion:
> If you agree that this change in behavior is a bug, I can submit a PR to fix it 👍, thanks!

Sure, go ahead. 

Resolving patch:
diff --git a/PyInstaller/utils/hooks/__init__.py b/PyInstaller/utils/hooks/__init__.py
--- a/PyInstaller/utils/hooks/__init__.py
+++ b/PyInstaller/utils/hooks/__init__.py
@@ -1122,7 +1122,7 @@ def collect_entry_point(name: str):
     imports = []
     for entry_point in importlib_metadata.entry_points(group=name):
         datas += copy_metadata(entry_point.dist.name)
-        imports.append(entry_point.value)
+        imports.append(entry_point.module)
     return datas, imports
 
 


Test patch: