Skip to content

Commit efea926

Browse files
author
Kevin D Smith
committed
TKPATH fixes
1 parent 9a60825 commit efea926

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

swat/clib.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import glob
2727
import os
28+
import platform
2829
import sys
2930
from .utils.compat import PY3, WIDE_CHARS, a2u
3031
from .exceptions import SWATError
@@ -137,11 +138,24 @@ def InitializeTK(*args, **kwargs):
137138
''' Initialize the TK subsystem (importing _pyswat as needed) '''
138139
if _pyswat is None:
139140
_import_pyswat()
140-
out = _pyswat.InitializeTK(*args, **kwargs)
141-
# Override TKPATH after initialization so that other TK applications
142-
# won't be affected.
143-
if sys.platform.lower().startswith('win') and 'TKPATH' not in os.environ:
144-
os.environ['TKPATH'] = os.pathsep
141+
142+
# Patch ppc linux path
143+
set_tkpath_env = 'ppc' in platform.machine() and 'TKPATH' not in os.environ
144+
if set_tkpath_env and args:
145+
os.environ['TKPATH'] = args[0]
146+
147+
try:
148+
out = _pyswat.InitializeTK(*args, **kwargs)
149+
150+
finally:
151+
if set_tkpath_env:
152+
del os.environ['TKPATH']
153+
154+
# Override TKPATH after initialization so that other TK applications
155+
# won't be affected (Windows only).
156+
if sys.platform.lower().startswith('win') and 'TKPATH' not in os.environ:
157+
os.environ['TKPATH'] = os.pathsep
158+
145159
return out
146160

147161

0 commit comments

Comments
 (0)