# Date 1740199947 18000
# Fri Feb 21 23:52:27 2025 -0500
# Branch stable
# Node ID 339021eefeff0dc10b8dced34c0c380a83ee3af2
# Parent 75a7d2c5e3c54c673ffec8489ead5e767bba9970
# EXP-Topic packaging
thg: avoid referencing `__file__` in the main script in frozen builds
I got this when launching WorkBench on Windows (macOS seemed OK):
Traceback (most recent call last):
File "thg", line 16, in <module>
NameError: name '__file__' is not defined
It looks like this broke in 326e8dde97a9, as `__file__` was avoided in forzen
builds prior to that.
diff --git a/thg b/thg
--- a/thg
+++ b/thg
@@ -13,7 +13,6 @@
import os
import sys
-thg_base_path = os.path.dirname(os.path.realpath(__file__))
if hasattr(sys, "frozen"):
if sys.frozen == 'windows_exe':
@@ -100,6 +99,8 @@
'system32', 'cmd.exe')
os.environ['COMSPEC'] = comspec
else:
+ thg_base_path = os.path.dirname(os.path.realpath(__file__))
+
testpath = os.path.join(thg_base_path, 'tortoisehg')
if os.path.isdir(testpath) and thg_base_path not in sys.path:
sys.path.insert(0, thg_base_path)