[PATCH 1 of 2] thg: drop some macOS code from the main script

2 views
Skip to first unread message

Matt Harbison

unread,
Feb 22, 2025, 12:37:20 AMFeb 22
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1740199269 18000
# Fri Feb 21 23:41:09 2025 -0500
# Branch stable
# Node ID 75a7d2c5e3c54c673ffec8489ead5e767bba9970
# Parent 64eeec503fc29c0b2538de780904ed7504128bfb
# EXP-Topic packaging
thg: drop some macOS code from the main script

Not sure what this is, but there haven't been any Python 2.6 paths in a long
time.

diff --git a/thg b/thg
--- a/thg
+++ b/thg
@@ -15,11 +15,6 @@

thg_base_path = os.path.dirname(os.path.realpath(__file__))

-if 'THG_OSX_APP' in os.environ:
- # sys.path as created by py2app doesn't work quite right with demandimport
- # Add the explicit path where PyQt4 and other libs are
- sys.path.insert(0, os.path.join(thg_base_path, 'lib/python2.6/lib-dynload'))
-
if hasattr(sys, "frozen"):
if sys.frozen == 'windows_exe':
# sys.stdin is invalid, should be None. Fixes svn, git subrepos

Matt Harbison

unread,
Feb 22, 2025, 12:37:27 AMFeb 22
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# 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)

Antonio Muci

unread,
Feb 22, 2025, 2:04:11 AMFeb 22
to thg...@googlegroups.com, Matt Harbison
Sorry for the lame error.

Yuya Nishihara

unread,
Feb 22, 2025, 8:26:51 AMFeb 22
to Matt Harbison, thg...@googlegroups.com
On Sat, 22 Feb 2025 00:37:07 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_h...@yahoo.com>
> # Date 1740199269 18000
> # Fri Feb 21 23:41:09 2025 -0500
> # Branch stable
> # Node ID 75a7d2c5e3c54c673ffec8489ead5e767bba9970
> # Parent 64eeec503fc29c0b2538de780904ed7504128bfb
> # EXP-Topic packaging
> thg: drop some macOS code from the main script

Queued, thanks.

Matt Harbison

unread,
Feb 22, 2025, 2:13:39 PMFeb 22
to TortoiseHg Developers
No problem- it's a subtle reason for being conditionalized like that.  I'm just glad I found it, because I thought it was related to the new build environment.
Reply all
Reply to author
Forward
0 new messages