Tribler / tribler

Privacy enhanced BitTorrent client with P2P content discovery
https://www.tribler.org
GNU General Public License v3.0
4.74k stars 445 forks source link

[7.14 release branch] PyInstaller refuses to build Tribler on Mac #8002

Closed kozlovsky closed 2 months ago

kozlovsky commented 2 months ago

Suddenly, PyInstaller stopped building Tribler binaries on Mac yesterday.

with the following error:

85597 INFO: Loading module hook 'hook-cryptography.py' from '/Users/tribler/jenkins/workspace/Tribler/Build/Build-macOS/tribler/build-env/lib/python3.8/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks'...
85600 DEBUG: Hook failed with:
Traceback (most recent call last):
  File "/Users/tribler/jenkins/workspace/Tribler/Build/Build-macOS/tribler/build-env/lib/python3.8/site-packages/PyInstaller/depend/imphook.py", line 408, in _load_hook_module
    self._hook_module = importlib_load_source(
  File "/Users/tribler/jenkins/workspace/Tribler/Build/Build-macOS/tribler/build-env/lib/python3.8/site-packages/PyInstaller/compat.py", line 598, in importlib_load_source
    return mod_loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 462, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 962, in load_module
  File "<frozen importlib._bootstrap_external>", line 787, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 702, in _load
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/tribler/jenkins/workspace/Tribler/Build/Build-macOS/tribler/build-env/lib/python3.8/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-cryptography.py", line 21, in <module>
    from PyInstaller import isolated
ImportError: cannot import name 'isolated' from 'PyInstaller' (/Users/tribler/jenkins/workspace/Tribler/Build/Build-macOS/tribler/build-env/lib/python3.8/site-packages/PyInstaller/__init__.py)
Traceback (most recent call last):
  File "/Users/tribler/jenkins/workspace/Tribler/Build/Build-macOS/tribler/build-env/lib/python3.8/site-packages/PyInstaller/depend/imphook.py", line 408, in _load_hook_module
    self._hook_module = importlib_load_source(
  File "/Users/tribler/jenkins/workspace/Tribler/Build/Build-macOS/tribler/build-env/lib/python3.8/site-packages/PyInstaller/compat.py", line 598, in importlib_load_source
    return mod_loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 462, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 962, in load_module
  File "<frozen importlib._bootstrap_external>", line 787, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 702, in _load
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/tribler/jenkins/workspace/Tribler/Build/Build-macOS/tribler/build-env/lib/python3.8/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-cryptography.py", line 21, in <module>
    from PyInstaller import isolated
ImportError: cannot import name 'isolated' from 'PyInstaller' (/Users/tribler/jenkins/workspace/Tribler/Build/Build-macOS/tribler/build-env/lib/python3.8/site-packages/PyInstaller/__init__.py)

After some investigation, this is what happened:

So, PyInstaller 4.2 installed pyinstaller-hooks-contrib 2024.5 as a dependency. Then, pyinstaller-hooks-contrib tried importing from PyInstaller import isolated, which works only for Pyinstaller>=5.0.

As a workaround, we can pre-install pyinstaller-hooks-contrib 2024.4, which works with PyInstaller 4.2.

Later, we can reconsider specifying PyInstaller and pyinstaller-hooks-contrib directly in makedist_macos.sh and specify them in requirements-build.txt instead. We can probably also update PyInstaller to version >= 5.0.