pyinstaller / pyinstaller-hooks-contrib

Community maintained hooks for PyInstaller.
Other
96 stars 126 forks source link

Missing imports during packaging with PyInstaller 5.13 and pyinstaller-hooks-contrib 2023.12 #686

Open rly opened 10 months ago

rly commented 10 months ago

Describe the bug Using PyInstaller 5.13 and the latest pyinstaller-hooks-contrib 2023.12 release results in ModuleNotFoundError: No module named 'h5py.defs' when running our tests on a PyInstaller executable (https://github.com/NeurodataWithoutBorders/nwb-guide/issues/559). Tests were passing with version 2023.11 using the same version of PyInstaller 5.13. Pinning pyinstaller-hooks-contrib to the earlier 2023.11 fixes the issue. Upgrading PyInstaller to the latest 6.3.0 also fixes the issue. So there seems to be an incompatibility between PyInstaller 5.13 and the latest pyinstaller-hooks-contrib 2023.12. I have not tested other versions beyond those mentioned.

The h5py hooks should have been loaded from https://github.com/pyinstaller/pyinstaller-hooks-contrib/blob/master/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-h5py.py but the logs indicate that they were not. This PR https://github.com/pyinstaller/pyinstaller-hooks-contrib/pull/677 was merged in 2023.12 . Since it relates to how pyinstaller finds hooks, I wonder if this caused the issue.

Since I was able to resolve this issue by upgrading to the latest version of PyInstaller, I have no requests. I'm creating this ticket to let you all know about the incompatibility and inform anyone else who might encounter the same issue. Feel free to close this.

To Reproduce Sorry, I am not a pyinstaller expert and creating a MWE would take some time...

Expected behavior Expected no change in pyinstaller behavior between pyinstaller-hooks-contrib = 2023.11 and pyinstaller-hooks-contrib = 2023.12.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context

rokm commented 10 months ago

https://github.com/NeurodataWithoutBorders/nwb-guide/actions/runs/7409596543/job/20160174711#step:11:492

In the failed run, the pyinstaller-hooks-contrib hooks are not registered, because the installed packaging version does not meet the minimum version requirement (pyinstaller-hooks-contrib 2023.12 added a dependency on packaging >= 22.0 in #676).

I cannot reproduce the problem when doing a pip install pyinstaller==5.13.2 in a clean virtual environment made with python.org python - the latest version of packaging (23.2 at the time of writing) is installe).

I do note, however, that you are installing pyinstaller and pyinstaller-hooks-contrib from conda, so my guess would be that they do not properly declare the new dependency in their pyinstaller-hooks-contrib package. (PyInstaller >= 6.0 also depends on packaging >= 22.0, and it is likely that conda does properly declare that dependency for PyInstaller package; that's why it works for PyInstaller 6.3, but not for 5.13.2).

rly commented 10 months ago

Thanks @rokm for the detailed investigation! The issue with packaging makes sense. Indeed, the conda-forge version of PyInstaller, pyinstaller-feedstock, added packaging>=20.0 as a requirement in PyInstaller 6.0, and the conda-forge version of pyinstaller-hooks-contrib does not list packaging as a requirement

I created an issue and PR on https://github.com/conda-forge/pyinstaller-hooks-contrib-feedstock/issues/40 to add the packaging >= 22.0 requirement. I also created an issue and PR on https://github.com/conda-forge/pyinstaller-feedstock/issues/106 to update the packaging >= 20.0 -> 22.0 requirement for PyInstaller 6.3.0.