Tribler / tribler

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

is_frozen() returns the wrong result when the Tribler binary is built with cx_freeze instead of PyInstaller #8000

Closed kozlovsky closed 5 months ago

kozlovsky commented 5 months ago

Recently, we switched from PyInstaller to cx_freeze on Windows.

Some parts of Tribler logic rely on the is_frozen function, which checks the presence of the sys._MEIPASS attribute as a sign that Tribler runs as a binary.

Unfortunately, sys._MEIPASS is a PyInstaller-only attribute, and cx_freeze does not set it. As a result, for Tribler binaries on Windows, is_frozen currently returns False, which affects some important parts of the logic.

The correct logic of is_frozen should also check the presence of the sys.frozen attribute that is set to True in cx_freeze-generated binaries.